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.Diagnostics;
22 using System.Runtime.CompilerServices;
23 using Tizen.NUI.Binding;
25 namespace Tizen.NUI.BaseComponents
28 /// View is the base class for all views.
30 /// <since_tizen> 3 </since_tizen>
31 public partial class View
33 private MergedStyle mergedStyle = null;
34 internal string styleName;
36 internal MergedStyle MergedStyle
40 if (null == mergedStyle)
42 mergedStyle = new MergedStyle(GetType(), this);
49 internal class ThemeData
52 private enum States : byte
55 ControlStatePropagation = 1 << 0,
56 ThemeChangeSensitive = 1 << 1,
57 ThemeApplied = 1 << 2, // It is true when the view has valid style name or the platform theme has a component style for this view type.
58 // That indicates the view can have different styles by theme.
59 // Hence if the current state has ThemeApplied and ThemeChangeSensitive, the view will change its style by theme changing.
60 ListeningThemeChangeEvent = 1 << 3,
63 private States states = ThemeManager.ApplicationThemeChangeSensitive ? States.ThemeChangeSensitive : States.None;
64 public ViewStyle viewStyle;
65 public ControlState controlStates = ControlState.Normal;
66 public ViewSelectorData selectorData;
68 public bool ControlStatePropagation
70 get => ((states & States.ControlStatePropagation) != 0);
71 set => SetOption(States.ControlStatePropagation, value);
74 public bool ThemeChangeSensitive
76 get => ((states & States.ThemeChangeSensitive) != 0);
77 set => SetOption(States.ThemeChangeSensitive, value);
80 public bool ThemeApplied
82 get => ((states & States.ThemeApplied) != 0);
83 set => SetOption(States.ThemeApplied, value);
86 public bool ListeningThemeChangeEvent
88 get => ((states & States.ListeningThemeChangeEvent) != 0);
89 set => SetOption(States.ListeningThemeChangeEvent, value);
92 private void SetOption(States option, bool value)
94 if (value) states |= option;
95 else states &= ~option;
100 /// The color mode of View.
101 /// This specifies whether the View uses its own color, or inherits its parent color.
102 /// The default is ColorMode.UseOwnMultiplyParentColor.
104 internal ColorMode ColorMode
112 return GetColorMode();
116 internal LayoutLength SuggestedMinimumWidth
120 float result = Interop.Actor.GetSuggestedMinimumWidth(SwigCPtr);
121 if (NDalicPINVOKE.SWIGPendingException.Pending)
122 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
123 return new LayoutLength(result);
127 internal LayoutLength SuggestedMinimumHeight
131 float result = Interop.Actor.GetSuggestedMinimumHeight(SwigCPtr);
132 if (NDalicPINVOKE.SWIGPendingException.Pending)
133 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
134 return new LayoutLength(result);
138 internal float WorldPositionX
142 float returnValue = 0.0f;
143 PropertyValue wordPositionX = GetProperty(View.Property.WorldPositionX);
144 wordPositionX?.Get(out returnValue);
145 wordPositionX?.Dispose();
150 internal float WorldPositionY
154 float returnValue = 0.0f;
155 PropertyValue wordPositionY = GetProperty(View.Property.WorldPositionY);
156 wordPositionY?.Get(out returnValue);
157 wordPositionY?.Dispose();
162 internal float WorldPositionZ
166 float returnValue = 0.0f;
167 PropertyValue wordPositionZ = GetProperty(View.Property.WorldPositionZ);
168 wordPositionZ?.Get(out returnValue);
169 wordPositionZ?.Dispose();
174 internal bool FocusState
178 return IsKeyboardFocusable();
182 SetKeyboardFocusable(value);
186 internal void SetLayout(LayoutItem layout)
188 Window.Instance.LayoutController.CreateProcessCallback();
189 this.layout = layout;
190 this.layout?.AttachToOwner(this);
191 this.layout?.RequestLayout();
194 internal void AttachTransitionsToChildren(LayoutTransition transition)
196 // Iterate children, adding the transition unless a transition
197 // for the same condition and property has already been
199 foreach (View view in Children)
201 LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions, transition.Condition, transition, false);
205 internal float ParentOriginX
209 float returnValue = 0.0f;
210 PropertyValue parentOriginX = GetProperty(View.Property.ParentOriginX);
211 parentOriginX?.Get(out returnValue);
212 parentOriginX?.Dispose();
217 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
218 SetProperty(View.Property.ParentOriginX, setValue);
220 NotifyPropertyChanged();
224 internal float ParentOriginY
228 float returnValue = 0.0f;
229 PropertyValue parentOriginY = GetProperty(View.Property.ParentOriginY);
230 parentOriginY?.Get(out returnValue);
231 parentOriginY?.Dispose();
236 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
237 SetProperty(View.Property.ParentOriginY, setValue);
239 NotifyPropertyChanged();
243 internal float ParentOriginZ
247 float returnValue = 0.0f;
248 PropertyValue parentOriginZ = GetProperty(View.Property.ParentOriginZ);
249 parentOriginZ?.Get(out returnValue);
250 parentOriginZ?.Dispose();
255 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
256 SetProperty(View.Property.ParentOriginZ, setValue);
258 NotifyPropertyChanged();
262 internal float PivotPointX
266 float returnValue = 0.0f;
267 PropertyValue anchorPointX = GetProperty(View.Property.AnchorPointX);
268 anchorPointX?.Get(out returnValue);
269 anchorPointX?.Dispose();
274 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
275 SetProperty(View.Property.AnchorPointX, setValue);
280 internal float PivotPointY
284 float returnValue = 0.0f;
285 PropertyValue anchorPointY = GetProperty(View.Property.AnchorPointY);
286 anchorPointY?.Get(out returnValue);
287 anchorPointY?.Dispose();
292 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
293 SetProperty(View.Property.AnchorPointY, setValue);
298 internal float PivotPointZ
302 float returnValue = 0.0f;
303 PropertyValue anchorPointZ = GetProperty(View.Property.AnchorPointZ);
304 anchorPointZ?.Get(out returnValue);
305 anchorPointZ?.Dispose();
310 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
311 SetProperty(View.Property.AnchorPointZ, setValue);
316 internal Matrix WorldMatrix
320 Matrix returnValue = new Matrix();
321 PropertyValue wordMatrix = GetProperty(View.Property.WorldMatrix);
322 wordMatrix?.Get(returnValue);
323 wordMatrix?.Dispose();
329 /// Indicates that this View should listen Touch event to handle its ControlState.
331 private bool enableControlState = false;
333 private int LeftFocusableViewId
338 PropertyValue leftFocusableViewId = GetProperty(View.Property.LeftFocusableViewId);
339 leftFocusableViewId?.Get(out returnValue);
340 leftFocusableViewId?.Dispose();
345 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
346 SetProperty(View.Property.LeftFocusableViewId, setValue);
351 private int RightFocusableViewId
356 PropertyValue rightFocusableViewId = GetProperty(View.Property.RightFocusableViewId);
357 rightFocusableViewId?.Get(out returnValue);
358 rightFocusableViewId?.Dispose();
363 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
364 SetProperty(View.Property.RightFocusableViewId, setValue);
369 private int UpFocusableViewId
374 PropertyValue upFocusableViewId = GetProperty(View.Property.UpFocusableViewId);
375 upFocusableViewId?.Get(out returnValue);
376 upFocusableViewId?.Dispose();
381 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
382 SetProperty(View.Property.UpFocusableViewId, setValue);
387 private int DownFocusableViewId
392 PropertyValue downFocusableViewId = GetProperty(View.Property.DownFocusableViewId);
393 downFocusableViewId?.Get(out returnValue);
394 downFocusableViewId?.Dispose();
399 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
400 SetProperty(View.Property.DownFocusableViewId, setValue);
405 internal void Raise()
407 var parentChildren = GetParent()?.Children;
409 if (parentChildren != null)
411 int currentIndex = parentChildren.IndexOf(this);
413 // If the view is not already the last item in the list.
414 if (currentIndex >= 0 && currentIndex < parentChildren.Count - 1)
416 View temp = parentChildren[currentIndex + 1];
417 parentChildren[currentIndex + 1] = this;
418 parentChildren[currentIndex] = temp;
420 Interop.NDalic.Raise(SwigCPtr);
421 if (NDalicPINVOKE.SWIGPendingException.Pending)
422 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
427 internal void Lower()
429 var parentChildren = GetParent()?.Children;
431 if (parentChildren != null)
433 int currentIndex = parentChildren.IndexOf(this);
435 // If the view is not already the first item in the list.
436 if (currentIndex > 0 && currentIndex < parentChildren.Count)
438 View temp = parentChildren[currentIndex - 1];
439 parentChildren[currentIndex - 1] = this;
440 parentChildren[currentIndex] = temp;
442 Interop.NDalic.Lower(SwigCPtr);
443 if (NDalicPINVOKE.SWIGPendingException.Pending)
444 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
450 /// Raises the view to above the target view.
452 /// <remarks>The sibling order of views within the parent will be updated automatically.
453 /// Views on the level above the target view will still be shown above this view.
454 /// Raising this view above views with the same sibling order as each other will raise this view above them.
455 /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion.
457 /// <param name="target">Will be raised above this view.</param>
458 internal void RaiseAbove(View target)
460 var parentChildren = GetParent()?.Children;
462 if (parentChildren != null)
464 int currentIndex = parentChildren.IndexOf(this);
465 int targetIndex = parentChildren.IndexOf(target);
467 if (currentIndex < 0 || targetIndex < 0 ||
468 currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
470 NUILog.Error("index should be bigger than 0 and less than children of layer count");
473 // If the currentIndex is less than the target index and the target has the same parent.
474 if (currentIndex < targetIndex)
476 parentChildren.Remove(this);
477 parentChildren.Insert(targetIndex, this);
479 Interop.NDalic.RaiseAbove(SwigCPtr, View.getCPtr(target));
480 if (NDalicPINVOKE.SWIGPendingException.Pending)
481 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
488 /// Lowers the view to below the target view.
490 /// <remarks>The sibling order of views within the parent will be updated automatically.
491 /// Lowering this view below views with the same sibling order as each other will lower this view above them.
492 /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion.
494 /// <param name="target">Will be lowered below this view.</param>
495 internal void LowerBelow(View target)
497 var parentChildren = GetParent()?.Children;
499 if (parentChildren != null)
501 int currentIndex = parentChildren.IndexOf(this);
502 int targetIndex = parentChildren.IndexOf(target);
503 if (currentIndex < 0 || targetIndex < 0 ||
504 currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
506 NUILog.Error("index should be bigger than 0 and less than children of layer count");
510 // If the currentIndex is not already the 0th index and the target has the same parent.
511 if ((currentIndex != 0) && (targetIndex != -1) &&
512 (currentIndex > targetIndex))
514 parentChildren.Remove(this);
515 parentChildren.Insert(targetIndex, this);
517 Interop.NDalic.LowerBelow(SwigCPtr, View.getCPtr(target));
518 if (NDalicPINVOKE.SWIGPendingException.Pending)
519 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
525 internal string GetName()
527 string ret = Interop.Actor.GetName(SwigCPtr);
528 if (NDalicPINVOKE.SWIGPendingException.Pending)
529 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
533 internal void SetName(string name)
535 Interop.Actor.SetName(SwigCPtr, name);
536 if (NDalicPINVOKE.SWIGPendingException.Pending)
537 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
540 internal uint GetId()
542 uint ret = Interop.Actor.GetId(SwigCPtr);
543 if (NDalicPINVOKE.SWIGPendingException.Pending)
544 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
548 internal bool IsRoot()
550 bool ret = Interop.ActorInternal.IsRoot(SwigCPtr);
551 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
555 internal bool OnWindow()
557 bool ret = Interop.Actor.OnStage(SwigCPtr);
558 if (NDalicPINVOKE.SWIGPendingException.Pending)
559 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
563 internal View FindChildById(uint id)
565 //to fix memory leak issue, match the handle count with native side.
566 IntPtr cPtr = Interop.Actor.FindChildById(SwigCPtr, id);
567 View ret = this.GetInstanceSafely<View>(cPtr);
568 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
572 internal override View FindCurrentChildById(uint id)
574 return FindChildById(id);
577 internal void SetParentOrigin(Vector3 origin)
579 Interop.ActorInternal.SetParentOrigin(SwigCPtr, Vector3.getCPtr(origin));
580 if (NDalicPINVOKE.SWIGPendingException.Pending)
581 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
584 internal Vector3 GetCurrentParentOrigin()
586 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentParentOrigin(SwigCPtr), true);
587 if (NDalicPINVOKE.SWIGPendingException.Pending)
588 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
592 internal void SetAnchorPoint(Vector3 anchorPoint)
594 Interop.Actor.SetAnchorPoint(SwigCPtr, Vector3.getCPtr(anchorPoint));
595 if (NDalicPINVOKE.SWIGPendingException.Pending)
596 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
599 internal Vector3 GetCurrentAnchorPoint()
601 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentAnchorPoint(SwigCPtr), true);
602 if (NDalicPINVOKE.SWIGPendingException.Pending)
603 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
607 internal void SetSize(float width, float height)
609 Interop.ActorInternal.SetSize(SwigCPtr, width, height);
610 if (NDalicPINVOKE.SWIGPendingException.Pending)
611 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
614 internal void SetSize(float width, float height, float depth)
616 Interop.ActorInternal.SetSize(SwigCPtr, width, height, depth);
617 if (NDalicPINVOKE.SWIGPendingException.Pending)
618 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
621 internal void SetSize(Vector2 size)
623 Interop.ActorInternal.SetSizeVector2(SwigCPtr, Vector2.getCPtr(size));
624 if (NDalicPINVOKE.SWIGPendingException.Pending)
625 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
628 internal void SetSize(Vector3 size)
630 Interop.ActorInternal.SetSizeVector3(SwigCPtr, Vector3.getCPtr(size));
631 if (NDalicPINVOKE.SWIGPendingException.Pending)
632 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
635 internal Vector3 GetTargetSize()
637 Vector3 ret = new Vector3(Interop.ActorInternal.GetTargetSize(SwigCPtr), true);
638 if (NDalicPINVOKE.SWIGPendingException.Pending)
639 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
643 internal Size2D GetCurrentSize()
645 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
646 if (NDalicPINVOKE.SWIGPendingException.Pending)
647 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
648 Size2D size = new Size2D((int)ret.Width, (int)ret.Height);
653 internal Size2D GetCurrentSizeFloat()
655 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
656 if (NDalicPINVOKE.SWIGPendingException.Pending)
657 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
661 internal Vector3 GetNaturalSize()
663 Vector3 ret = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
664 if (NDalicPINVOKE.SWIGPendingException.Pending)
665 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
669 internal void SetPosition(float x, float y)
671 Interop.ActorInternal.SetPosition(SwigCPtr, x, y);
672 if (NDalicPINVOKE.SWIGPendingException.Pending)
673 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
676 internal void SetPosition(float x, float y, float z)
678 Interop.ActorInternal.SetPosition(SwigCPtr, x, y, z);
679 if (NDalicPINVOKE.SWIGPendingException.Pending)
680 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
683 internal void SetPosition(Vector3 position)
685 Interop.ActorInternal.SetPosition(SwigCPtr, Vector3.getCPtr(position));
686 if (NDalicPINVOKE.SWIGPendingException.Pending)
687 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
690 internal void SetX(float x)
692 Interop.ActorInternal.SetX(SwigCPtr, x);
693 if (NDalicPINVOKE.SWIGPendingException.Pending)
694 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
697 internal void SetY(float y)
699 Interop.ActorInternal.SetY(SwigCPtr, y);
700 if (NDalicPINVOKE.SWIGPendingException.Pending)
701 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
704 internal void SetZ(float z)
706 Interop.ActorInternal.SetZ(SwigCPtr, z);
707 if (NDalicPINVOKE.SWIGPendingException.Pending)
708 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
711 internal void TranslateBy(Vector3 distance)
713 Interop.ActorInternal.TranslateBy(SwigCPtr, Vector3.getCPtr(distance));
714 if (NDalicPINVOKE.SWIGPendingException.Pending)
715 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
718 internal Position GetCurrentPosition()
720 Position ret = new Position(Interop.Actor.GetCurrentPosition(SwigCPtr), true);
721 if (NDalicPINVOKE.SWIGPendingException.Pending)
722 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
726 internal Vector3 GetCurrentWorldPosition()
728 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldPosition(SwigCPtr), true);
729 if (NDalicPINVOKE.SWIGPendingException.Pending)
730 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
734 internal void SetInheritPosition(bool inherit)
736 Interop.ActorInternal.SetInheritPosition(SwigCPtr, inherit);
737 if (NDalicPINVOKE.SWIGPendingException.Pending)
738 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
741 internal bool IsPositionInherited()
743 bool ret = Interop.ActorInternal.IsPositionInherited(SwigCPtr);
744 if (NDalicPINVOKE.SWIGPendingException.Pending)
745 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
749 internal void SetOrientation(Degree angle, Vector3 axis)
751 Interop.ActorInternal.SetOrientationDegree(SwigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
752 if (NDalicPINVOKE.SWIGPendingException.Pending)
753 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
756 internal void SetOrientation(Radian angle, Vector3 axis)
758 Interop.ActorInternal.SetOrientationRadian(SwigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
759 if (NDalicPINVOKE.SWIGPendingException.Pending)
760 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
763 internal void SetOrientation(Rotation orientation)
765 Interop.ActorInternal.SetOrientationQuaternion(SwigCPtr, Rotation.getCPtr(orientation));
766 if (NDalicPINVOKE.SWIGPendingException.Pending)
767 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
770 internal Rotation GetCurrentOrientation()
772 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentOrientation(SwigCPtr), true);
773 if (NDalicPINVOKE.SWIGPendingException.Pending)
774 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
778 internal void SetInheritOrientation(bool inherit)
780 Interop.ActorInternal.SetInheritOrientation(SwigCPtr, inherit);
781 if (NDalicPINVOKE.SWIGPendingException.Pending)
782 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
785 internal bool IsOrientationInherited()
787 bool ret = Interop.ActorInternal.IsOrientationInherited(SwigCPtr);
788 if (NDalicPINVOKE.SWIGPendingException.Pending)
789 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
793 internal Rotation GetCurrentWorldOrientation()
795 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentWorldOrientation(SwigCPtr), true);
796 if (NDalicPINVOKE.SWIGPendingException.Pending)
797 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
801 internal void SetScale(float scale)
803 Interop.ActorInternal.SetScale(SwigCPtr, scale);
804 if (NDalicPINVOKE.SWIGPendingException.Pending)
805 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
808 internal void SetScale(float scaleX, float scaleY, float scaleZ)
810 Interop.ActorInternal.SetScale(SwigCPtr, scaleX, scaleY, scaleZ);
811 if (NDalicPINVOKE.SWIGPendingException.Pending)
812 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
815 internal void SetScale(Vector3 scale)
817 Interop.ActorInternal.SetScale(SwigCPtr, Vector3.getCPtr(scale));
818 if (NDalicPINVOKE.SWIGPendingException.Pending)
819 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
822 internal Vector3 GetCurrentScale()
824 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentScale(SwigCPtr), true);
825 if (NDalicPINVOKE.SWIGPendingException.Pending)
826 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
830 internal Vector3 GetCurrentWorldScale()
832 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldScale(SwigCPtr), true);
833 if (NDalicPINVOKE.SWIGPendingException.Pending)
834 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
838 internal void SetInheritScale(bool inherit)
840 Interop.ActorInternal.SetInheritScale(SwigCPtr, inherit);
841 if (NDalicPINVOKE.SWIGPendingException.Pending)
842 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
845 internal bool IsScaleInherited()
847 bool ret = Interop.ActorInternal.IsScaleInherited(SwigCPtr);
848 if (NDalicPINVOKE.SWIGPendingException.Pending)
849 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
853 internal Matrix GetCurrentWorldMatrix()
855 Matrix ret = new Matrix(Interop.ActorInternal.GetCurrentWorldMatrix(SwigCPtr), true);
856 if (NDalicPINVOKE.SWIGPendingException.Pending)
857 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
861 internal void SetVisible(bool visible)
863 Interop.Actor.SetVisible(SwigCPtr, visible);
864 if (NDalicPINVOKE.SWIGPendingException.Pending)
865 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
868 internal bool IsVisible()
870 bool ret = Interop.ActorInternal.IsVisible(SwigCPtr);
871 if (NDalicPINVOKE.SWIGPendingException.Pending)
872 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
876 internal void SetOpacity(float opacity)
878 Interop.ActorInternal.SetOpacity(SwigCPtr, opacity);
879 if (NDalicPINVOKE.SWIGPendingException.Pending)
880 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
883 internal float GetCurrentOpacity()
885 float ret = Interop.ActorInternal.GetCurrentOpacity(SwigCPtr);
886 if (NDalicPINVOKE.SWIGPendingException.Pending)
887 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
891 internal Vector4 GetCurrentColor()
893 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentColor(SwigCPtr), true);
894 if (NDalicPINVOKE.SWIGPendingException.Pending)
895 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
898 internal ColorMode GetColorMode()
900 ColorMode ret = (ColorMode)Interop.ActorInternal.GetColorMode(SwigCPtr);
901 if (NDalicPINVOKE.SWIGPendingException.Pending)
902 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
906 internal Vector4 GetCurrentWorldColor()
908 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentWorldColor(SwigCPtr), true);
909 if (NDalicPINVOKE.SWIGPendingException.Pending)
910 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
914 internal void SetDrawMode(DrawModeType drawMode)
916 Interop.ActorInternal.SetDrawMode(SwigCPtr, (int)drawMode);
917 if (NDalicPINVOKE.SWIGPendingException.Pending)
918 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
921 internal DrawModeType GetDrawMode()
923 DrawModeType ret = (DrawModeType)Interop.ActorInternal.GetDrawMode(SwigCPtr);
924 if (NDalicPINVOKE.SWIGPendingException.Pending)
925 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
929 internal void SetKeyboardFocusable(bool focusable)
931 Interop.ActorInternal.SetKeyboardFocusable(SwigCPtr, focusable);
932 if (NDalicPINVOKE.SWIGPendingException.Pending)
933 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
936 internal bool IsKeyboardFocusable()
938 bool ret = Interop.ActorInternal.IsKeyboardFocusable(SwigCPtr);
939 if (NDalicPINVOKE.SWIGPendingException.Pending)
940 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
944 internal void SetKeyboardFocusableChildren(bool focusable)
946 Interop.ActorInternal.SetKeyboardFocusableChildren(SwigCPtr, focusable);
947 if (NDalicPINVOKE.SWIGPendingException.Pending)
948 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
951 internal bool AreChildrenKeyBoardFocusable()
953 bool ret = Interop.ActorInternal.AreChildrenKeyBoardFocusable(SwigCPtr);
954 if (NDalicPINVOKE.SWIGPendingException.Pending)
955 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
959 internal void SetFocusableInTouch(bool enabled)
961 Interop.ActorInternal.SetFocusableInTouch(SwigCPtr, enabled);
962 if (NDalicPINVOKE.SWIGPendingException.Pending)
963 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
966 internal bool IsFocusableInTouch()
968 bool ret = Interop.ActorInternal.IsFocusableInTouch(SwigCPtr);
969 if (NDalicPINVOKE.SWIGPendingException.Pending)
970 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
974 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
976 Interop.Actor.SetResizePolicy(SwigCPtr, (int)policy, (int)dimension);
977 if (NDalicPINVOKE.SWIGPendingException.Pending)
978 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
981 internal ResizePolicyType GetResizePolicy(DimensionType dimension)
983 ResizePolicyType ret = (ResizePolicyType)Interop.Actor.GetResizePolicy(SwigCPtr, (int)dimension);
984 if (NDalicPINVOKE.SWIGPendingException.Pending)
985 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
989 internal Vector3 GetSizeModeFactor()
991 Vector3 ret = new Vector3(Interop.Actor.GetSizeModeFactor(SwigCPtr), true);
992 if (NDalicPINVOKE.SWIGPendingException.Pending)
993 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
997 internal void SetMinimumSize(Vector2 size)
999 Interop.ActorInternal.SetMinimumSize(SwigCPtr, Vector2.getCPtr(size));
1000 if (NDalicPINVOKE.SWIGPendingException.Pending)
1001 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1004 internal Vector2 GetMinimumSize()
1006 Vector2 ret = new Vector2(Interop.ActorInternal.GetMinimumSize(SwigCPtr), true);
1007 if (NDalicPINVOKE.SWIGPendingException.Pending)
1008 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1012 internal void SetMaximumSize(Vector2 size)
1014 Interop.ActorInternal.SetMaximumSize(SwigCPtr, Vector2.getCPtr(size));
1015 if (NDalicPINVOKE.SWIGPendingException.Pending)
1016 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1019 internal Vector2 GetMaximumSize()
1021 Vector2 ret = new Vector2(Interop.ActorInternal.GetMaximumSize(SwigCPtr), true);
1022 if (NDalicPINVOKE.SWIGPendingException.Pending)
1023 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1027 internal int GetHierarchyDepth()
1029 int ret = Interop.Actor.GetHierarchyDepth(SwigCPtr);
1030 if (NDalicPINVOKE.SWIGPendingException.Pending)
1031 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1035 internal uint GetRendererCount()
1037 uint ret = Interop.Actor.GetRendererCount(SwigCPtr);
1038 if (NDalicPINVOKE.SWIGPendingException.Pending)
1039 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1043 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
1045 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1048 internal bool IsTopLevelView()
1050 if (GetParent() is Layer)
1057 internal void SetKeyInputFocus()
1059 Interop.ViewInternal.SetKeyInputFocus(SwigCPtr);
1060 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1063 internal void ClearKeyInputFocus()
1065 Interop.ViewInternal.ClearKeyInputFocus(SwigCPtr);
1066 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1069 internal PinchGestureDetector GetPinchGestureDetector()
1071 PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.GetPinchGestureDetector(SwigCPtr), true);
1072 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1076 internal PanGestureDetector GetPanGestureDetector()
1078 PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.GetPanGestureDetector(SwigCPtr), true);
1079 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1083 internal TapGestureDetector GetTapGestureDetector()
1085 TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.GetTapGestureDetector(SwigCPtr), true);
1086 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1090 internal LongPressGestureDetector GetLongPressGestureDetector()
1092 LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.GetLongPressGestureDetector(SwigCPtr), true);
1093 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1097 internal IntPtr GetPtrfromView()
1099 return (IntPtr)SwigCPtr;
1102 internal void RemoveChild(View child)
1104 // Do actual child removal
1105 Interop.Actor.Remove(SwigCPtr, View.getCPtr(child));
1106 if (NDalicPINVOKE.SWIGPendingException.Pending)
1107 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1109 Children.Remove(child);
1110 child.InternalParent = null;
1112 RemoveChildBindableObject(child);
1114 if (ChildRemoved != null)
1116 ChildRemovedEventArgs e = new ChildRemovedEventArgs
1120 ChildRemoved(this, e);
1125 /// Removes the layout from this View.
1127 internal void ResetLayout()
1132 internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1134 return (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1137 /// TODO open as a protected level
1138 internal virtual void ApplyCornerRadius()
1140 if (backgroundExtraData == null) return;
1142 var cornerRadius = backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius);
1144 // Apply to the background visual
1145 PropertyMap backgroundMap = new PropertyMap();
1146 PropertyValue background = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.BACKGROUND);
1148 if (background.Get(backgroundMap) && !backgroundMap.Empty())
1150 backgroundMap[Visual.Property.CornerRadius] = cornerRadius;
1151 backgroundMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1152 var temp = new PropertyValue(backgroundMap);
1153 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.BACKGROUND, temp);
1156 backgroundMap.Dispose();
1157 background.Dispose();
1159 // Apply to the shadow visual
1160 PropertyMap shadowMap = new PropertyMap();
1161 PropertyValue shadow = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.SHADOW);
1162 if (shadow.Get(shadowMap) && !shadowMap.Empty())
1164 shadowMap[Visual.Property.CornerRadius] = cornerRadius;
1165 shadowMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1166 var temp = new PropertyValue(shadowMap);
1167 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.SHADOW, temp);
1170 shadowMap.Dispose();
1172 cornerRadius.Dispose();
1175 /// TODO open as a protected level
1176 internal virtual void ApplyBorderline()
1178 if (backgroundExtraData == null) return;
1180 var borderlineColor = backgroundExtraData.BorderlineColor == null ? new PropertyValue(Color.Black) : new PropertyValue(backgroundExtraData.BorderlineColor);
1182 // Apply to the background visual
1183 PropertyMap backgroundMap = new PropertyMap();
1184 PropertyValue background = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.BACKGROUND);
1185 if (background.Get(backgroundMap) && !backgroundMap.Empty())
1187 backgroundMap[Visual.Property.BorderlineWidth] = new PropertyValue(backgroundExtraData.BorderlineWidth);
1188 backgroundMap[Visual.Property.BorderlineColor] = borderlineColor;
1189 backgroundMap[Visual.Property.BorderlineOffset] = new PropertyValue(backgroundExtraData.BorderlineOffset);
1190 var temp = new PropertyValue(backgroundMap);
1191 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.BACKGROUND, temp);
1194 backgroundMap.Dispose();
1195 background.Dispose();
1196 borderlineColor.Dispose();
1200 /// Get selector value from the triggerable selector or related property.
1202 internal Selector<T> GetSelector<T>(TriggerableSelector<T> triggerableSelector, NUI.Binding.BindableProperty relatedProperty)
1204 var selector = triggerableSelector?.Get();
1205 if (selector != null)
1210 var value = (T)GetValue(relatedProperty);
1211 return value == null ? null : new Selector<T>(value);
1214 internal void SetThemeApplied()
1216 if (themeData == null) themeData = new ThemeData();
1217 themeData.ThemeApplied = true;
1219 if (ThemeChangeSensitive && !themeData.ListeningThemeChangeEvent)
1221 themeData.ListeningThemeChangeEvent = true;
1222 ThemeManager.ThemeChangedInternal.Add(OnThemeChanged);
1227 /// you can override it to clean-up your own resources.
1229 /// <param name="type">DisposeTypes</param>
1230 /// <since_tizen> 3 </since_tizen>
1231 protected override void Dispose(DisposeTypes type)
1238 //_mergedStyle = null;
1240 if (type == DisposeTypes.Explicit)
1243 //Release your own managed resources here.
1244 //You should release all of your own disposable objects here.
1245 if (themeData != null)
1247 themeData.selectorData?.Reset(this);
1248 if (themeData.ListeningThemeChangeEvent)
1250 ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
1253 if(widthConstraint != null)
1255 widthConstraint.Remove();
1256 widthConstraint.Dispose();
1258 if(heightConstraint != null)
1260 heightConstraint.Remove();
1261 heightConstraint.Dispose();
1265 //Release your own unmanaged resources here.
1266 //You should not access any managed member here except static instance.
1267 //because the execution order of Finalizes is non-deterministic.
1269 // equivalent to "if (this != null)". more clear to understand.
1272 DisConnectFromSignals();
1274 foreach (View view in Children)
1276 view.InternalParent = null;
1284 /// This will not be public opened.
1285 [EditorBrowsable(EditorBrowsableState.Never)]
1286 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1288 Interop.View.DeleteView(swigCPtr);
1292 /// The touch event handler for ControlState.
1293 /// Please change ControlState value by touch state if needed.
1295 /// <exception cref="ArgumentNullException"> Thrown when touch is null. </exception>
1296 [EditorBrowsable(EditorBrowsableState.Never)]
1297 protected virtual bool HandleControlStateOnTouch(Touch touch)
1301 throw new global::System.ArgumentNullException(nameof(touch));
1304 switch (touch.GetState(0))
1306 case PointStateType.Down:
1307 ControlState += ControlState.Pressed;
1309 case PointStateType.Interrupted:
1310 case PointStateType.Up:
1311 if (ControlState.Contains(ControlState.Pressed))
1313 ControlState -= ControlState.Pressed;
1322 private void DisConnectFromSignals()
1324 // Save current CPtr.
1325 global::System.Runtime.InteropServices.HandleRef currentCPtr = SwigCPtr;
1327 // Use BaseHandle CPtr as current might have been deleted already in derived classes.
1328 SwigCPtr = GetBaseHandleCPtrHandleRef;
1330 if (onRelayoutEventCallback != null)
1332 ViewSignal signal = this.OnRelayoutSignal();
1333 signal?.Disconnect(onRelayoutEventCallback);
1335 onRelayoutEventCallback = null;
1338 if (offWindowEventCallback != null)
1340 ViewSignal signal = this.OffWindowSignal();
1341 signal?.Disconnect(offWindowEventCallback);
1343 offWindowEventCallback = null;
1346 if (onWindowEventCallback != null)
1348 ViewSignal signal = this.OnWindowSignal();
1349 signal?.Disconnect(onWindowEventCallback);
1351 onWindowEventCallback = null;
1354 if (wheelEventCallback != null)
1356 WheelSignal signal = this.WheelEventSignal();
1357 signal?.Disconnect(wheelEventCallback);
1361 if (WindowWheelEventHandler != null)
1363 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
1366 if (hoverEventCallback != null)
1368 HoverSignal signal = this.HoveredSignal();
1369 signal?.Disconnect(hoverEventCallback);
1373 if (interceptTouchDataCallback != null)
1375 TouchDataSignal signal = this.InterceptTouchSignal();
1376 signal?.Disconnect(interceptTouchDataCallback);
1380 if (touchDataCallback != null)
1382 TouchDataSignal signal = this.TouchSignal();
1383 signal?.Disconnect(touchDataCallback);
1387 if (ResourcesLoadedCallback != null)
1389 ViewSignal signal = this.ResourcesLoadedSignal();
1390 signal?.Disconnect(ResourcesLoadedCallback);
1392 ResourcesLoadedCallback = null;
1395 if (keyCallback != null)
1397 ControlKeySignal signal = this.KeyEventSignal();
1398 signal?.Disconnect(keyCallback);
1402 if (keyInputFocusLostCallback != null)
1404 KeyInputFocusSignal signal = this.KeyInputFocusLostSignal();
1405 signal?.Disconnect(keyInputFocusLostCallback);
1409 if (keyInputFocusGainedCallback != null)
1411 KeyInputFocusSignal signal = this.KeyInputFocusGainedSignal();
1412 signal?.Disconnect(keyInputFocusGainedCallback);
1416 if (backgroundResourceLoadedCallback != null)
1418 ViewSignal signal = this.ResourcesLoadedSignal();
1419 signal?.Disconnect(backgroundResourceLoadedCallback);
1421 backgroundResourceLoadedCallback = null;
1424 if (onWindowSendEventCallback != null)
1426 ViewSignal signal = this.OnWindowSignal();
1427 signal?.Disconnect(onWindowSendEventCallback);
1429 onWindowSendEventCallback = null;
1432 // BaseHandle CPtr is used in Registry and there is danger of deletion if we keep using it here.
1433 // Restore current CPtr.
1434 SwigCPtr = currentCPtr;
1438 /// Apply initial style to the view.
1440 [EditorBrowsable(EditorBrowsableState.Never)]
1441 protected virtual void InitializeStyle(ViewStyle style = null)
1443 var initialStyle = ThemeManager.GetInitialStyleWithoutClone(GetType());
1446 ApplyStyle(initialStyle);
1450 var refinedStyle = style;
1451 if (style.IncludeDefaultStyle)
1453 refinedStyle = initialStyle?.Merge(style);
1455 ApplyStyle(refinedStyle);
1458 // Listen theme change event if needs.
1459 if (ThemeManager.PlatformThemeEnabled && initialStyle != null)
1465 private View ConvertIdToView(uint id)
1467 View view = GetParent()?.FindCurrentChildById(id);
1469 //If we can't find the parent's children, find in the top layer.
1472 Container parent = GetParent();
1473 while ((parent is View) && (parent != null))
1475 parent = parent.GetParent();
1476 if (parent is Layer)
1478 view = parent.FindCurrentChildById(id);
1487 private void OnScaleChanged(float x, float y, float z)
1489 Scale = new Vector3(x, y, z);
1492 private void OnBackgroundColorChanged(float r, float g, float b, float a)
1494 BackgroundColor = new Color(r, g, b, a);
1497 private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1499 Padding = new Extents(start, end, top, bottom);
1502 private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1504 Margin = new Extents(start, end, top, bottom);
1507 private void OnColorChanged(float r, float g, float b, float a)
1509 Color = new Color(r, g, b, a);
1512 private void OnAnchorPointChanged(float x, float y, float z)
1514 AnchorPoint = new Position(x, y, z);
1517 private void OnCellIndexChanged(float x, float y)
1519 CellIndex = new Vector2(x, y);
1522 private void OnFlexMarginChanged(float x, float y, float z, float w)
1524 FlexMargin = new Vector4(x, y, z, w);
1527 private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1529 PaddingEX = new Extents(start, end, top, bottom);
1532 private void OnSizeModeFactorChanged(float x, float y, float z)
1534 SizeModeFactor = new Vector3(x, y, z);
1537 private bool EmptyOnTouch(object target, TouchEventArgs args)
1542 private ViewSelectorData EnsureSelectorData()
1544 if (themeData == null) themeData = new ThemeData();
1546 return themeData.selectorData ?? (themeData.selectorData = new ViewSelectorData());