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);
48 internal virtual LayoutItem CreateDefaultLayout()
50 return new AbsoluteLayout();
53 internal class ThemeData
56 private enum States : byte
59 ControlStatePropagation = 1 << 0,
60 ThemeChangeSensitive = 1 << 1,
61 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.
62 // That indicates the view can have different styles by theme.
63 // Hence if the current state has ThemeApplied and ThemeChangeSensitive, the view will change its style by theme changing.
64 ListeningThemeChangeEvent = 1 << 3,
67 private States states = ThemeManager.ApplicationThemeChangeSensitive ? States.ThemeChangeSensitive : States.None;
68 public ViewStyle viewStyle;
69 public ControlState controlStates = ControlState.Normal;
70 public ViewSelectorData selectorData;
72 public bool ControlStatePropagation
74 get => ((states & States.ControlStatePropagation) != 0);
75 set => SetOption(States.ControlStatePropagation, value);
78 public bool ThemeChangeSensitive
80 get => ((states & States.ThemeChangeSensitive) != 0);
81 set => SetOption(States.ThemeChangeSensitive, value);
84 public bool ThemeApplied
86 get => ((states & States.ThemeApplied) != 0);
87 set => SetOption(States.ThemeApplied, value);
90 public bool ListeningThemeChangeEvent
92 get => ((states & States.ListeningThemeChangeEvent) != 0);
93 set => SetOption(States.ListeningThemeChangeEvent, value);
96 private void SetOption(States option, bool value)
98 if (value) states |= option;
99 else states &= ~option;
104 /// The color mode of View.
105 /// This specifies whether the View uses its own color, or inherits its parent color.
106 /// The default is ColorMode.UseOwnMultiplyParentColor.
108 internal ColorMode ColorMode
116 return GetColorMode();
120 internal LayoutLength SuggestedMinimumWidth
124 float result = Interop.Actor.GetSuggestedMinimumWidth(SwigCPtr);
125 if (NDalicPINVOKE.SWIGPendingException.Pending)
126 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
127 return new LayoutLength(result);
131 internal LayoutLength SuggestedMinimumHeight
135 float result = Interop.Actor.GetSuggestedMinimumHeight(SwigCPtr);
136 if (NDalicPINVOKE.SWIGPendingException.Pending)
137 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
138 return new LayoutLength(result);
142 internal float WorldPositionX
146 float returnValue = 0.0f;
147 PropertyValue wordPositionX = GetProperty(View.Property.WorldPositionX);
148 wordPositionX?.Get(out returnValue);
149 wordPositionX?.Dispose();
154 internal float WorldPositionY
158 float returnValue = 0.0f;
159 PropertyValue wordPositionY = GetProperty(View.Property.WorldPositionY);
160 wordPositionY?.Get(out returnValue);
161 wordPositionY?.Dispose();
166 internal float WorldPositionZ
170 float returnValue = 0.0f;
171 PropertyValue wordPositionZ = GetProperty(View.Property.WorldPositionZ);
172 wordPositionZ?.Get(out returnValue);
173 wordPositionZ?.Dispose();
178 internal bool FocusState
182 return IsKeyboardFocusable();
186 SetKeyboardFocusable(value);
190 internal void SetLayout(LayoutItem layout)
194 this.layout = layout;
195 this.layout?.AttachToOwner(this);
196 this.layout?.RequestLayout();
199 internal void AttachTransitionsToChildren(LayoutTransition transition)
201 // Iterate children, adding the transition unless a transition
202 // for the same condition and property has already been
204 foreach (View view in Children)
206 LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions, transition.Condition, transition, false);
210 internal float ParentOriginX
214 float returnValue = 0.0f;
215 PropertyValue parentOriginX = GetProperty(View.Property.ParentOriginX);
216 parentOriginX?.Get(out returnValue);
217 parentOriginX?.Dispose();
222 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
223 SetProperty(View.Property.ParentOriginX, setValue);
225 NotifyPropertyChanged();
229 internal float ParentOriginY
233 float returnValue = 0.0f;
234 PropertyValue parentOriginY = GetProperty(View.Property.ParentOriginY);
235 parentOriginY?.Get(out returnValue);
236 parentOriginY?.Dispose();
241 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
242 SetProperty(View.Property.ParentOriginY, setValue);
244 NotifyPropertyChanged();
248 internal float ParentOriginZ
252 float returnValue = 0.0f;
253 PropertyValue parentOriginZ = GetProperty(View.Property.ParentOriginZ);
254 parentOriginZ?.Get(out returnValue);
255 parentOriginZ?.Dispose();
260 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
261 SetProperty(View.Property.ParentOriginZ, setValue);
263 NotifyPropertyChanged();
267 internal float PivotPointX
271 float returnValue = 0.0f;
272 PropertyValue anchorPointX = GetProperty(View.Property.AnchorPointX);
273 anchorPointX?.Get(out returnValue);
274 anchorPointX?.Dispose();
279 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
280 SetProperty(View.Property.AnchorPointX, setValue);
285 internal float PivotPointY
289 float returnValue = 0.0f;
290 PropertyValue anchorPointY = GetProperty(View.Property.AnchorPointY);
291 anchorPointY?.Get(out returnValue);
292 anchorPointY?.Dispose();
297 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
298 SetProperty(View.Property.AnchorPointY, setValue);
303 internal float PivotPointZ
307 float returnValue = 0.0f;
308 PropertyValue anchorPointZ = GetProperty(View.Property.AnchorPointZ);
309 anchorPointZ?.Get(out returnValue);
310 anchorPointZ?.Dispose();
315 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
316 SetProperty(View.Property.AnchorPointZ, setValue);
321 internal Matrix WorldMatrix
325 Matrix returnValue = new Matrix();
326 PropertyValue wordMatrix = GetProperty(View.Property.WorldMatrix);
327 wordMatrix?.Get(returnValue);
328 wordMatrix?.Dispose();
334 /// The number of layouts including view's layout and children's layouts.
335 /// This can be used to set/unset Process callback to calculate Layout.
337 internal int LayoutCount
346 if (layoutCount == value) return;
348 if (value < 0) throw new global::System.ArgumentOutOfRangeException(nameof(LayoutCount), "LayoutCount(" + LayoutCount + ") should not be less than zero");
350 int diff = value - layoutCount;
353 if (InternalParent != null)
355 var parentView = InternalParent as View;
356 if (parentView != null)
358 parentView.LayoutCount += diff;
362 var parentLayer = InternalParent as Layer;
363 if (parentLayer != null)
365 parentLayer.LayoutCount += diff;
373 /// Indicates that this View should listen Touch event to handle its ControlState.
375 private bool enableControlState = false;
377 private int LeftFocusableViewId
382 PropertyValue leftFocusableViewId = GetProperty(View.Property.LeftFocusableViewId);
383 leftFocusableViewId?.Get(out returnValue);
384 leftFocusableViewId?.Dispose();
389 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
390 SetProperty(View.Property.LeftFocusableViewId, setValue);
395 private int RightFocusableViewId
400 PropertyValue rightFocusableViewId = GetProperty(View.Property.RightFocusableViewId);
401 rightFocusableViewId?.Get(out returnValue);
402 rightFocusableViewId?.Dispose();
407 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
408 SetProperty(View.Property.RightFocusableViewId, setValue);
413 private int UpFocusableViewId
418 PropertyValue upFocusableViewId = GetProperty(View.Property.UpFocusableViewId);
419 upFocusableViewId?.Get(out returnValue);
420 upFocusableViewId?.Dispose();
425 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
426 SetProperty(View.Property.UpFocusableViewId, setValue);
431 private int DownFocusableViewId
436 PropertyValue downFocusableViewId = GetProperty(View.Property.DownFocusableViewId);
437 downFocusableViewId?.Get(out returnValue);
438 downFocusableViewId?.Dispose();
443 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
444 SetProperty(View.Property.DownFocusableViewId, setValue);
449 internal string GetName()
451 string ret = Interop.Actor.GetName(SwigCPtr);
452 if (NDalicPINVOKE.SWIGPendingException.Pending)
453 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
457 internal void SetName(string name)
459 Interop.Actor.SetName(SwigCPtr, name);
460 if (NDalicPINVOKE.SWIGPendingException.Pending)
461 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
464 internal uint GetId()
466 uint ret = Interop.Actor.GetId(SwigCPtr);
467 if (NDalicPINVOKE.SWIGPendingException.Pending)
468 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
472 internal bool IsRoot()
474 bool ret = Interop.ActorInternal.IsRoot(SwigCPtr);
475 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
479 internal bool OnWindow()
481 bool ret = Interop.Actor.OnStage(SwigCPtr);
482 if (NDalicPINVOKE.SWIGPendingException.Pending)
483 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
487 internal View FindChildById(uint id)
489 //to fix memory leak issue, match the handle count with native side.
490 IntPtr cPtr = Interop.Actor.FindChildById(SwigCPtr, id);
491 View ret = this.GetInstanceSafely<View>(cPtr);
492 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
496 internal override View FindCurrentChildById(uint id)
498 return FindChildById(id);
501 internal void SetParentOrigin(Vector3 origin)
503 Interop.ActorInternal.SetParentOrigin(SwigCPtr, Vector3.getCPtr(origin));
504 if (NDalicPINVOKE.SWIGPendingException.Pending)
505 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
508 internal Vector3 GetCurrentParentOrigin()
510 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentParentOrigin(SwigCPtr), true);
511 if (NDalicPINVOKE.SWIGPendingException.Pending)
512 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
516 internal void SetAnchorPoint(Vector3 anchorPoint)
518 Interop.Actor.SetAnchorPoint(SwigCPtr, Vector3.getCPtr(anchorPoint));
519 if (NDalicPINVOKE.SWIGPendingException.Pending)
520 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
523 internal Vector3 GetCurrentAnchorPoint()
525 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentAnchorPoint(SwigCPtr), true);
526 if (NDalicPINVOKE.SWIGPendingException.Pending)
527 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
531 internal void SetSize(float width, float height)
533 Interop.ActorInternal.SetSize(SwigCPtr, width, height);
534 if (NDalicPINVOKE.SWIGPendingException.Pending)
535 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
538 internal void SetSize(float width, float height, float depth)
540 Interop.ActorInternal.SetSize(SwigCPtr, width, height, depth);
541 if (NDalicPINVOKE.SWIGPendingException.Pending)
542 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
545 internal void SetSize(Vector2 size)
547 Interop.ActorInternal.SetSizeVector2(SwigCPtr, Vector2.getCPtr(size));
548 if (NDalicPINVOKE.SWIGPendingException.Pending)
549 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
552 internal void SetSize(Vector3 size)
554 Interop.ActorInternal.SetSizeVector3(SwigCPtr, Vector3.getCPtr(size));
555 if (NDalicPINVOKE.SWIGPendingException.Pending)
556 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
559 internal Vector3 GetTargetSize()
561 Vector3 ret = new Vector3(Interop.ActorInternal.GetTargetSize(SwigCPtr), true);
562 if (NDalicPINVOKE.SWIGPendingException.Pending)
563 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
567 internal Size2D GetCurrentSize()
569 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
570 if (NDalicPINVOKE.SWIGPendingException.Pending)
571 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
572 Size2D size = new Size2D((int)ret.Width, (int)ret.Height);
577 internal Size2D GetCurrentSizeFloat()
579 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
580 if (NDalicPINVOKE.SWIGPendingException.Pending)
581 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
586 /// GetNaturalSize() function behaviour can be changed for each subclass of View.
587 /// So we make GetNaturalSize() function virtual, and make subclass can define it's owned logic
589 internal virtual Vector3 GetNaturalSize()
591 Vector3 ret = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
592 if (NDalicPINVOKE.SWIGPendingException.Pending)
593 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
597 internal void SetPosition(float x, float y)
599 Interop.ActorInternal.SetPosition(SwigCPtr, x, y);
600 if (NDalicPINVOKE.SWIGPendingException.Pending)
601 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
604 internal void SetPosition(float x, float y, float z)
606 Interop.ActorInternal.SetPosition(SwigCPtr, x, y, z);
607 if (NDalicPINVOKE.SWIGPendingException.Pending)
608 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
611 internal void SetPosition(Vector3 position)
613 Interop.ActorInternal.SetPosition(SwigCPtr, Vector3.getCPtr(position));
614 if (NDalicPINVOKE.SWIGPendingException.Pending)
615 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()
648 Position ret = new Position(Interop.Actor.GetCurrentPosition(SwigCPtr), true);
649 if (NDalicPINVOKE.SWIGPendingException.Pending)
650 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
654 internal Vector3 GetCurrentWorldPosition()
656 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldPosition(SwigCPtr), true);
657 if (NDalicPINVOKE.SWIGPendingException.Pending)
658 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
662 internal void SetInheritPosition(bool inherit)
664 Interop.ActorInternal.SetInheritPosition(SwigCPtr, inherit);
665 if (NDalicPINVOKE.SWIGPendingException.Pending)
666 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
669 internal bool IsPositionInherited()
671 bool ret = Interop.ActorInternal.IsPositionInherited(SwigCPtr);
672 if (NDalicPINVOKE.SWIGPendingException.Pending)
673 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
677 internal void SetOrientation(Degree angle, Vector3 axis)
679 Interop.ActorInternal.SetOrientationDegree(SwigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
680 if (NDalicPINVOKE.SWIGPendingException.Pending)
681 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
684 internal void SetOrientation(Radian angle, Vector3 axis)
686 Interop.ActorInternal.SetOrientationRadian(SwigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
687 if (NDalicPINVOKE.SWIGPendingException.Pending)
688 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
691 internal void SetOrientation(Rotation orientation)
693 Interop.ActorInternal.SetOrientationQuaternion(SwigCPtr, Rotation.getCPtr(orientation));
694 if (NDalicPINVOKE.SWIGPendingException.Pending)
695 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
698 internal Rotation GetCurrentOrientation()
700 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentOrientation(SwigCPtr), true);
701 if (NDalicPINVOKE.SWIGPendingException.Pending)
702 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
706 internal void SetInheritOrientation(bool inherit)
708 Interop.ActorInternal.SetInheritOrientation(SwigCPtr, inherit);
709 if (NDalicPINVOKE.SWIGPendingException.Pending)
710 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
713 internal bool IsOrientationInherited()
715 bool ret = Interop.ActorInternal.IsOrientationInherited(SwigCPtr);
716 if (NDalicPINVOKE.SWIGPendingException.Pending)
717 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
721 internal Rotation GetCurrentWorldOrientation()
723 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentWorldOrientation(SwigCPtr), true);
724 if (NDalicPINVOKE.SWIGPendingException.Pending)
725 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
729 internal void SetScale(float scale)
731 Interop.ActorInternal.SetScale(SwigCPtr, scale);
732 if (NDalicPINVOKE.SWIGPendingException.Pending)
733 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
736 internal void SetScale(float scaleX, float scaleY, float scaleZ)
738 Interop.ActorInternal.SetScale(SwigCPtr, scaleX, scaleY, scaleZ);
739 if (NDalicPINVOKE.SWIGPendingException.Pending)
740 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
743 internal void SetScale(Vector3 scale)
745 Interop.ActorInternal.SetScale(SwigCPtr, Vector3.getCPtr(scale));
746 if (NDalicPINVOKE.SWIGPendingException.Pending)
747 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
750 internal Vector3 GetCurrentScale()
752 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentScale(SwigCPtr), true);
753 if (NDalicPINVOKE.SWIGPendingException.Pending)
754 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
758 internal Vector3 GetCurrentWorldScale()
760 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldScale(SwigCPtr), true);
761 if (NDalicPINVOKE.SWIGPendingException.Pending)
762 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
766 internal void SetInheritScale(bool inherit)
768 Interop.ActorInternal.SetInheritScale(SwigCPtr, inherit);
769 if (NDalicPINVOKE.SWIGPendingException.Pending)
770 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
773 internal bool IsScaleInherited()
775 bool ret = Interop.ActorInternal.IsScaleInherited(SwigCPtr);
776 if (NDalicPINVOKE.SWIGPendingException.Pending)
777 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
781 internal Matrix GetCurrentWorldMatrix()
783 Matrix ret = new Matrix(Interop.ActorInternal.GetCurrentWorldMatrix(SwigCPtr), true);
784 if (NDalicPINVOKE.SWIGPendingException.Pending)
785 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
789 internal void SetVisible(bool visible)
791 Interop.Actor.SetVisible(SwigCPtr, visible);
792 if (NDalicPINVOKE.SWIGPendingException.Pending)
793 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
796 internal bool IsVisible()
798 bool ret = Interop.ActorInternal.IsVisible(SwigCPtr);
799 if (NDalicPINVOKE.SWIGPendingException.Pending)
800 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
804 internal void SetOpacity(float opacity)
806 Interop.ActorInternal.SetOpacity(SwigCPtr, opacity);
807 if (NDalicPINVOKE.SWIGPendingException.Pending)
808 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
811 internal float GetCurrentOpacity()
813 float ret = Interop.ActorInternal.GetCurrentOpacity(SwigCPtr);
814 if (NDalicPINVOKE.SWIGPendingException.Pending)
815 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
819 internal Vector4 GetCurrentColor()
821 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentColor(SwigCPtr), true);
822 if (NDalicPINVOKE.SWIGPendingException.Pending)
823 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
826 internal ColorMode GetColorMode()
828 ColorMode ret = (ColorMode)Interop.ActorInternal.GetColorMode(SwigCPtr);
829 if (NDalicPINVOKE.SWIGPendingException.Pending)
830 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
834 internal Vector4 GetCurrentWorldColor()
836 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentWorldColor(SwigCPtr), true);
837 if (NDalicPINVOKE.SWIGPendingException.Pending)
838 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
842 internal void SetDrawMode(DrawModeType drawMode)
844 Interop.ActorInternal.SetDrawMode(SwigCPtr, (int)drawMode);
845 if (NDalicPINVOKE.SWIGPendingException.Pending)
846 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
849 internal DrawModeType GetDrawMode()
851 DrawModeType ret = (DrawModeType)Interop.ActorInternal.GetDrawMode(SwigCPtr);
852 if (NDalicPINVOKE.SWIGPendingException.Pending)
853 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
857 internal void SetKeyboardFocusable(bool focusable)
859 Interop.ActorInternal.SetKeyboardFocusable(SwigCPtr, focusable);
860 if (NDalicPINVOKE.SWIGPendingException.Pending)
861 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
864 internal bool IsKeyboardFocusable()
866 bool ret = Interop.ActorInternal.IsKeyboardFocusable(SwigCPtr);
867 if (NDalicPINVOKE.SWIGPendingException.Pending)
868 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
872 internal void SetKeyboardFocusableChildren(bool focusable)
874 Interop.ActorInternal.SetKeyboardFocusableChildren(SwigCPtr, focusable);
875 if (NDalicPINVOKE.SWIGPendingException.Pending)
876 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
879 internal bool AreChildrenKeyBoardFocusable()
881 bool ret = Interop.ActorInternal.AreChildrenKeyBoardFocusable(SwigCPtr);
882 if (NDalicPINVOKE.SWIGPendingException.Pending)
883 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
887 internal void SetFocusableInTouch(bool enabled)
889 Interop.ActorInternal.SetFocusableInTouch(SwigCPtr, enabled);
890 if (NDalicPINVOKE.SWIGPendingException.Pending)
891 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
894 internal bool IsFocusableInTouch()
896 bool ret = Interop.ActorInternal.IsFocusableInTouch(SwigCPtr);
897 if (NDalicPINVOKE.SWIGPendingException.Pending)
898 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
902 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
904 Interop.Actor.SetResizePolicy(SwigCPtr, (int)policy, (int)dimension);
905 if (NDalicPINVOKE.SWIGPendingException.Pending)
906 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
909 internal ResizePolicyType GetResizePolicy(DimensionType dimension)
911 ResizePolicyType ret = (ResizePolicyType)Interop.Actor.GetResizePolicy(SwigCPtr, (int)dimension);
912 if (NDalicPINVOKE.SWIGPendingException.Pending)
913 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
917 internal Vector3 GetSizeModeFactor()
919 Vector3 ret = new Vector3(Interop.Actor.GetSizeModeFactor(SwigCPtr), true);
920 if (NDalicPINVOKE.SWIGPendingException.Pending)
921 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
925 internal void SetMinimumSize(Vector2 size)
927 Interop.ActorInternal.SetMinimumSize(SwigCPtr, Vector2.getCPtr(size));
928 if (NDalicPINVOKE.SWIGPendingException.Pending)
929 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
932 internal Vector2 GetMinimumSize()
934 Vector2 ret = new Vector2(Interop.ActorInternal.GetMinimumSize(SwigCPtr), true);
935 if (NDalicPINVOKE.SWIGPendingException.Pending)
936 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
940 internal void SetMaximumSize(Vector2 size)
942 Interop.ActorInternal.SetMaximumSize(SwigCPtr, Vector2.getCPtr(size));
943 if (NDalicPINVOKE.SWIGPendingException.Pending)
944 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
947 internal Vector2 GetMaximumSize()
949 Vector2 ret = new Vector2(Interop.ActorInternal.GetMaximumSize(SwigCPtr), true);
950 if (NDalicPINVOKE.SWIGPendingException.Pending)
951 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
955 internal int GetHierarchyDepth()
957 int ret = Interop.Actor.GetHierarchyDepth(SwigCPtr);
958 if (NDalicPINVOKE.SWIGPendingException.Pending)
959 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
963 internal uint GetRendererCount()
965 uint ret = Interop.Actor.GetRendererCount(SwigCPtr);
966 if (NDalicPINVOKE.SWIGPendingException.Pending)
967 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
971 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
973 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
976 internal bool IsTopLevelView()
978 if (GetParent() is Layer)
985 internal void SetKeyInputFocus()
987 Interop.ViewInternal.SetKeyInputFocus(SwigCPtr);
988 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
991 internal void ClearKeyInputFocus()
993 Interop.ViewInternal.ClearKeyInputFocus(SwigCPtr);
994 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
997 internal PinchGestureDetector GetPinchGestureDetector()
999 PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.GetPinchGestureDetector(SwigCPtr), true);
1000 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1004 internal PanGestureDetector GetPanGestureDetector()
1006 PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.GetPanGestureDetector(SwigCPtr), true);
1007 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1011 internal TapGestureDetector GetTapGestureDetector()
1013 TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.GetTapGestureDetector(SwigCPtr), true);
1014 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1018 internal LongPressGestureDetector GetLongPressGestureDetector()
1020 LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.GetLongPressGestureDetector(SwigCPtr), true);
1021 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1025 internal IntPtr GetPtrfromView()
1027 return (IntPtr)SwigCPtr;
1030 internal void RemoveChild(View child)
1032 // Do actual child removal
1033 Interop.Actor.Remove(SwigCPtr, View.getCPtr(child));
1034 if (NDalicPINVOKE.SWIGPendingException.Pending)
1035 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1037 Children.Remove(child);
1038 child.InternalParent = null;
1039 LayoutCount -= child.LayoutCount;
1041 RemoveChildBindableObject(child);
1043 if (ChildRemoved != null)
1045 ChildRemovedEventArgs e = new ChildRemovedEventArgs
1049 ChildRemoved(this, e);
1054 /// Removes the layout from this View.
1056 internal void ResetLayout()
1063 internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1065 return (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1068 /// TODO open as a protected level
1069 internal virtual void ApplyCornerRadius()
1071 if (backgroundExtraData == null) return;
1073 var cornerRadiusValue = backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius);
1074 var cornerRadiusPolicyValue = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1076 // Make current propertyMap
1077 PropertyMap currentPropertyMap = new PropertyMap();
1078 currentPropertyMap[Visual.Property.CornerRadius] = cornerRadiusValue;
1079 currentPropertyMap[Visual.Property.CornerRadiusPolicy] = cornerRadiusPolicyValue;
1080 var temp = new PropertyValue(currentPropertyMap);
1082 // Update corner radius properties to background and shadow by ActionUpdateProperty
1083 DoAction(View.Property.BACKGROUND, ActionUpdateProperty, temp);
1084 DoAction(View.Property.SHADOW, ActionUpdateProperty, temp);
1087 currentPropertyMap.Dispose();
1088 cornerRadiusValue.Dispose();
1089 cornerRadiusPolicyValue.Dispose();
1092 /// TODO open as a protected level
1093 internal virtual void ApplyBorderline()
1095 if (backgroundExtraData == null) return;
1097 var borderlineWidthValue = new PropertyValue(backgroundExtraData.BorderlineWidth);
1098 var borderlineColorValue = backgroundExtraData.BorderlineColor == null ? new PropertyValue(Color.Black) : new PropertyValue(backgroundExtraData.BorderlineColor);
1099 var borderlineOffsetValue = new PropertyValue(backgroundExtraData.BorderlineOffset);
1101 // Make current propertyMap
1102 PropertyMap currentPropertyMap = new PropertyMap();
1103 currentPropertyMap[Visual.Property.BorderlineWidth] = borderlineWidthValue;
1104 currentPropertyMap[Visual.Property.BorderlineColor] = borderlineColorValue;
1105 currentPropertyMap[Visual.Property.BorderlineOffset] = borderlineOffsetValue;
1106 var temp = new PropertyValue(currentPropertyMap);
1108 // Update borderline properties to background by ActionUpdateProperty
1109 DoAction(View.Property.BACKGROUND, ActionUpdateProperty, temp);
1112 currentPropertyMap.Dispose();
1113 borderlineWidthValue.Dispose();
1114 borderlineColorValue.Dispose();
1115 borderlineOffsetValue.Dispose();
1119 /// Get selector value from the triggerable selector or related property.
1121 internal Selector<T> GetSelector<T>(TriggerableSelector<T> triggerableSelector, NUI.Binding.BindableProperty relatedProperty)
1123 var selector = triggerableSelector?.Get();
1124 if (selector != null)
1129 var value = (T)GetValue(relatedProperty);
1130 return value == null ? null : new Selector<T>(value);
1133 internal void SetThemeApplied()
1135 if (themeData == null) themeData = new ThemeData();
1136 themeData.ThemeApplied = true;
1138 if (ThemeChangeSensitive && !themeData.ListeningThemeChangeEvent)
1140 themeData.ListeningThemeChangeEvent = true;
1141 ThemeManager.ThemeChangedInternal.Add(OnThemeChanged);
1146 /// you can override it to clean-up your own resources.
1148 /// <param name="type">DisposeTypes</param>
1149 /// <since_tizen> 3 </since_tizen>
1150 protected override void Dispose(DisposeTypes type)
1157 DebugFileLogging.Instance.WriteLog($"View.Dispose({type}) START");
1158 DebugFileLogging.Instance.WriteLog($"type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1161 DebugFileLogging.Instance.WriteLog($"ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1165 DebugFileLogging.Instance.WriteLog($"has no native body!");
1168 //_mergedStyle = null;
1170 internalMaximumSize?.Dispose();
1171 internalMaximumSize = null;
1172 internalMinimumSize?.Dispose();
1173 internalMinimumSize = null;
1174 internalMargin?.Dispose();
1175 internalMargin = null;
1176 internalPadding?.Dispose();
1177 internalPadding = null;
1178 internalSizeModeFactor?.Dispose();
1179 internalSizeModeFactor = null;
1180 internalCellIndex?.Dispose();
1181 internalCellIndex = null;
1182 internalBackgroundColor?.Dispose();
1183 internalBackgroundColor = null;
1184 internalColor?.Dispose();
1185 internalColor = null;
1186 internalPivotPoint?.Dispose();
1187 internalPivotPoint = null;
1188 internalPosition?.Dispose();
1189 internalPosition = null;
1190 internalPosition2D?.Dispose();
1191 internalPosition2D = null;
1192 internalScale?.Dispose();
1193 internalScale = null;
1194 internalSize?.Dispose();
1195 internalSize = null;
1196 internalSize2D?.Dispose();
1197 internalSize2D = null;
1199 if (type == DisposeTypes.Explicit)
1202 //Release your own managed resources here.
1203 //You should release all of your own disposable objects here.
1204 if (themeData != null)
1206 themeData.selectorData?.Reset(this);
1207 if (themeData.ListeningThemeChangeEvent)
1209 ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
1212 if (widthConstraint != null)
1214 widthConstraint.Remove();
1215 widthConstraint.Dispose();
1217 if (heightConstraint != null)
1219 heightConstraint.Remove();
1220 heightConstraint.Dispose();
1224 //Release your own unmanaged resources here.
1225 //You should not access any managed member here except static instance.
1226 //because the execution order of Finalizes is non-deterministic.
1228 DisConnectFromSignals();
1230 foreach (View view in Children)
1232 view.InternalParent = null;
1237 NUILog.Debug($"[Dispose] View.Dispose({type}) END");
1238 NUILog.Debug($"=============================");
1243 /// This will not be public opened.
1244 [EditorBrowsable(EditorBrowsableState.Never)]
1245 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1247 Interop.View.DeleteView(swigCPtr);
1251 /// The touch event handler for ControlState.
1252 /// Please change ControlState value by touch state if needed.
1254 /// <exception cref="ArgumentNullException"> Thrown when touch is null. </exception>
1255 [EditorBrowsable(EditorBrowsableState.Never)]
1256 protected virtual bool HandleControlStateOnTouch(Touch touch)
1260 throw new global::System.ArgumentNullException(nameof(touch));
1263 switch (touch.GetState(0))
1265 case PointStateType.Down:
1266 ControlState += ControlState.Pressed;
1268 case PointStateType.Interrupted:
1269 case PointStateType.Up:
1270 if (ControlState.Contains(ControlState.Pressed))
1272 ControlState -= ControlState.Pressed;
1281 private void DisConnectFromSignals()
1283 if (HasBody() == false)
1285 NUILog.Debug($"[Dispose] DisConnectFromSignals() No native body! No need to Disconnect Signals!");
1288 NUILog.Debug($"[Dispose] DisConnectFromSignals START");
1289 NUILog.Debug($"[Dispose] View.DisConnectFromSignals() type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1290 NUILog.Debug($"[Dispose] ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1292 if (onRelayoutEventCallback != null)
1294 NUILog.Debug($"[Dispose] onRelayoutEventCallback");
1296 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(GetBaseHandleCPtrHandleRef), false);
1297 signal?.Disconnect(onRelayoutEventCallback);
1298 onRelayoutEventCallback = null;
1301 if (offWindowEventCallback != null)
1303 NUILog.Debug($"[Dispose] offWindowEventCallback");
1305 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(GetBaseHandleCPtrHandleRef), false);
1306 signal?.Disconnect(offWindowEventCallback);
1307 offWindowEventCallback = null;
1310 if (onWindowEventCallback != null)
1312 NUILog.Debug($"[Dispose] onWindowEventCallback");
1314 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1315 signal?.Disconnect(onWindowEventCallback);
1316 onWindowEventCallback = null;
1319 if (wheelEventCallback != null)
1321 NUILog.Debug($"[Dispose] wheelEventCallback");
1323 using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(GetBaseHandleCPtrHandleRef), false);
1324 signal?.Disconnect(wheelEventCallback);
1325 wheelEventCallback = null;
1328 if (hoverEventCallback != null)
1330 NUILog.Debug($"[Dispose] hoverEventCallback");
1332 using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(GetBaseHandleCPtrHandleRef), false);
1333 signal?.Disconnect(hoverEventCallback);
1334 hoverEventCallback = null;
1337 if (interceptTouchDataCallback != null)
1339 NUILog.Debug($"[Dispose] interceptTouchDataCallback");
1341 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(GetBaseHandleCPtrHandleRef), false);
1342 signal?.Disconnect(interceptTouchDataCallback);
1343 interceptTouchDataCallback = null;
1346 if (touchDataCallback != null)
1348 NUILog.Debug($"[Dispose] touchDataCallback");
1350 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(GetBaseHandleCPtrHandleRef), false);
1351 signal?.Disconnect(touchDataCallback);
1352 touchDataCallback = null;
1355 if (ResourcesLoadedCallback != null)
1357 NUILog.Debug($"[Dispose] ResourcesLoadedCallback");
1359 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1360 signal?.Disconnect(ResourcesLoadedCallback);
1361 ResourcesLoadedCallback = null;
1364 if (keyCallback != null)
1366 NUILog.Debug($"[Dispose] keyCallback");
1368 using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(GetBaseHandleCPtrHandleRef), false);
1369 signal?.Disconnect(keyCallback);
1373 if (keyInputFocusLostCallback != null)
1375 NUILog.Debug($"[Dispose] keyInputFocusLostCallback");
1377 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(GetBaseHandleCPtrHandleRef), false);
1378 signal?.Disconnect(keyInputFocusLostCallback);
1379 keyInputFocusLostCallback = null;
1380 keyInputFocusLostEventHandler = null;
1383 if (keyInputFocusGainedCallback != null)
1385 NUILog.Debug($"[Dispose] keyInputFocusGainedCallback");
1387 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(GetBaseHandleCPtrHandleRef), false);
1388 signal?.Disconnect(keyInputFocusGainedCallback);
1389 keyInputFocusGainedCallback = null;
1390 keyInputFocusGainedEventHandler = null;
1393 if (backgroundResourceLoadedCallback != null)
1395 NUILog.Debug($"[Dispose] backgroundResourceLoadedCallback");
1397 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1398 signal?.Disconnect(backgroundResourceLoadedCallback);
1399 backgroundResourceLoadedCallback = null;
1402 if (onWindowSendEventCallback != null)
1404 NUILog.Debug($"[Dispose] onWindowSendEventCallback");
1406 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1407 signal?.Disconnect(onWindowSendEventCallback);
1408 onWindowSendEventCallback = null;
1410 NUILog.Debug($"[Dispose] DisConnectFromSignals END");
1414 /// Apply initial style to the view.
1416 [EditorBrowsable(EditorBrowsableState.Never)]
1417 protected virtual void InitializeStyle(ViewStyle style = null)
1419 var initialStyle = ThemeManager.GetInitialStyleWithoutClone(GetType());
1422 ApplyStyle(initialStyle);
1426 var refinedStyle = style;
1427 if (style.IncludeDefaultStyle)
1429 refinedStyle = initialStyle?.Merge(style);
1431 ApplyStyle(refinedStyle);
1434 // Listen theme change event if needs.
1435 if (ThemeManager.PlatformThemeEnabled && initialStyle != null)
1441 private View ConvertIdToView(uint id)
1443 View view = GetParent()?.FindCurrentChildById(id);
1445 //If we can't find the parent's children, find in the top layer.
1448 Container parent = GetParent();
1449 while ((parent is View) && (parent != null))
1451 parent = parent.GetParent();
1452 if (parent is Layer)
1454 view = parent.FindCurrentChildById(id);
1463 private void OnScaleChanged(float x, float y, float z)
1465 Scale = new Vector3(x, y, z);
1468 private void OnBackgroundColorChanged(float r, float g, float b, float a)
1470 BackgroundColor = new Color(r, g, b, a);
1473 private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1475 Padding = new Extents(start, end, top, bottom);
1478 private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1480 Margin = new Extents(start, end, top, bottom);
1483 private void OnAnchorPointChanged(float x, float y, float z)
1485 AnchorPoint = new Position(x, y, z);
1488 private void OnCellIndexChanged(float x, float y)
1490 CellIndex = new Vector2(x, y);
1493 private void OnFlexMarginChanged(float x, float y, float z, float w)
1495 FlexMargin = new Vector4(x, y, z, w);
1498 private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1500 PaddingEX = new Extents(start, end, top, bottom);
1503 private void OnSizeModeFactorChanged(float x, float y, float z)
1505 SizeModeFactor = new Vector3(x, y, z);
1508 private bool EmptyOnTouch(object target, TouchEventArgs args)
1513 private ViewSelectorData EnsureSelectorData()
1515 if (themeData == null) themeData = new ThemeData();
1517 return themeData.selectorData ?? (themeData.selectorData = new ViewSelectorData());