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 internal string styleName;
34 /// The color mode of View.
35 /// This specifies whether the View uses its own color, or inherits its parent color.
36 /// The default is ColorMode.UseOwnMultiplyParentColor.
38 internal ColorMode ColorMode
46 return GetColorMode();
50 internal LayoutLength SuggestedMinimumWidth
54 float result = Interop.Actor.GetSuggestedMinimumWidth(SwigCPtr);
55 if (NDalicPINVOKE.SWIGPendingException.Pending)
56 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
57 return new LayoutLength(result);
61 internal LayoutLength SuggestedMinimumHeight
65 float result = Interop.Actor.GetSuggestedMinimumHeight(SwigCPtr);
66 if (NDalicPINVOKE.SWIGPendingException.Pending)
67 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
68 return new LayoutLength(result);
72 internal float WorldPositionX
76 float returnValue = 0.0f;
77 PropertyValue wordPositionX = GetProperty(View.Property.WorldPositionX);
78 wordPositionX?.Get(out returnValue);
79 wordPositionX?.Dispose();
84 internal float WorldPositionY
88 float returnValue = 0.0f;
89 PropertyValue wordPositionY = GetProperty(View.Property.WorldPositionY);
90 wordPositionY?.Get(out returnValue);
91 wordPositionY?.Dispose();
96 internal float WorldPositionZ
100 float returnValue = 0.0f;
101 PropertyValue wordPositionZ = GetProperty(View.Property.WorldPositionZ);
102 wordPositionZ?.Get(out returnValue);
103 wordPositionZ?.Dispose();
108 internal bool FocusState
112 return IsKeyboardFocusable();
116 SetKeyboardFocusable(value);
120 internal void SetLayout(LayoutItem layout)
122 Window.Instance.LayoutController.CreateProcessCallback();
123 this.layout = layout;
124 this.layout?.AttachToOwner(this);
125 this.layout?.RequestLayout();
128 internal void AttachTransitionsToChildren(LayoutTransition transition)
130 // Iterate children, adding the transition unless a transition
131 // for the same condition and property has already been
133 foreach (View view in Children)
135 LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions, transition.Condition, transition, false);
139 internal float ParentOriginX
143 float returnValue = 0.0f;
144 PropertyValue parentOriginX = GetProperty(View.Property.ParentOriginX);
145 parentOriginX?.Get(out returnValue);
146 parentOriginX?.Dispose();
151 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
152 SetProperty(View.Property.ParentOriginX, setValue);
154 NotifyPropertyChanged();
158 internal float ParentOriginY
162 float returnValue = 0.0f;
163 PropertyValue parentOriginY = GetProperty(View.Property.ParentOriginY);
164 parentOriginY?.Get(out returnValue);
165 parentOriginY?.Dispose();
170 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
171 SetProperty(View.Property.ParentOriginY, setValue);
173 NotifyPropertyChanged();
177 internal float ParentOriginZ
181 float returnValue = 0.0f;
182 PropertyValue parentOriginZ = GetProperty(View.Property.ParentOriginZ);
183 parentOriginZ?.Get(out returnValue);
184 parentOriginZ?.Dispose();
189 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
190 SetProperty(View.Property.ParentOriginZ, setValue);
192 NotifyPropertyChanged();
196 internal float PivotPointX
200 float returnValue = 0.0f;
201 PropertyValue anchorPointX = GetProperty(View.Property.AnchorPointX);
202 anchorPointX?.Get(out returnValue);
203 anchorPointX?.Dispose();
208 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
209 SetProperty(View.Property.AnchorPointX, setValue);
214 internal float PivotPointY
218 float returnValue = 0.0f;
219 PropertyValue anchorPointY = GetProperty(View.Property.AnchorPointY);
220 anchorPointY?.Get(out returnValue);
221 anchorPointY?.Dispose();
226 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
227 SetProperty(View.Property.AnchorPointY, setValue);
232 internal float PivotPointZ
236 float returnValue = 0.0f;
237 PropertyValue anchorPointZ = GetProperty(View.Property.AnchorPointZ);
238 anchorPointZ?.Get(out returnValue);
239 anchorPointZ?.Dispose();
244 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
245 SetProperty(View.Property.AnchorPointZ, setValue);
250 internal Matrix WorldMatrix
254 Matrix returnValue = new Matrix();
255 PropertyValue wordMatrix = GetProperty(View.Property.WorldMatrix);
256 wordMatrix?.Get(returnValue);
257 wordMatrix?.Dispose();
263 /// Indicates that this View should listen Touch event to handle its ControlState.
265 private bool enableControlState = false;
267 private int LeftFocusableViewId
272 PropertyValue leftFocusableViewId = GetProperty(View.Property.LeftFocusableViewId);
273 leftFocusableViewId?.Get(out returnValue);
274 leftFocusableViewId?.Dispose();
279 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
280 SetProperty(View.Property.LeftFocusableViewId, setValue);
285 private int RightFocusableViewId
290 PropertyValue rightFocusableViewId = GetProperty(View.Property.RightFocusableViewId);
291 rightFocusableViewId?.Get(out returnValue);
292 rightFocusableViewId?.Dispose();
297 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
298 SetProperty(View.Property.RightFocusableViewId, setValue);
303 private int UpFocusableViewId
308 PropertyValue upFocusableViewId = GetProperty(View.Property.UpFocusableViewId);
309 upFocusableViewId?.Get(out returnValue);
310 upFocusableViewId?.Dispose();
315 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
316 SetProperty(View.Property.UpFocusableViewId, setValue);
321 private int DownFocusableViewId
326 PropertyValue downFocusableViewId = GetProperty(View.Property.DownFocusableViewId);
327 downFocusableViewId?.Get(out returnValue);
328 downFocusableViewId?.Dispose();
333 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
334 SetProperty(View.Property.DownFocusableViewId, setValue);
339 internal void Raise()
341 var parentChildren = GetParent()?.Children;
343 if (parentChildren != null)
345 int currentIndex = parentChildren.IndexOf(this);
347 // If the view is not already the last item in the list.
348 if (currentIndex >= 0 && currentIndex < parentChildren.Count - 1)
350 View temp = parentChildren[currentIndex + 1];
351 parentChildren[currentIndex + 1] = this;
352 parentChildren[currentIndex] = temp;
354 Interop.NDalic.Raise(SwigCPtr);
355 if (NDalicPINVOKE.SWIGPendingException.Pending)
356 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
361 internal void Lower()
363 var parentChildren = GetParent()?.Children;
365 if (parentChildren != null)
367 int currentIndex = parentChildren.IndexOf(this);
369 // If the view is not already the first item in the list.
370 if (currentIndex > 0 && currentIndex < parentChildren.Count)
372 View temp = parentChildren[currentIndex - 1];
373 parentChildren[currentIndex - 1] = this;
374 parentChildren[currentIndex] = temp;
376 Interop.NDalic.Lower(SwigCPtr);
377 if (NDalicPINVOKE.SWIGPendingException.Pending)
378 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
384 /// Raises the view to above the target view.
386 /// <remarks>The sibling order of views within the parent will be updated automatically.
387 /// Views on the level above the target view will still be shown above this view.
388 /// Raising this view above views with the same sibling order as each other will raise this view above them.
389 /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion.
391 /// <param name="target">Will be raised above this view.</param>
392 internal void RaiseAbove(View target)
394 var parentChildren = GetParent()?.Children;
396 if (parentChildren != null)
398 int currentIndex = parentChildren.IndexOf(this);
399 int targetIndex = parentChildren.IndexOf(target);
401 if (currentIndex < 0 || targetIndex < 0 ||
402 currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
404 NUILog.Error("index should be bigger than 0 and less than children of layer count");
407 // If the currentIndex is less than the target index and the target has the same parent.
408 if (currentIndex < targetIndex)
410 parentChildren.Remove(this);
411 parentChildren.Insert(targetIndex, this);
413 Interop.NDalic.RaiseAbove(SwigCPtr, View.getCPtr(target));
414 if (NDalicPINVOKE.SWIGPendingException.Pending)
415 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
422 /// Lowers the view to below the target view.
424 /// <remarks>The sibling order of views within the parent will be updated automatically.
425 /// Lowering this view below views with the same sibling order as each other will lower this view above them.
426 /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion.
428 /// <param name="target">Will be lowered below this view.</param>
429 internal void LowerBelow(View target)
431 var parentChildren = GetParent()?.Children;
433 if (parentChildren != null)
435 int currentIndex = parentChildren.IndexOf(this);
436 int targetIndex = parentChildren.IndexOf(target);
437 if (currentIndex < 0 || targetIndex < 0 ||
438 currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
440 NUILog.Error("index should be bigger than 0 and less than children of layer count");
444 // If the currentIndex is not already the 0th index and the target has the same parent.
445 if ((currentIndex != 0) && (targetIndex != -1) &&
446 (currentIndex > targetIndex))
448 parentChildren.Remove(this);
449 parentChildren.Insert(targetIndex, this);
451 Interop.NDalic.LowerBelow(SwigCPtr, View.getCPtr(target));
452 if (NDalicPINVOKE.SWIGPendingException.Pending)
453 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
459 internal string GetName()
461 string ret = Interop.Actor.GetName(SwigCPtr);
462 if (NDalicPINVOKE.SWIGPendingException.Pending)
463 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
467 internal void SetName(string name)
469 Interop.Actor.SetName(SwigCPtr, name);
470 if (NDalicPINVOKE.SWIGPendingException.Pending)
471 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
474 internal uint GetId()
476 uint ret = Interop.Actor.GetId(SwigCPtr);
477 if (NDalicPINVOKE.SWIGPendingException.Pending)
478 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
482 internal bool IsRoot()
484 bool ret = Interop.ActorInternal.IsRoot(SwigCPtr);
485 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
489 internal bool OnWindow()
491 bool ret = Interop.Actor.OnStage(SwigCPtr);
492 if (NDalicPINVOKE.SWIGPendingException.Pending)
493 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
497 internal View FindChildById(uint id)
499 //to fix memory leak issue, match the handle count with native side.
500 IntPtr cPtr = Interop.Actor.FindChildById(SwigCPtr, id);
501 View ret = this.GetInstanceSafely<View>(cPtr);
502 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
506 internal override View FindCurrentChildById(uint id)
508 return FindChildById(id);
511 internal void SetParentOrigin(Vector3 origin)
513 Interop.ActorInternal.SetParentOrigin(SwigCPtr, Vector3.getCPtr(origin));
514 if (NDalicPINVOKE.SWIGPendingException.Pending)
515 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
518 internal Vector3 GetCurrentParentOrigin()
520 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentParentOrigin(SwigCPtr), true);
521 if (NDalicPINVOKE.SWIGPendingException.Pending)
522 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
526 internal void SetAnchorPoint(Vector3 anchorPoint)
528 Interop.Actor.SetAnchorPoint(SwigCPtr, Vector3.getCPtr(anchorPoint));
529 if (NDalicPINVOKE.SWIGPendingException.Pending)
530 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
533 internal Vector3 GetCurrentAnchorPoint()
535 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentAnchorPoint(SwigCPtr), true);
536 if (NDalicPINVOKE.SWIGPendingException.Pending)
537 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
541 internal void SetSize(float width, float height)
543 Interop.ActorInternal.SetSize(SwigCPtr, width, height);
544 if (NDalicPINVOKE.SWIGPendingException.Pending)
545 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
548 internal void SetSize(float width, float height, float depth)
550 Interop.ActorInternal.SetSize(SwigCPtr, width, height, depth);
551 if (NDalicPINVOKE.SWIGPendingException.Pending)
552 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
555 internal void SetSize(Vector2 size)
557 Interop.ActorInternal.SetSizeVector2(SwigCPtr, Vector2.getCPtr(size));
558 if (NDalicPINVOKE.SWIGPendingException.Pending)
559 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
562 internal void SetSize(Vector3 size)
564 Interop.ActorInternal.SetSizeVector3(SwigCPtr, Vector3.getCPtr(size));
565 if (NDalicPINVOKE.SWIGPendingException.Pending)
566 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
569 internal Vector3 GetTargetSize()
571 Vector3 ret = new Vector3(Interop.ActorInternal.GetTargetSize(SwigCPtr), true);
572 if (NDalicPINVOKE.SWIGPendingException.Pending)
573 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
577 internal Size2D GetCurrentSize()
579 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
580 if (NDalicPINVOKE.SWIGPendingException.Pending)
581 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
582 Size2D size = new Size2D((int)ret.Width, (int)ret.Height);
587 internal Size2D GetCurrentSizeFloat()
589 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
590 if (NDalicPINVOKE.SWIGPendingException.Pending)
591 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
595 internal Vector3 GetNaturalSize()
597 Vector3 ret = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
598 if (NDalicPINVOKE.SWIGPendingException.Pending)
599 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
603 internal void SetPosition(float x, float y)
605 Interop.ActorInternal.SetPosition(SwigCPtr, x, y);
606 if (NDalicPINVOKE.SWIGPendingException.Pending)
607 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
610 internal void SetPosition(float x, float y, float z)
612 Interop.ActorInternal.SetPosition(SwigCPtr, x, y, z);
613 if (NDalicPINVOKE.SWIGPendingException.Pending)
614 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
617 internal void SetPosition(Vector3 position)
619 Interop.ActorInternal.SetPosition(SwigCPtr, Vector3.getCPtr(position));
620 if (NDalicPINVOKE.SWIGPendingException.Pending)
621 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
624 internal void SetX(float x)
626 Interop.ActorInternal.SetX(SwigCPtr, x);
627 if (NDalicPINVOKE.SWIGPendingException.Pending)
628 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
631 internal void SetY(float y)
633 Interop.ActorInternal.SetY(SwigCPtr, y);
634 if (NDalicPINVOKE.SWIGPendingException.Pending)
635 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
638 internal void SetZ(float z)
640 Interop.ActorInternal.SetZ(SwigCPtr, z);
641 if (NDalicPINVOKE.SWIGPendingException.Pending)
642 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
645 internal void TranslateBy(Vector3 distance)
647 Interop.ActorInternal.TranslateBy(SwigCPtr, Vector3.getCPtr(distance));
648 if (NDalicPINVOKE.SWIGPendingException.Pending)
649 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
652 internal Position GetCurrentPosition()
654 Position ret = new Position(Interop.Actor.GetCurrentPosition(SwigCPtr), true);
655 if (NDalicPINVOKE.SWIGPendingException.Pending)
656 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
660 internal Vector3 GetCurrentWorldPosition()
662 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldPosition(SwigCPtr), true);
663 if (NDalicPINVOKE.SWIGPendingException.Pending)
664 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
668 internal void SetInheritPosition(bool inherit)
670 Interop.ActorInternal.SetInheritPosition(SwigCPtr, inherit);
671 if (NDalicPINVOKE.SWIGPendingException.Pending)
672 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
675 internal bool IsPositionInherited()
677 bool ret = Interop.ActorInternal.IsPositionInherited(SwigCPtr);
678 if (NDalicPINVOKE.SWIGPendingException.Pending)
679 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
683 internal void SetOrientation(Degree angle, Vector3 axis)
685 Interop.ActorInternal.SetOrientationDegree(SwigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
686 if (NDalicPINVOKE.SWIGPendingException.Pending)
687 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
690 internal void SetOrientation(Radian angle, Vector3 axis)
692 Interop.ActorInternal.SetOrientationRadian(SwigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
693 if (NDalicPINVOKE.SWIGPendingException.Pending)
694 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
697 internal void SetOrientation(Rotation orientation)
699 Interop.ActorInternal.SetOrientationQuaternion(SwigCPtr, Rotation.getCPtr(orientation));
700 if (NDalicPINVOKE.SWIGPendingException.Pending)
701 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
704 internal Rotation GetCurrentOrientation()
706 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentOrientation(SwigCPtr), true);
707 if (NDalicPINVOKE.SWIGPendingException.Pending)
708 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
712 internal void SetInheritOrientation(bool inherit)
714 Interop.ActorInternal.SetInheritOrientation(SwigCPtr, inherit);
715 if (NDalicPINVOKE.SWIGPendingException.Pending)
716 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
719 internal bool IsOrientationInherited()
721 bool ret = Interop.ActorInternal.IsOrientationInherited(SwigCPtr);
722 if (NDalicPINVOKE.SWIGPendingException.Pending)
723 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
727 internal Rotation GetCurrentWorldOrientation()
729 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentWorldOrientation(SwigCPtr), true);
730 if (NDalicPINVOKE.SWIGPendingException.Pending)
731 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
735 internal void SetScale(float scale)
737 Interop.ActorInternal.SetScale(SwigCPtr, scale);
738 if (NDalicPINVOKE.SWIGPendingException.Pending)
739 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
742 internal void SetScale(float scaleX, float scaleY, float scaleZ)
744 Interop.ActorInternal.SetScale(SwigCPtr, scaleX, scaleY, scaleZ);
745 if (NDalicPINVOKE.SWIGPendingException.Pending)
746 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
749 internal void SetScale(Vector3 scale)
751 Interop.ActorInternal.SetScale(SwigCPtr, Vector3.getCPtr(scale));
752 if (NDalicPINVOKE.SWIGPendingException.Pending)
753 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
756 internal Vector3 GetCurrentScale()
758 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentScale(SwigCPtr), true);
759 if (NDalicPINVOKE.SWIGPendingException.Pending)
760 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
764 internal Vector3 GetCurrentWorldScale()
766 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldScale(SwigCPtr), true);
767 if (NDalicPINVOKE.SWIGPendingException.Pending)
768 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
772 internal void SetInheritScale(bool inherit)
774 Interop.ActorInternal.SetInheritScale(SwigCPtr, inherit);
775 if (NDalicPINVOKE.SWIGPendingException.Pending)
776 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
779 internal bool IsScaleInherited()
781 bool ret = Interop.ActorInternal.IsScaleInherited(SwigCPtr);
782 if (NDalicPINVOKE.SWIGPendingException.Pending)
783 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
787 internal Matrix GetCurrentWorldMatrix()
789 Matrix ret = new Matrix(Interop.ActorInternal.GetCurrentWorldMatrix(SwigCPtr), true);
790 if (NDalicPINVOKE.SWIGPendingException.Pending)
791 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
795 internal void SetVisible(bool visible)
797 Interop.Actor.SetVisible(SwigCPtr, visible);
798 if (NDalicPINVOKE.SWIGPendingException.Pending)
799 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
802 internal bool IsVisible()
804 bool ret = Interop.ActorInternal.IsVisible(SwigCPtr);
805 if (NDalicPINVOKE.SWIGPendingException.Pending)
806 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
810 internal void SetOpacity(float opacity)
812 Interop.ActorInternal.SetOpacity(SwigCPtr, opacity);
813 if (NDalicPINVOKE.SWIGPendingException.Pending)
814 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
817 internal float GetCurrentOpacity()
819 float ret = Interop.ActorInternal.GetCurrentOpacity(SwigCPtr);
820 if (NDalicPINVOKE.SWIGPendingException.Pending)
821 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
825 internal Vector4 GetCurrentColor()
827 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentColor(SwigCPtr), true);
828 if (NDalicPINVOKE.SWIGPendingException.Pending)
829 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
832 internal ColorMode GetColorMode()
834 ColorMode ret = (ColorMode)Interop.ActorInternal.GetColorMode(SwigCPtr);
835 if (NDalicPINVOKE.SWIGPendingException.Pending)
836 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
840 internal Vector4 GetCurrentWorldColor()
842 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentWorldColor(SwigCPtr), true);
843 if (NDalicPINVOKE.SWIGPendingException.Pending)
844 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
848 internal void SetDrawMode(DrawModeType drawMode)
850 Interop.ActorInternal.SetDrawMode(SwigCPtr, (int)drawMode);
851 if (NDalicPINVOKE.SWIGPendingException.Pending)
852 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
855 internal DrawModeType GetDrawMode()
857 DrawModeType ret = (DrawModeType)Interop.ActorInternal.GetDrawMode(SwigCPtr);
858 if (NDalicPINVOKE.SWIGPendingException.Pending)
859 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
863 internal void SetKeyboardFocusable(bool focusable)
865 Interop.ActorInternal.SetKeyboardFocusable(SwigCPtr, focusable);
866 if (NDalicPINVOKE.SWIGPendingException.Pending)
867 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
870 internal bool IsKeyboardFocusable()
872 bool ret = Interop.ActorInternal.IsKeyboardFocusable(SwigCPtr);
873 if (NDalicPINVOKE.SWIGPendingException.Pending)
874 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
878 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
880 Interop.Actor.SetResizePolicy(SwigCPtr, (int)policy, (int)dimension);
881 if (NDalicPINVOKE.SWIGPendingException.Pending)
882 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
885 internal ResizePolicyType GetResizePolicy(DimensionType dimension)
887 ResizePolicyType ret = (ResizePolicyType)Interop.Actor.GetResizePolicy(SwigCPtr, (int)dimension);
888 if (NDalicPINVOKE.SWIGPendingException.Pending)
889 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
893 internal Vector3 GetSizeModeFactor()
895 Vector3 ret = new Vector3(Interop.Actor.GetSizeModeFactor(SwigCPtr), true);
896 if (NDalicPINVOKE.SWIGPendingException.Pending)
897 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
901 internal void SetMinimumSize(Vector2 size)
903 Interop.ActorInternal.SetMinimumSize(SwigCPtr, Vector2.getCPtr(size));
904 if (NDalicPINVOKE.SWIGPendingException.Pending)
905 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
908 internal Vector2 GetMinimumSize()
910 Vector2 ret = new Vector2(Interop.ActorInternal.GetMinimumSize(SwigCPtr), true);
911 if (NDalicPINVOKE.SWIGPendingException.Pending)
912 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
916 internal void SetMaximumSize(Vector2 size)
918 Interop.ActorInternal.SetMaximumSize(SwigCPtr, Vector2.getCPtr(size));
919 if (NDalicPINVOKE.SWIGPendingException.Pending)
920 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
923 internal Vector2 GetMaximumSize()
925 Vector2 ret = new Vector2(Interop.ActorInternal.GetMaximumSize(SwigCPtr), true);
926 if (NDalicPINVOKE.SWIGPendingException.Pending)
927 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
931 internal int GetHierarchyDepth()
933 int ret = Interop.Actor.GetHierarchyDepth(SwigCPtr);
934 if (NDalicPINVOKE.SWIGPendingException.Pending)
935 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
939 internal uint GetRendererCount()
941 uint ret = Interop.Actor.GetRendererCount(SwigCPtr);
942 if (NDalicPINVOKE.SWIGPendingException.Pending)
943 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
947 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
949 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
952 internal bool IsTopLevelView()
954 if (GetParent() is Layer)
961 internal void SetKeyInputFocus()
963 Interop.ViewInternal.SetKeyInputFocus(SwigCPtr);
964 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
967 internal void ClearKeyInputFocus()
969 Interop.ViewInternal.ClearKeyInputFocus(SwigCPtr);
970 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
973 internal PinchGestureDetector GetPinchGestureDetector()
975 PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.GetPinchGestureDetector(SwigCPtr), true);
976 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
980 internal PanGestureDetector GetPanGestureDetector()
982 PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.GetPanGestureDetector(SwigCPtr), true);
983 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
987 internal TapGestureDetector GetTapGestureDetector()
989 TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.GetTapGestureDetector(SwigCPtr), true);
990 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
994 internal LongPressGestureDetector GetLongPressGestureDetector()
996 LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.GetLongPressGestureDetector(SwigCPtr), true);
997 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1001 internal IntPtr GetPtrfromView()
1003 return (IntPtr)SwigCPtr;
1006 internal void RemoveChild(View child)
1008 // Do actual child removal
1009 Interop.Actor.Remove(SwigCPtr, View.getCPtr(child));
1010 if (NDalicPINVOKE.SWIGPendingException.Pending)
1011 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1013 Children.Remove(child);
1014 child.InternalParent = null;
1016 RemoveChildBindableObject(child);
1018 if (ChildRemoved != null)
1020 ChildRemovedEventArgs e = new ChildRemovedEventArgs
1024 ChildRemoved(this, e);
1029 /// Removes the layout from this View.
1031 internal void ResetLayout()
1036 internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1038 return (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1041 /// TODO open as a protected level
1042 internal virtual void ApplyCornerRadius()
1044 if (backgroundExtraData == null) return;
1046 var cornerRadius = backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius);
1048 // Apply to the background visual
1049 PropertyMap backgroundMap = new PropertyMap();
1050 PropertyValue background = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.BACKGROUND);
1052 if (background.Get(backgroundMap) && !backgroundMap.Empty())
1054 backgroundMap[Visual.Property.CornerRadius] = cornerRadius;
1055 backgroundMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1056 var temp = new PropertyValue(backgroundMap);
1057 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.BACKGROUND, temp);
1060 backgroundMap.Dispose();
1061 background.Dispose();
1063 // Apply to the shadow visual
1064 PropertyMap shadowMap = new PropertyMap();
1065 PropertyValue shadow = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.SHADOW);
1066 if (shadow.Get(shadowMap) && !shadowMap.Empty())
1068 shadowMap[Visual.Property.CornerRadius] = cornerRadius;
1069 shadowMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1070 var temp = new PropertyValue(shadowMap);
1071 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.SHADOW, temp);
1074 shadowMap.Dispose();
1076 cornerRadius.Dispose();
1079 /// TODO open as a protected level
1080 internal virtual void ApplyBorderline()
1082 if (backgroundExtraData == null) return;
1084 var borderlineColor = backgroundExtraData.BorderlineColor == null ? new PropertyValue(Color.Black) : new PropertyValue(backgroundExtraData.BorderlineColor);
1086 // Apply to the background visual
1087 PropertyMap backgroundMap = new PropertyMap();
1088 PropertyValue background = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.BACKGROUND);
1089 if (background.Get(backgroundMap) && !backgroundMap.Empty())
1091 backgroundMap[Visual.Property.BorderlineWidth] = new PropertyValue(backgroundExtraData.BorderlineWidth);
1092 backgroundMap[Visual.Property.BorderlineColor] = borderlineColor;
1093 backgroundMap[Visual.Property.BorderlineOffset] = new PropertyValue(backgroundExtraData.BorderlineOffset);
1094 var temp = new PropertyValue(backgroundMap);
1095 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.BACKGROUND, temp);
1098 backgroundMap.Dispose();
1099 background.Dispose();
1100 borderlineColor.Dispose();
1104 /// Get selector value from the triggerable selector or related property.
1106 internal Selector<T> GetSelector<T>(TriggerableSelector<T> triggerableSelector, NUI.Binding.BindableProperty relatedProperty)
1108 var selector = triggerableSelector?.Get();
1109 if (selector != null)
1114 var value = (T)GetValue(relatedProperty);
1115 return value == null ? null : new Selector<T>(value);
1119 /// you can override it to clean-up your own resources.
1121 /// <param name="type">DisposeTypes</param>
1122 /// <since_tizen> 3 </since_tizen>
1123 protected override void Dispose(DisposeTypes type)
1130 //_mergedStyle = null;
1132 if (type == DisposeTypes.Explicit)
1135 //Release your own managed resources here.
1136 //You should release all of your own disposable objects here.
1137 themeData?.selectorData?.Reset(this);
1138 if (ThemeChangeSensitive)
1140 ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
1144 //Release your own unmanaged resources here.
1145 //You should not access any managed member here except static instance.
1146 //because the execution order of Finalizes is non-deterministic.
1149 DisConnectFromSignals();
1152 foreach (View view in Children)
1154 view.InternalParent = null;
1160 /// This will not be public opened.
1161 [EditorBrowsable(EditorBrowsableState.Never)]
1162 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1164 Interop.View.DeleteView(swigCPtr);
1168 /// The touch event handler for ControlState.
1169 /// Please change ControlState value by touch state if needed.
1171 /// <exception cref="ArgumentNullException"> Thrown when touch is null. </exception>
1172 [EditorBrowsable(EditorBrowsableState.Never)]
1173 protected virtual bool HandleControlStateOnTouch(Touch touch)
1177 throw new global::System.ArgumentNullException(nameof(touch));
1180 switch (touch.GetState(0))
1182 case PointStateType.Down:
1183 ControlState += ControlState.Pressed;
1185 case PointStateType.Interrupted:
1186 case PointStateType.Up:
1187 if (ControlState.Contains(ControlState.Pressed))
1189 ControlState -= ControlState.Pressed;
1198 private void DisConnectFromSignals()
1200 // Save current CPtr.
1201 global::System.Runtime.InteropServices.HandleRef currentCPtr = SwigCPtr;
1203 // Use BaseHandle CPtr as current might have been deleted already in derived classes.
1204 SwigCPtr = GetBaseHandleCPtrHandleRef;
1206 if (onRelayoutEventCallback != null)
1208 ViewSignal signal = this.OnRelayoutSignal();
1209 signal?.Disconnect(onRelayoutEventCallback);
1211 onRelayoutEventCallback = null;
1214 if (offWindowEventCallback != null)
1216 ViewSignal signal = this.OffWindowSignal();
1217 signal?.Disconnect(offWindowEventCallback);
1219 offWindowEventCallback = null;
1222 if (onWindowEventCallback != null)
1224 ViewSignal signal = this.OnWindowSignal();
1225 signal?.Disconnect(onWindowEventCallback);
1227 onWindowEventCallback = null;
1230 if (wheelEventCallback != null)
1232 WheelSignal signal = this.WheelEventSignal();
1233 signal?.Disconnect(wheelEventCallback);
1237 if (WindowWheelEventHandler != null)
1239 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
1242 if (hoverEventCallback != null)
1244 HoverSignal signal = this.HoveredSignal();
1245 signal?.Disconnect(hoverEventCallback);
1249 if (interceptTouchDataCallback != null)
1251 TouchDataSignal signal = this.InterceptTouchSignal();
1252 signal?.Disconnect(interceptTouchDataCallback);
1256 if (touchDataCallback != null)
1258 TouchDataSignal signal = this.TouchSignal();
1259 signal?.Disconnect(touchDataCallback);
1263 if (ResourcesLoadedCallback != null)
1265 ViewSignal signal = this.ResourcesLoadedSignal();
1266 signal?.Disconnect(ResourcesLoadedCallback);
1268 ResourcesLoadedCallback = null;
1271 if (keyCallback != null)
1273 ControlKeySignal signal = this.KeyEventSignal();
1274 signal?.Disconnect(keyCallback);
1278 if (keyInputFocusLostCallback != null)
1280 KeyInputFocusSignal signal = this.KeyInputFocusLostSignal();
1281 signal?.Disconnect(keyInputFocusLostCallback);
1285 if (keyInputFocusGainedCallback != null)
1287 KeyInputFocusSignal signal = this.KeyInputFocusGainedSignal();
1288 signal?.Disconnect(keyInputFocusGainedCallback);
1292 if (backgroundResourceLoadedCallback != null)
1294 ViewSignal signal = this.ResourcesLoadedSignal();
1295 signal?.Disconnect(backgroundResourceLoadedCallback);
1297 backgroundResourceLoadedCallback = null;
1300 if (onWindowSendEventCallback != null)
1302 ViewSignal signal = this.OnWindowSignal();
1303 signal?.Disconnect(onWindowSendEventCallback);
1305 onWindowSendEventCallback = null;
1308 // BaseHandle CPtr is used in Registry and there is danger of deletion if we keep using it here.
1309 // Restore current CPtr.
1310 SwigCPtr = currentCPtr;
1314 /// Apply initial style to the view.
1316 [EditorBrowsable(EditorBrowsableState.Never)]
1317 protected void InitializeStyle(ViewStyle style = null)
1319 if (style != null) ApplyStyle(style); // Use given style
1320 else UpdateStyle(); // Use style in the current theme
1323 private View ConvertIdToView(uint id)
1325 View view = GetParent()?.FindCurrentChildById(id);
1327 //If we can't find the parent's children, find in the top layer.
1330 Container parent = GetParent();
1331 while ((parent is View) && (parent != null))
1333 parent = parent.GetParent();
1334 if (parent is Layer)
1336 view = parent.FindCurrentChildById(id);
1345 private void OnScaleChanged(float x, float y, float z)
1347 Scale = new Vector3(x, y, z);
1350 private void OnBackgroundColorChanged(float r, float g, float b, float a)
1352 BackgroundColor = new Color(r, g, b, a);
1355 private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1357 Padding = new Extents(start, end, top, bottom);
1360 private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1362 Margin = new Extents(start, end, top, bottom);
1365 private void OnColorChanged(float r, float g, float b, float a)
1367 Color = new Color(r, g, b, a);
1370 private void OnAnchorPointChanged(float x, float y, float z)
1372 AnchorPoint = new Position(x, y, z);
1375 private void OnCellIndexChanged(float x, float y)
1377 CellIndex = new Vector2(x, y);
1380 private void OnFlexMarginChanged(float x, float y, float z, float w)
1382 FlexMargin = new Vector4(x, y, z, w);
1385 private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1387 PaddingEX = new Extents(start, end, top, bottom);
1390 private void OnSizeModeFactorChanged(float x, float y, float z)
1392 SizeModeFactor = new Vector3(x, y, z);
1395 private bool EmptyOnTouch(object target, TouchEventArgs args)
1400 private void UpdateStyle()
1403 if (string.IsNullOrEmpty(styleName)) newStyle = ThemeManager.GetStyleWithoutClone(GetType());
1404 else newStyle = ThemeManager.GetStyleWithoutClone(styleName);
1406 if (newStyle != null)
1408 ApplyStyle(newStyle);
1412 private ViewSelectorData EnsureSelectorData()
1414 if (themeData == null) themeData = new ThemeData();
1416 return themeData.selectorData ?? (themeData.selectorData = new ViewSelectorData());