2 * Copyright(c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.ComponentModel;
20 using global::System.Diagnostics;
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 internal enum BackgroundExtraDataUpdatedFlag : byte
36 BackgroundCornerRadius = 1 << 0,
37 BackgroundBorderline = 1 << 1,
38 ShadowCornerRadius = 1 << 2,
39 ContentsCornerRadius = 1 << 3, /// Subclass cases.
40 ContentsBorderline = 1 << 4, /// Subclass cases.
42 Background = BackgroundCornerRadius | BackgroundBorderline,
43 Shadow = ShadowCornerRadius,
45 CornerRadius = BackgroundCornerRadius | ShadowCornerRadius | ContentsCornerRadius,
46 Borderline = BackgroundBorderline | ContentsBorderline,
49 All = Background | Shadow,
52 internal BackgroundExtraDataUpdatedFlag backgroundExtraDataUpdatedFlag = BackgroundExtraDataUpdatedFlag.None;
54 private bool backgroundExtraDataUpdateProcessAttachedFlag = false;
56 internal virtual LayoutItem CreateDefaultLayout()
58 return new AbsoluteLayout();
61 internal class ThemeData
64 private enum States : byte
67 ControlStatePropagation = 1 << 0,
68 ThemeChangeSensitive = 1 << 1,
69 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.
70 // That indicates the view can have different styles by theme.
71 // Hence if the current state has ThemeApplied and ThemeChangeSensitive, the view will change its style by theme changing.
72 ListeningThemeChangeEvent = 1 << 3,
75 private States states = ThemeManager.ApplicationThemeChangeSensitive ? States.ThemeChangeSensitive : States.None;
76 public ViewStyle viewStyle;
77 public ControlState controlStates = ControlState.Normal;
78 public ViewSelectorData selectorData;
80 public bool ControlStatePropagation
82 get => ((states & States.ControlStatePropagation) != 0);
83 set => SetOption(States.ControlStatePropagation, value);
86 public bool ThemeChangeSensitive
88 get => ((states & States.ThemeChangeSensitive) != 0);
89 set => SetOption(States.ThemeChangeSensitive, value);
92 public bool ThemeApplied
94 get => ((states & States.ThemeApplied) != 0);
95 set => SetOption(States.ThemeApplied, value);
98 public bool ListeningThemeChangeEvent
100 get => ((states & States.ListeningThemeChangeEvent) != 0);
101 set => SetOption(States.ListeningThemeChangeEvent, value);
104 private void SetOption(States option, bool value)
106 if (value) states |= option;
107 else states &= ~option;
112 /// The color mode of View.
113 /// This specifies whether the View uses its own color, or inherits its parent color.
114 /// The default is ColorMode.UseOwnMultiplyParentColor.
116 internal ColorMode ColorMode
124 return GetColorMode();
128 internal LayoutLength SuggestedMinimumWidth
132 float result = Interop.Actor.GetSuggestedMinimumWidth(SwigCPtr);
133 if (NDalicPINVOKE.SWIGPendingException.Pending)
134 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135 return new LayoutLength(result);
139 internal LayoutLength SuggestedMinimumHeight
143 float result = Interop.Actor.GetSuggestedMinimumHeight(SwigCPtr);
144 if (NDalicPINVOKE.SWIGPendingException.Pending)
145 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
146 return new LayoutLength(result);
150 internal float WorldPositionX
155 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.WorldPositionX);
159 internal float WorldPositionY
164 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.WorldPositionY);
168 internal float WorldPositionZ
173 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.WorldPositionZ);
177 internal bool FocusState
181 return IsKeyboardFocusable();
185 SetKeyboardFocusable(value);
189 internal void SetLayout(LayoutItem layout)
193 this.layout = layout;
194 this.layout?.AttachToOwner(this);
195 this.layout?.RequestLayout();
198 internal void AttachTransitionsToChildren(LayoutTransition transition)
200 // Iterate children, adding the transition unless a transition
201 // for the same condition and property has already been
203 foreach (View view in Children)
205 LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions, transition.Condition, transition, false);
209 internal float ParentOriginX
214 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.ParentOriginX);
219 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.WorldPositionX, value);
220 NotifyPropertyChanged();
224 internal float ParentOriginY
229 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.ParentOriginY);
234 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.ParentOriginY, value);
235 NotifyPropertyChanged();
239 internal float ParentOriginZ
244 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.ParentOriginZ);
249 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.ParentOriginZ, value);
250 NotifyPropertyChanged();
254 internal float PivotPointX
259 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.AnchorPointX);
264 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.AnchorPointX, value);
268 internal float PivotPointY
273 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.AnchorPointY);
278 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.AnchorPointY, value);
282 internal float PivotPointZ
287 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.AnchorPointZ);
292 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.AnchorPointZ, value);
296 internal Matrix WorldMatrix
300 Matrix returnValue = new Matrix();
301 PropertyValue wordMatrix = GetProperty(View.Property.WorldMatrix);
302 wordMatrix?.Get(returnValue);
303 wordMatrix?.Dispose();
309 /// The number of layouts including view's layout and children's layouts.
310 /// This can be used to set/unset Process callback to calculate Layout.
312 internal int LayoutCount
321 if (layoutCount == value) return;
323 if (value < 0) throw new global::System.ArgumentOutOfRangeException(nameof(LayoutCount), "LayoutCount(" + LayoutCount + ") should not be less than zero");
325 int diff = value - layoutCount;
328 if (InternalParent != null)
330 var parentView = InternalParent as View;
331 if (parentView != null)
333 parentView.LayoutCount += diff;
337 var parentLayer = InternalParent as Layer;
338 if (parentLayer != null)
340 parentLayer.LayoutCount += diff;
348 /// Indicates that this View should listen Touch event to handle its ControlState.
350 private bool enableControlState = false;
352 private int LeftFocusableViewId
357 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.LeftFocusableViewId);
362 Object.InternalSetPropertyInt(SwigCPtr, View.Property.LeftFocusableViewId, value);
366 private int RightFocusableViewId
371 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.RightFocusableViewId);
376 Object.InternalSetPropertyInt(SwigCPtr, View.Property.RightFocusableViewId, value);
380 private int UpFocusableViewId
385 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.UpFocusableViewId);
390 Object.InternalSetPropertyInt(SwigCPtr, View.Property.UpFocusableViewId, value);
394 private int DownFocusableViewId
399 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.DownFocusableViewId);
404 Object.InternalSetPropertyInt(SwigCPtr, View.Property.DownFocusableViewId, value);
408 private int ClockwiseFocusableViewId
413 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.ClockwiseFocusableViewId);
418 Object.InternalSetPropertyInt(SwigCPtr, View.Property.ClockwiseFocusableViewId, value);
422 private int CounterClockwiseFocusableViewId
427 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.CounterClockwiseFocusableViewId);
432 Object.InternalSetPropertyInt(SwigCPtr, View.Property.CounterClockwiseFocusableViewId, value);
436 internal string GetName()
438 string ret = Interop.Actor.GetName(SwigCPtr);
439 if (NDalicPINVOKE.SWIGPendingException.Pending)
440 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
444 internal void SetName(string name)
446 Interop.Actor.SetName(SwigCPtr, name);
447 if (NDalicPINVOKE.SWIGPendingException.Pending)
448 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
451 internal uint GetId()
453 uint ret = Interop.Actor.GetId(SwigCPtr);
454 if (NDalicPINVOKE.SWIGPendingException.Pending)
455 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
459 internal bool IsRoot()
461 bool ret = Interop.ActorInternal.IsRoot(SwigCPtr);
462 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
466 internal bool OnWindow()
468 bool ret = Interop.Actor.OnStage(SwigCPtr);
469 if (NDalicPINVOKE.SWIGPendingException.Pending)
470 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
474 internal View FindChildById(uint id)
476 //to fix memory leak issue, match the handle count with native side.
477 IntPtr cPtr = Interop.Actor.FindChildById(SwigCPtr, id);
478 View ret = this.GetInstanceSafely<View>(cPtr);
479 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
483 internal override View FindCurrentChildById(uint id)
485 return FindChildById(id);
488 internal void SetParentOrigin(Position origin)
490 Interop.ActorInternal.SetParentOrigin(SwigCPtr, Position.getCPtr(origin));
491 if (NDalicPINVOKE.SWIGPendingException.Pending)
492 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
495 internal Position GetCurrentParentOrigin()
498 if(internalCurrentParentOrigin == null)
500 internalCurrentParentOrigin = new Position(0, 0, 0);
503 Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.ParentOrigin, internalCurrentParentOrigin.SwigCPtr);
505 if (NDalicPINVOKE.SWIGPendingException.Pending)
507 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
509 return internalCurrentParentOrigin;
512 internal void SetAnchorPoint(Position anchorPoint)
514 Interop.Actor.SetAnchorPoint(SwigCPtr, Position.getCPtr(anchorPoint));
515 if (NDalicPINVOKE.SWIGPendingException.Pending)
516 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
519 internal Position GetCurrentAnchorPoint()
522 if(internalCurrentAnchorPoint == null)
524 internalCurrentAnchorPoint = new Position(0, 0, 0);
527 Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.AnchorPoint, internalCurrentAnchorPoint.SwigCPtr);
529 if (NDalicPINVOKE.SWIGPendingException.Pending)
531 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
533 return internalCurrentAnchorPoint;
536 internal void SetSize(float width, float height)
538 Interop.ActorInternal.SetSize(SwigCPtr, width, height);
539 if (NDalicPINVOKE.SWIGPendingException.Pending)
540 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
543 internal void SetSize(float width, float height, float depth)
545 Interop.ActorInternal.SetSize(SwigCPtr, width, height, depth);
546 if (NDalicPINVOKE.SWIGPendingException.Pending)
547 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
550 internal void SetSize(Vector2 size)
552 Interop.ActorInternal.SetSizeVector2(SwigCPtr, Vector2.getCPtr(size));
553 if (NDalicPINVOKE.SWIGPendingException.Pending)
554 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
557 internal void SetSize(Vector3 size)
559 Interop.ActorInternal.SetSizeVector3(SwigCPtr, Vector3.getCPtr(size));
560 if (NDalicPINVOKE.SWIGPendingException.Pending)
561 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
564 internal Vector3 GetTargetSize()
567 if(internalTargetSize == null)
569 internalTargetSize = new Vector3(0, 0, 0);
572 Interop.ActorInternal.RetrieveTargetSize(SwigCPtr, internalTargetSize.SwigCPtr);
574 if (NDalicPINVOKE.SWIGPendingException.Pending)
576 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
578 return internalTargetSize;
581 internal Size2D GetCurrentSize()
584 if(internalCurrentSize == null)
586 internalCurrentSize = new Size2D(0, 0);
589 Interop.ActorInternal.RetrieveCurrentPropertyVector2ActualVector3(SwigCPtr, Property.SIZE, internalCurrentSize.SwigCPtr);
591 if (NDalicPINVOKE.SWIGPendingException.Pending)
593 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
595 return internalCurrentSize;
598 internal Size2D GetCurrentSizeFloat()
600 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
601 if (NDalicPINVOKE.SWIGPendingException.Pending)
602 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
607 /// GetNaturalSize() function behaviour can be changed for each subclass of View.
608 /// So we make GetNaturalSize() function virtual, and make subclass can define it's owned logic
610 internal virtual Vector3 GetNaturalSize()
612 Vector3 ret = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
613 if (NDalicPINVOKE.SWIGPendingException.Pending)
614 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
618 internal void SetX(float x)
620 Interop.ActorInternal.SetX(SwigCPtr, x);
621 if (NDalicPINVOKE.SWIGPendingException.Pending)
622 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
625 internal void SetY(float y)
627 Interop.ActorInternal.SetY(SwigCPtr, y);
628 if (NDalicPINVOKE.SWIGPendingException.Pending)
629 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
632 internal void SetZ(float z)
634 Interop.ActorInternal.SetZ(SwigCPtr, z);
635 if (NDalicPINVOKE.SWIGPendingException.Pending)
636 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
639 internal void TranslateBy(Vector3 distance)
641 Interop.ActorInternal.TranslateBy(SwigCPtr, Vector3.getCPtr(distance));
642 if (NDalicPINVOKE.SWIGPendingException.Pending)
643 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
646 internal Position GetCurrentPosition()
649 if(internalCurrentPosition == null)
651 internalCurrentPosition = new Position(0, 0, 0);
654 Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, Property.POSITION, internalCurrentPosition.SwigCPtr);
656 if (NDalicPINVOKE.SWIGPendingException.Pending)
658 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
660 return internalCurrentPosition;
662 internal Vector3 GetCurrentWorldPosition()
665 if(internalCurrentWorldPosition == null)
667 internalCurrentWorldPosition = new Vector3(0, 0, 0);
670 Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.WorldPosition, internalCurrentWorldPosition.SwigCPtr);
672 if (NDalicPINVOKE.SWIGPendingException.Pending)
674 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
676 return internalCurrentWorldPosition;
679 internal Vector2 GetCurrentScreenPosition()
682 if(internalCurrentScreenPosition == null)
684 internalCurrentScreenPosition = new Vector2(0, 0);
687 Object.InternalRetrievingPropertyVector2(SwigCPtr, View.Property.ScreenPosition, internalCurrentScreenPosition.SwigCPtr);
689 if (NDalicPINVOKE.SWIGPendingException.Pending)
691 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
693 return internalCurrentScreenPosition;
696 internal Vector4 GetCurrentScreenPositionSize()
698 Vector4 ret = new Vector4(Interop.Actor.CurrentScreenExtents(SwigCPtr), true);
699 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
703 internal void SetInheritPosition(bool inherit)
705 Interop.ActorInternal.SetInheritPosition(SwigCPtr, inherit);
706 if (NDalicPINVOKE.SWIGPendingException.Pending)
707 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
710 internal bool IsPositionInherited()
712 bool ret = Interop.ActorInternal.IsPositionInherited(SwigCPtr);
713 if (NDalicPINVOKE.SWIGPendingException.Pending)
714 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
718 internal void SetOrientation(Degree angle, Vector3 axis)
720 Interop.ActorInternal.SetOrientationDegree(SwigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
721 if (NDalicPINVOKE.SWIGPendingException.Pending)
722 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
725 internal void SetOrientation(Radian angle, Vector3 axis)
727 Interop.ActorInternal.SetOrientationRadian(SwigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
728 if (NDalicPINVOKE.SWIGPendingException.Pending)
729 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
732 internal void SetOrientation(Rotation orientation)
734 Interop.ActorInternal.SetOrientationQuaternion(SwigCPtr, Rotation.getCPtr(orientation));
735 if (NDalicPINVOKE.SWIGPendingException.Pending)
736 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
739 internal Rotation GetCurrentOrientation()
741 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentOrientation(SwigCPtr), true);
742 if (NDalicPINVOKE.SWIGPendingException.Pending)
743 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
747 internal void SetInheritOrientation(bool inherit)
749 Interop.ActorInternal.SetInheritOrientation(SwigCPtr, inherit);
750 if (NDalicPINVOKE.SWIGPendingException.Pending)
751 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
754 internal bool IsOrientationInherited()
756 bool ret = Interop.ActorInternal.IsOrientationInherited(SwigCPtr);
757 if (NDalicPINVOKE.SWIGPendingException.Pending)
758 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
762 internal Rotation GetCurrentWorldOrientation()
764 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentWorldOrientation(SwigCPtr), true);
765 if (NDalicPINVOKE.SWIGPendingException.Pending)
766 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
770 internal void SetScale(float scale)
772 Interop.ActorInternal.SetScale(SwigCPtr, scale);
773 if (NDalicPINVOKE.SWIGPendingException.Pending)
774 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
777 internal void SetScale(float scaleX, float scaleY, float scaleZ)
779 Interop.ActorInternal.SetScale(SwigCPtr, scaleX, scaleY, scaleZ);
780 if (NDalicPINVOKE.SWIGPendingException.Pending)
781 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
784 internal void SetScale(Vector3 scale)
786 Interop.ActorInternal.SetScale(SwigCPtr, Vector3.getCPtr(scale));
787 if (NDalicPINVOKE.SWIGPendingException.Pending)
788 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
791 internal Vector3 GetCurrentScale()
794 if(internalCurrentScale == null)
796 internalCurrentScale = new Vector3(0, 0, 0);
799 Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.SCALE, internalCurrentScale.SwigCPtr);
801 if (NDalicPINVOKE.SWIGPendingException.Pending)
803 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
805 return internalCurrentScale;
808 internal Vector3 GetCurrentWorldScale()
811 if(internalCurrentWorldScale == null)
813 internalCurrentWorldScale = new Vector3(0, 0, 0);
816 Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.WorldScale, internalCurrentWorldScale.SwigCPtr);
818 if (NDalicPINVOKE.SWIGPendingException.Pending)
820 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
822 return internalCurrentWorldScale;
825 internal void SetInheritScale(bool inherit)
827 Interop.ActorInternal.SetInheritScale(SwigCPtr, inherit);
828 if (NDalicPINVOKE.SWIGPendingException.Pending)
829 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
832 internal bool IsScaleInherited()
834 bool ret = Interop.ActorInternal.IsScaleInherited(SwigCPtr);
835 if (NDalicPINVOKE.SWIGPendingException.Pending)
836 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
840 internal Matrix GetCurrentWorldMatrix()
842 Matrix ret = new Matrix(Interop.ActorInternal.GetCurrentWorldMatrix(SwigCPtr), true);
843 if (NDalicPINVOKE.SWIGPendingException.Pending)
844 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
848 internal void SetVisible(bool visible)
850 Interop.Actor.SetVisible(SwigCPtr, visible);
851 if (NDalicPINVOKE.SWIGPendingException.Pending)
852 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
856 /// Retrieve the View's current Visibility.
859 /// The <see cref="Visibility"/> property is set in the main thread, so it is not updated in real time when the value is changed in the render thread.
860 /// However, this method can get the current actual value updated in real time.
862 internal bool IsVisible()
864 bool ret = Interop.ActorInternal.IsVisible(SwigCPtr);
865 if (NDalicPINVOKE.SWIGPendingException.Pending)
866 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
870 internal void SetOpacity(float opacity)
872 Interop.ActorInternal.SetOpacity(SwigCPtr, opacity);
873 if (NDalicPINVOKE.SWIGPendingException.Pending)
874 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
877 internal float GetCurrentOpacity()
879 float ret = Interop.ActorInternal.GetCurrentOpacity(SwigCPtr);
880 if (NDalicPINVOKE.SWIGPendingException.Pending)
881 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
885 internal Vector4 GetCurrentColor()
888 if(internalCurrentColor == null)
890 internalCurrentColor = new Vector4(0, 0, 0, 0);
893 Interop.ActorInternal.RetrieveCurrentPropertyVector4(SwigCPtr, Interop.ActorProperty.ColorGet(), internalCurrentColor.SwigCPtr);
895 if (NDalicPINVOKE.SWIGPendingException.Pending)
897 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
899 return internalCurrentColor;
901 internal ColorMode GetColorMode()
903 ColorMode ret = (ColorMode)Interop.ActorInternal.GetColorMode(SwigCPtr);
904 if (NDalicPINVOKE.SWIGPendingException.Pending)
905 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
909 internal Vector4 GetCurrentWorldColor()
912 if(internalCurrentWorldColor == null)
914 internalCurrentWorldColor = new Vector4(0, 0, 0, 0);
917 Interop.ActorInternal.RetrieveCurrentPropertyVector4(SwigCPtr, Property.WorldColor, internalCurrentWorldColor.SwigCPtr);
919 if (NDalicPINVOKE.SWIGPendingException.Pending)
921 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
923 return internalCurrentWorldColor;
926 internal void SetDrawMode(DrawModeType drawMode)
928 Interop.ActorInternal.SetDrawMode(SwigCPtr, (int)drawMode);
929 if (NDalicPINVOKE.SWIGPendingException.Pending)
930 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
933 internal DrawModeType GetDrawMode()
935 DrawModeType ret = (DrawModeType)Interop.ActorInternal.GetDrawMode(SwigCPtr);
936 if (NDalicPINVOKE.SWIGPendingException.Pending)
937 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
941 internal void SetKeyboardFocusable(bool focusable)
943 Interop.ActorInternal.SetKeyboardFocusable(SwigCPtr, focusable);
944 if (NDalicPINVOKE.SWIGPendingException.Pending)
945 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
948 internal bool IsKeyboardFocusable()
950 bool ret = Interop.ActorInternal.IsKeyboardFocusable(SwigCPtr);
951 if (NDalicPINVOKE.SWIGPendingException.Pending)
952 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
956 internal void SetKeyboardFocusableChildren(bool focusable)
958 Interop.ActorInternal.SetKeyboardFocusableChildren(SwigCPtr, focusable);
959 if (NDalicPINVOKE.SWIGPendingException.Pending)
960 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
963 internal bool AreChildrenKeyBoardFocusable()
965 bool ret = Interop.ActorInternal.AreChildrenKeyBoardFocusable(SwigCPtr);
966 if (NDalicPINVOKE.SWIGPendingException.Pending)
967 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
971 internal void SetFocusableInTouch(bool enabled)
973 Interop.ActorInternal.SetFocusableInTouch(SwigCPtr, enabled);
974 if (NDalicPINVOKE.SWIGPendingException.Pending)
975 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
978 internal bool IsFocusableInTouch()
980 bool ret = Interop.ActorInternal.IsFocusableInTouch(SwigCPtr);
981 if (NDalicPINVOKE.SWIGPendingException.Pending)
982 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
986 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
988 Interop.Actor.SetResizePolicy(SwigCPtr, (int)policy, (int)dimension);
989 if (NDalicPINVOKE.SWIGPendingException.Pending)
990 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
993 internal ResizePolicyType GetResizePolicy(DimensionType dimension)
995 ResizePolicyType ret = (ResizePolicyType)Interop.Actor.GetResizePolicy(SwigCPtr, (int)dimension);
996 if (NDalicPINVOKE.SWIGPendingException.Pending)
997 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1001 internal Vector3 GetSizeModeFactor()
1004 if (internalSizeModeFactor == null)
1006 internalSizeModeFactor = new Vector3(OnSizeModeFactorChanged, 0, 0, 0);
1008 Object.InternalRetrievingPropertyVector3(SwigCPtr, View.Property.SizeModeFactor, internalSizeModeFactor.SwigCPtr);
1009 return internalSizeModeFactor;
1012 internal void SetMinimumSize(Vector2 size)
1014 Interop.ActorInternal.SetMinimumSize(SwigCPtr, Vector2.getCPtr(size));
1015 if (NDalicPINVOKE.SWIGPendingException.Pending)
1016 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1019 internal Vector2 GetMinimumSize()
1022 if (internalMinimumSize == null)
1024 internalMinimumSize = new Size2D(OnMinimumSizeChanged, 0, 0);
1026 Object.InternalRetrievingPropertyVector2(SwigCPtr, View.Property.MinimumSize, internalMinimumSize.SwigCPtr);
1027 return internalMinimumSize;
1030 internal void SetMaximumSize(Vector2 size)
1032 Interop.ActorInternal.SetMaximumSize(SwigCPtr, Vector2.getCPtr(size));
1033 if (NDalicPINVOKE.SWIGPendingException.Pending)
1034 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1037 internal Vector2 GetMaximumSize()
1040 if (internalMaximumSize == null)
1042 internalMaximumSize = new Size2D(OnMaximumSizeChanged, 0, 0);
1044 Object.InternalRetrievingPropertyVector2(SwigCPtr, View.Property.MaximumSize, internalMaximumSize.SwigCPtr);
1045 return internalMaximumSize;
1048 internal int GetHierarchyDepth()
1050 int ret = Interop.Actor.GetHierarchyDepth(SwigCPtr);
1051 if (NDalicPINVOKE.SWIGPendingException.Pending)
1052 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1056 internal uint GetRendererCount()
1058 uint ret = Interop.Actor.GetRendererCount(SwigCPtr);
1059 if (NDalicPINVOKE.SWIGPendingException.Pending)
1060 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1064 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
1066 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1069 internal bool IsTopLevelView()
1071 if (GetParent() is Layer)
1079 /// Check whether Current view don't has BackgroundVisual or not.
1080 /// Some API (like Animation, Borderline) required non-empty backgrounds.
1082 internal bool IsBackgroundEmpty()
1084 int visualType = (int)Visual.Type.Invalid;
1085 Interop.View.InternalRetrievingVisualPropertyInt(this.SwigCPtr, Property.BACKGROUND, Visual.Property.Type, out visualType);
1086 return visualType == (int)Visual.Type.Invalid;
1090 /// Check whether Current view don't has ShadowVisual or not.
1092 internal bool IsShadowEmpty()
1094 int visualType = (int)Visual.Type.Invalid;
1095 Interop.View.InternalRetrievingVisualPropertyInt(this.SwigCPtr, Property.SHADOW, Visual.Property.Type, out visualType);
1096 return visualType == (int)Visual.Type.Invalid;
1099 internal void SetKeyInputFocus()
1101 Interop.ViewInternal.SetKeyInputFocus(SwigCPtr);
1102 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1105 internal void ClearKeyInputFocus()
1107 Interop.ViewInternal.ClearKeyInputFocus(SwigCPtr);
1108 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1111 internal PinchGestureDetector GetPinchGestureDetector()
1113 PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.GetPinchGestureDetector(SwigCPtr), true);
1114 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1118 internal PanGestureDetector GetPanGestureDetector()
1120 PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.GetPanGestureDetector(SwigCPtr), true);
1121 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1125 internal TapGestureDetector GetTapGestureDetector()
1127 TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.GetTapGestureDetector(SwigCPtr), true);
1128 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1132 internal LongPressGestureDetector GetLongPressGestureDetector()
1134 LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.GetLongPressGestureDetector(SwigCPtr), true);
1135 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1139 internal IntPtr GetPtrfromView()
1141 return (IntPtr)SwigCPtr;
1144 internal void RemoveChild(View child)
1146 // If the view had focus, it clears focus.
1147 if (child == FocusManager.Instance.GetCurrentFocusView())
1149 Tizen.Log.Debug("NUI", $"ClearFocus due to View id:({child.ID}) removed from scene\n");
1150 FocusManager.Instance.ClearFocus();
1152 // Do actual child removal
1153 Interop.Actor.Remove(SwigCPtr, View.getCPtr(child));
1154 if (NDalicPINVOKE.SWIGPendingException.Pending)
1155 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1157 Children.Remove(child);
1158 child.InternalParent = null;
1159 LayoutCount -= child.LayoutCount;
1161 OnChildRemoved(child);
1162 if (ChildRemoved != null)
1164 ChildRemovedEventArgs e = new ChildRemovedEventArgs
1168 ChildRemoved(this, e);
1173 /// Removes the layout from this View.
1175 internal void ResetLayout()
1182 internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1184 return (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1188 /// Lazy call to UpdateBackgroundExtraData.
1189 /// Collect Properties need to be update, and set properties that starts the Processing.
1191 internal virtual void UpdateBackgroundExtraData(BackgroundExtraDataUpdatedFlag flag)
1193 if (backgroundExtraData == null)
1198 if (!backgroundExtraDataUpdatedFlag.HasFlag(flag))
1200 backgroundExtraDataUpdatedFlag |= flag;
1201 // TODO : Re-open this API when we resolve Animation issue.
1202 // Instead, let we call UpdateBackgroundExtraData() synchronously.
1203 UpdateBackgroundExtraData();
1204 // if (!backgroundExtraDataUpdateProcessAttachedFlag)
1206 // backgroundExtraDataUpdateProcessAttachedFlag = true;
1207 // ProcessorController.Instance.ProcessorOnceEvent += UpdateBackgroundExtraData;
1208 // // Call process hardly.
1209 // ProcessorController.Instance.Awake();
1215 /// Callback function to Lazy UpdateBackgroundExtraData.
1217 private void UpdateBackgroundExtraData(object source, EventArgs e)
1219 // Note : To allow event attachment during UpdateBackgroundExtraData, let we make flag as false before call UpdateBackgroundExtraData().
1220 backgroundExtraDataUpdateProcessAttachedFlag = false;
1221 UpdateBackgroundExtraData();
1225 /// Update background extra data properties synchronously.
1226 /// After call this API, All background extra data properties updated.
1228 internal virtual void UpdateBackgroundExtraData()
1230 if (backgroundExtraData == null)
1235 if (IsShadowEmpty())
1237 backgroundExtraDataUpdatedFlag &= ~BackgroundExtraDataUpdatedFlag.Shadow;
1239 if (!Rectangle.IsNullOrZero(backgroundExtraData.BackgroundImageBorder))
1241 backgroundExtraDataUpdatedFlag &= ~BackgroundExtraDataUpdatedFlag.Background;
1244 if (backgroundExtraDataUpdatedFlag == BackgroundExtraDataUpdatedFlag.None)
1249 if ((backgroundExtraDataUpdatedFlag & BackgroundExtraDataUpdatedFlag.Borderline) != BackgroundExtraDataUpdatedFlag.None)
1253 if ((backgroundExtraDataUpdatedFlag & BackgroundExtraDataUpdatedFlag.CornerRadius) != BackgroundExtraDataUpdatedFlag.None)
1255 ApplyCornerRadius();
1257 backgroundExtraDataUpdatedFlag = BackgroundExtraDataUpdatedFlag.None;
1260 /// TODO open as a protected level
1261 internal virtual void ApplyCornerRadius()
1263 if (backgroundExtraData == null) return;
1265 // Update corner radius properties to background and shadow by ActionUpdateProperty
1266 if (backgroundExtraDataUpdatedFlag.HasFlag(BackgroundExtraDataUpdatedFlag.BackgroundCornerRadius))
1268 if (backgroundExtraData.CornerRadius != null)
1270 Interop.View.InternalUpdateVisualPropertyVector4(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.CornerRadius, Vector4.getCPtr(backgroundExtraData.CornerRadius));
1272 Interop.View.InternalUpdateVisualPropertyInt(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.CornerRadiusPolicy, (int)backgroundExtraData.CornerRadiusPolicy);
1274 if (backgroundExtraDataUpdatedFlag.HasFlag(BackgroundExtraDataUpdatedFlag.ShadowCornerRadius))
1276 if (backgroundExtraData.CornerRadius != null)
1278 Interop.View.InternalUpdateVisualPropertyVector4(this.SwigCPtr, View.Property.SHADOW, Visual.Property.CornerRadius, Vector4.getCPtr(backgroundExtraData.CornerRadius));
1280 Interop.View.InternalUpdateVisualPropertyInt(this.SwigCPtr, View.Property.SHADOW, Visual.Property.CornerRadiusPolicy, (int)backgroundExtraData.CornerRadiusPolicy);
1284 /// TODO open as a protected level
1285 internal virtual void ApplyBorderline()
1287 if (backgroundExtraData == null) return;
1289 // ActionUpdateProperty works well only if BACKGROUND visual setup before.
1290 // If view don't have BACKGROUND visual, we set transparent background color in default.
1291 if (IsBackgroundEmpty())
1293 // BACKGROUND visual doesn't exist.
1294 SetBackgroundColor(Color.Transparent);
1295 // SetBackgroundColor function apply borderline internally.
1296 // So we can just return now.
1300 // Update borderline properties to background by ActionUpdateProperty
1301 if (backgroundExtraDataUpdatedFlag.HasFlag(BackgroundExtraDataUpdatedFlag.BackgroundBorderline))
1303 Interop.View.InternalUpdateVisualPropertyFloat(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.BorderlineWidth, backgroundExtraData.BorderlineWidth);
1304 Interop.View.InternalUpdateVisualPropertyVector4(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.BorderlineColor, Vector4.getCPtr(backgroundExtraData.BorderlineColor ?? Color.Black));
1305 Interop.View.InternalUpdateVisualPropertyFloat(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.BorderlineOffset, backgroundExtraData.BorderlineOffset);
1310 /// Get selector value from the triggerable selector or related property.
1312 internal Selector<T> GetSelector<T>(TriggerableSelector<T> triggerableSelector, NUI.Binding.BindableProperty relatedProperty)
1314 var selector = triggerableSelector?.Get();
1315 if (selector != null)
1320 var value = (T)GetValue(relatedProperty);
1321 return value == null ? null : new Selector<T>(value);
1324 internal void SetThemeApplied()
1326 if (themeData == null) themeData = new ThemeData();
1327 themeData.ThemeApplied = true;
1329 if (ThemeChangeSensitive && !themeData.ListeningThemeChangeEvent)
1331 themeData.ListeningThemeChangeEvent = true;
1332 ThemeManager.ThemeChangedInternal.Add(OnThemeChanged);
1337 /// you can override it to clean-up your own resources.
1339 /// <param name="type">DisposeTypes</param>
1340 /// <since_tizen> 3 </since_tizen>
1341 protected override void Dispose(DisposeTypes type)
1348 disposeDebugging(type);
1350 if (SwigCMemOwn && !IsNativeHandleInvalid())
1352 Interop.ControlDevel.DaliAccessibilityDetachAccessibleObject(SwigCPtr);
1353 NDalicPINVOKE.ThrowExceptionIfExists();
1356 //_mergedStyle = null;
1358 internalMaximumSize?.Dispose();
1359 internalMaximumSize = null;
1360 internalMinimumSize?.Dispose();
1361 internalMinimumSize = null;
1362 internalMargin?.Dispose();
1363 internalMargin = null;
1364 internalPadding?.Dispose();
1365 internalPadding = null;
1366 internalSizeModeFactor?.Dispose();
1367 internalSizeModeFactor = null;
1368 internalCellIndex?.Dispose();
1369 internalCellIndex = null;
1370 internalBackgroundColor?.Dispose();
1371 internalBackgroundColor = null;
1372 internalColor?.Dispose();
1373 internalColor = null;
1374 internalPivotPoint?.Dispose();
1375 internalPivotPoint = null;
1376 internalPosition?.Dispose();
1377 internalPosition = null;
1378 internalPosition2D?.Dispose();
1379 internalPosition2D = null;
1380 internalScale?.Dispose();
1381 internalScale = null;
1382 internalSize?.Dispose();
1383 internalSize = null;
1384 internalSize2D?.Dispose();
1385 internalSize2D = null;
1387 panGestureDetector?.Dispose();
1388 panGestureDetector = null;
1389 longGestureDetector?.Dispose();
1390 longGestureDetector = null;
1391 pinchGestureDetector?.Dispose();
1392 pinchGestureDetector = null;
1393 tapGestureDetector?.Dispose();
1394 tapGestureDetector = null;
1395 rotationGestureDetector?.Dispose();
1396 rotationGestureDetector = null;
1398 internalCurrentParentOrigin?.Dispose();
1399 internalCurrentParentOrigin = null;
1400 internalCurrentAnchorPoint?.Dispose();
1401 internalCurrentAnchorPoint = null;
1402 internalTargetSize?.Dispose();
1403 internalTargetSize = null;
1404 internalCurrentSize?.Dispose();
1405 internalCurrentSize = null;
1406 internalCurrentPosition?.Dispose();
1407 internalCurrentPosition = null;
1408 internalCurrentWorldPosition?.Dispose();
1409 internalCurrentWorldPosition = null;
1410 internalCurrentScale?.Dispose();
1411 internalCurrentScale = null;
1412 internalCurrentWorldScale?.Dispose();
1413 internalCurrentWorldScale = null;
1414 internalCurrentColor?.Dispose();
1415 internalCurrentColor = null;
1416 internalCurrentWorldColor?.Dispose();
1417 internalCurrentWorldColor = null;
1418 internalSizeModeFactor?.Dispose();
1419 internalSizeModeFactor = null;
1420 internalCurrentScreenPosition?.Dispose();
1421 internalCurrentScreenPosition = null;
1423 if (type == DisposeTypes.Explicit)
1426 //Release your own managed resources here.
1427 //You should release all of your own disposable objects here.
1428 if (themeData != null)
1430 themeData.selectorData?.Reset(this);
1431 if (themeData.ListeningThemeChangeEvent)
1433 ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
1436 if (widthConstraint != null)
1438 widthConstraint.Remove();
1439 widthConstraint.Dispose();
1441 if (heightConstraint != null)
1443 heightConstraint.Remove();
1444 heightConstraint.Dispose();
1448 //Release your own unmanaged resources here.
1449 //You should not access any managed member here except static instance.
1450 //because the execution order of Finalizes is non-deterministic.
1452 DisConnectFromSignals();
1454 foreach (View view in Children)
1456 view.InternalParent = null;
1459 backgroundExtraDataUpdatedFlag = BackgroundExtraDataUpdatedFlag.None;
1460 if (backgroundExtraDataUpdateProcessAttachedFlag)
1462 ProcessorController.Instance.ProcessorOnceEvent -= UpdateBackgroundExtraData;
1463 backgroundExtraDataUpdateProcessAttachedFlag = false;
1468 NUILog.Debug($"[Dispose] View.Dispose({type}) END");
1469 NUILog.Debug($"=============================");
1476 /// This will not be public opened.
1477 [EditorBrowsable(EditorBrowsableState.Never)]
1478 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1480 Interop.View.DeleteView(swigCPtr);
1484 /// The touch event handler for ControlState.
1485 /// Please change ControlState value by touch state if needed.
1487 /// <exception cref="ArgumentNullException"> Thrown when touch is null. </exception>
1488 [EditorBrowsable(EditorBrowsableState.Never)]
1489 protected virtual bool HandleControlStateOnTouch(Touch touch)
1493 throw new global::System.ArgumentNullException(nameof(touch));
1496 switch (touch.GetState(0))
1498 case PointStateType.Down:
1499 ControlState += ControlState.Pressed;
1501 case PointStateType.Interrupted:
1502 case PointStateType.Up:
1503 if (ControlState.Contains(ControlState.Pressed))
1505 ControlState -= ControlState.Pressed;
1515 /// Internal callback of enabled property changes.
1516 /// Inherited view can override this method to implements enabled property changes.
1518 [EditorBrowsable(EditorBrowsableState.Never)]
1519 protected virtual void OnEnabled(bool enabled)
1523 if (State == View.States.Disabled)
1525 State = View.States.Normal;
1527 if (enableControlState)
1529 ControlState -= ControlState.Disabled;
1534 State = View.States.Disabled;
1535 if (enableControlState)
1537 ControlState += ControlState.Disabled;
1543 private void DisConnectFromSignals()
1545 if (HasBody() == false)
1547 NUILog.Debug($"[Dispose] DisConnectFromSignals() No native body! No need to Disconnect Signals!");
1550 NUILog.Debug($"[Dispose] DisConnectFromSignals START");
1551 NUILog.Debug($"[Dispose] View.DisConnectFromSignals() type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1552 NUILog.Debug($"[Dispose] ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1554 if (onRelayoutEventCallback != null)
1556 NUILog.Debug($"[Dispose] onRelayoutEventCallback");
1558 Interop.ActorSignal.OnRelayoutDisconnect(GetBaseHandleCPtrHandleRef, onRelayoutEventCallback.ToHandleRef(this));
1559 NDalicPINVOKE.ThrowExceptionIfExistsDebug();
1560 onRelayoutEventCallback = null;
1563 if (offWindowEventCallback != null)
1565 NUILog.Debug($"[Dispose] offWindowEventCallback");
1567 Interop.ActorSignal.OffSceneDisconnect(GetBaseHandleCPtrHandleRef, offWindowEventCallback.ToHandleRef(this));
1568 NDalicPINVOKE.ThrowExceptionIfExistsDebug();
1569 offWindowEventCallback = null;
1572 if (onWindowEventCallback != null)
1574 NUILog.Debug($"[Dispose] onWindowEventCallback");
1576 Interop.ActorSignal.OnSceneDisconnect(GetBaseHandleCPtrHandleRef, onWindowEventCallback.ToHandleRef(this));
1577 NDalicPINVOKE.ThrowExceptionIfExistsDebug();
1578 onWindowEventCallback = null;
1581 if (interceptWheelCallback != null)
1583 NUILog.Debug($"[Dispose] interceptWheelCallback");
1585 Interop.ActorSignal.InterceptWheelDisconnect(GetBaseHandleCPtrHandleRef, interceptWheelCallback.ToHandleRef(this));
1586 NDalicPINVOKE.ThrowExceptionIfExistsDebug();
1587 interceptWheelCallback = null;
1590 if (wheelEventCallback != null)
1592 NUILog.Debug($"[Dispose] wheelEventCallback");
1594 Interop.ActorSignal.WheelEventDisconnect(GetBaseHandleCPtrHandleRef, wheelEventCallback.ToHandleRef(this));
1595 NDalicPINVOKE.ThrowExceptionIfExistsDebug();
1596 wheelEventCallback = null;
1599 if (hoverEventCallback != null)
1601 NUILog.Debug($"[Dispose] hoverEventCallback");
1603 Interop.ActorSignal.HoveredDisconnect(GetBaseHandleCPtrHandleRef, hoverEventCallback.ToHandleRef(this));
1604 NDalicPINVOKE.ThrowExceptionIfExistsDebug();
1605 hoverEventCallback = null;
1608 if (hitTestResultDataCallback != null)
1610 NUILog.Debug($"[Dispose] hitTestResultDataCallback");
1612 Interop.ActorSignal.HitTestResultDisconnect(GetBaseHandleCPtrHandleRef, hitTestResultDataCallback.ToHandleRef(this));
1613 NDalicPINVOKE.ThrowExceptionIfExistsDebug();
1614 hitTestResultDataCallback = null;
1618 if (interceptTouchDataCallback != null)
1620 NUILog.Debug($"[Dispose] interceptTouchDataCallback");
1622 Interop.ActorSignal.InterceptTouchDisconnect(GetBaseHandleCPtrHandleRef, interceptTouchDataCallback.ToHandleRef(this));
1623 NDalicPINVOKE.ThrowExceptionIfExistsDebug();
1624 interceptTouchDataCallback = null;
1627 if (touchDataCallback != null)
1629 NUILog.Debug($"[Dispose] touchDataCallback");
1631 Interop.ActorSignal.TouchDisconnect(GetBaseHandleCPtrHandleRef, touchDataCallback.ToHandleRef(this));
1632 NDalicPINVOKE.ThrowExceptionIfExistsDebug();
1633 touchDataCallback = null;
1636 if (resourcesLoadedCallback != null)
1638 NUILog.Debug($"[Dispose] ResourcesLoadedCallback");
1640 Interop.ViewSignal.ResourceReadyDisconnect(GetBaseHandleCPtrHandleRef, resourcesLoadedCallback.ToHandleRef(this));
1641 NDalicPINVOKE.ThrowExceptionIfExistsDebug();
1642 resourcesLoadedCallback = null;
1645 if (keyCallback != null)
1647 NUILog.Debug($"[Dispose] keyCallback");
1649 Interop.ViewSignal.KeyEventDisconnect(GetBaseHandleCPtrHandleRef, keyCallback.ToHandleRef(this));
1650 NDalicPINVOKE.ThrowExceptionIfExistsDebug();
1654 if (keyInputFocusLostCallback != null)
1656 NUILog.Debug($"[Dispose] keyInputFocusLostCallback");
1658 Interop.ViewSignal.KeyInputFocusLostDisconnect(GetBaseHandleCPtrHandleRef, keyInputFocusLostCallback.ToHandleRef(this));
1659 NDalicPINVOKE.ThrowExceptionIfExistsDebug();
1660 keyInputFocusLostCallback = null;
1661 keyInputFocusLostEventHandler = null;
1664 if (keyInputFocusGainedCallback != null)
1666 NUILog.Debug($"[Dispose] keyInputFocusGainedCallback");
1668 Interop.ViewSignal.KeyInputFocusGainedDisconnect(GetBaseHandleCPtrHandleRef, keyInputFocusGainedCallback.ToHandleRef(this));
1669 NDalicPINVOKE.ThrowExceptionIfExistsDebug();
1670 keyInputFocusGainedCallback = null;
1671 keyInputFocusGainedEventHandler = null;
1674 if (backgroundResourceLoadedCallback != null)
1676 NUILog.Debug($"[Dispose] backgroundResourceLoadedCallback");
1678 Interop.ViewSignal.ResourceReadyDisconnect(GetBaseHandleCPtrHandleRef, backgroundResourceLoadedCallback.ToHandleRef(this));
1679 NDalicPINVOKE.ThrowExceptionIfExistsDebug();
1680 backgroundResourceLoadedCallback = null;
1683 NDalicPINVOKE.ThrowExceptionIfExists();
1684 NUILog.Debug($"[Dispose] DisConnectFromSignals END");
1688 /// Apply initial style to the view.
1690 [EditorBrowsable(EditorBrowsableState.Never)]
1691 protected virtual void InitializeStyle(ViewStyle style = null)
1693 if (style == null && ThemeManager.InitialThemeDisabled)
1695 // Fast return in most TV cases.
1699 var initialStyle = ThemeManager.GetInitialStyleWithoutClone(GetType());
1702 ApplyStyle(initialStyle);
1706 var refinedStyle = style;
1707 if (style.IncludeDefaultStyle)
1709 refinedStyle = initialStyle?.Merge(style);
1711 ApplyStyle(refinedStyle);
1714 // Listen theme change event if needs.
1715 if (initialStyle != null)
1721 private View ConvertIdToView(uint id)
1723 View view = GetParent()?.FindCurrentChildById(id);
1725 //If we can't find the parent's children, find in the top layer.
1728 Container parent = GetParent();
1729 while ((parent is View) && (parent != null))
1731 parent = parent.GetParent();
1732 if (parent is Layer)
1734 view = parent.FindCurrentChildById(id);
1743 private void OnScaleChanged(float x, float y, float z)
1745 Scale = new Vector3(x, y, z);
1748 private void OnBackgroundColorChanged(float r, float g, float b, float a)
1750 BackgroundColor = new Color(r, g, b, a);
1753 private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1755 Padding = new Extents(start, end, top, bottom);
1758 private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1760 Margin = new Extents(start, end, top, bottom);
1763 private void OnAnchorPointChanged(float x, float y, float z)
1765 AnchorPoint = new Position(x, y, z);
1768 private void OnCellIndexChanged(float x, float y)
1770 CellIndex = new Vector2(x, y);
1773 private void OnFlexMarginChanged(float x, float y, float z, float w)
1775 FlexMargin = new Vector4(x, y, z, w);
1778 private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1780 PaddingEX = new Extents(start, end, top, bottom);
1783 private void OnSizeModeFactorChanged(float x, float y, float z)
1785 SizeModeFactor = new Vector3(x, y, z);
1788 private bool EmptyOnTouch(object target, TouchEventArgs args)
1793 [EditorBrowsable(EditorBrowsableState.Never)]
1794 protected virtual bool CheckResourceReady()
1799 private ViewSelectorData EnsureSelectorData()
1801 if (themeData == null) themeData = new ThemeData();
1803 return themeData.selectorData ?? (themeData.selectorData = new ViewSelectorData());
1806 [Conditional("NUI_DISPOSE_DEBUG_ON")]
1807 private void disposeDebugging(DisposeTypes type)
1809 DebugFileLogging.Instance.WriteLog($"View.Dispose({type}) START");
1810 DebugFileLogging.Instance.WriteLog($"type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1813 DebugFileLogging.Instance.WriteLog($"ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1817 DebugFileLogging.Instance.WriteLog($"has no native body!");