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.
18 using System.Collections.Generic;
19 using System.ComponentModel;
20 using System.Runtime.InteropServices;
21 using Tizen.NUI.Binding;
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 : Container, IResourcesProvider
31 private static HashSet<BindableProperty> positionPropertyGroup = new HashSet<BindableProperty>();
32 private static HashSet<BindableProperty> sizePropertyGroup = new HashSet<BindableProperty>();
33 private static HashSet<BindableProperty> scalePropertyGroup = new HashSet<BindableProperty>();
35 internal BackgroundExtraData backgroundExtraData;
37 private bool layoutSet = false;
38 private LayoutItem layout; // Exclusive layout assigned to this View.
40 // List of transitions paired with the condition that uses the transition.
41 private Dictionary<TransitionCondition, TransitionList> layoutTransitions;
42 private int widthPolicy = LayoutParamPolicies.WrapContent; // Layout width policy
43 private int heightPolicy = LayoutParamPolicies.WrapContent; // Layout height policy
44 private float weight = 0.0f; // Weighting of child View in a Layout
45 private bool backgroundImageSynchronousLoading = false;
46 private bool excludeLayouting = false;
47 private LayoutTransition layoutTransition;
48 private TransitionOptions transitionOptions = null;
49 private ThemeData themeData;
51 // List of constraints
52 private Constraint widthConstraint = null;
53 private Constraint heightConstraint = null;
55 private Size2D internalMaximumSize = null;
56 private Size2D internalMinimumSize = null;
57 private Extents internalMargin = null;
58 private Extents internalPadding = null;
59 private Vector3 internalSizeModeFactor = null;
60 private Vector2 internalCellIndex = null;
61 private Color internalBackgroundColor = null;
62 private Color internalColor = null;
63 private Position internalPivotPoint = null;
64 private Position internalPosition = null;
65 private Position2D internalPosition2D = null;
66 private Vector3 internalScale = null;
67 private Size internalSize = null;
68 private Size2D internalSize2D = null;
72 RegisterPropertyGroup(PositionProperty, positionPropertyGroup);
73 RegisterPropertyGroup(Position2DProperty, positionPropertyGroup);
74 RegisterPropertyGroup(PositionXProperty, positionPropertyGroup);
75 RegisterPropertyGroup(PositionYProperty, positionPropertyGroup);
77 RegisterPropertyGroup(SizeProperty, sizePropertyGroup);
78 RegisterPropertyGroup(Size2DProperty, sizePropertyGroup);
79 RegisterPropertyGroup(SizeWidthProperty, sizePropertyGroup);
80 RegisterPropertyGroup(SizeHeightProperty, sizePropertyGroup);
82 RegisterPropertyGroup(ScaleProperty, scalePropertyGroup);
83 RegisterPropertyGroup(ScaleXProperty, scalePropertyGroup);
84 RegisterPropertyGroup(ScaleYProperty, scalePropertyGroup);
85 RegisterPropertyGroup(ScaleZProperty, scalePropertyGroup);
89 /// Creates a new instance of a view.
91 /// <since_tizen> 3 </since_tizen>
92 public View() : this(Interop.View.New(), true)
94 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
97 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
98 [EditorBrowsable(EditorBrowsableState.Never)]
99 public View(ViewStyle viewStyle) : this(Interop.View.New(), true, viewStyle)
104 /// Create a new instance of a View with setting the status of shown or hidden.
106 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
107 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
108 [EditorBrowsable(EditorBrowsableState.Never)]
109 public View(bool shown) : this(Interop.View.New(), true)
111 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115 internal View(View uiControl, bool shown = true) : this(Interop.View.NewView(View.getCPtr(uiControl)), true)
117 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
123 backgroundExtraData = uiControl.backgroundExtraData == null ? null : new BackgroundExtraData(uiControl.backgroundExtraData);
126 internal View(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : this(cPtr, cMemoryOwn, shown)
128 InitializeStyle(viewStyle);
131 internal View(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(cPtr, cMemoryOwn)
135 PositionUsesPivotPoint = false;
138 onWindowSendEventCallback = SendViewAddedEventToWindow;
139 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
140 signal?.Connect(onWindowSendEventCallback);
148 internal View(ViewImpl implementation, bool shown = true) : this(Interop.View.NewViewInternal(ViewImpl.getCPtr(implementation)), true)
150 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
159 /// The event that is triggered when the View's ControlState is changed.
161 [EditorBrowsable(EditorBrowsableState.Never)]
162 public event EventHandler<ControlStateChangedEventArgs> ControlStateChangedEvent;
164 internal event EventHandler<ControlStateChangedEventArgs> ControlStateChangeEventInternal;
168 /// Flag to indicate if layout set explicitly via API call or View was automatically given a Layout.
170 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
171 [EditorBrowsable(EditorBrowsableState.Never)]
172 public bool LayoutSet
181 /// Flag to allow Layouting to be disabled for Views.
182 /// Once a View has a Layout set then any children added to Views from then on will receive
183 /// automatic Layouts.
185 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
186 [EditorBrowsable(EditorBrowsableState.Never)]
187 public static bool LayoutingDisabled { get; set; } = true;
190 /// Deprecate. Please do not use this.
191 /// The style instance applied to this view.
192 /// Note that please do not modify the ViewStyle.
193 /// Modifying ViewStyle will affect other views with same ViewStyle.
195 [EditorBrowsable(EditorBrowsableState.Never)]
196 protected ViewStyle ViewStyle
200 if (themeData == null) themeData = new ThemeData();
202 if (themeData.viewStyle == null)
204 ApplyStyle(CreateViewStyle());
206 return themeData.viewStyle;
211 /// Get/Set the control state.
212 /// Note that the ControlState only available for the classes derived from Control.
213 /// If the classes that are not derived from Control (such as View, ImageView and TextLabel) want to use this system,
214 /// please set <see cref="EnableControlState"/> to true.
216 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
217 [EditorBrowsable(EditorBrowsableState.Never)]
218 public ControlState ControlState
222 return themeData == null ? ControlState.Normal : themeData.controlStates;
226 if (ControlState == value)
231 var prevState = ControlState;
233 if (themeData == null) themeData = new ThemeData();
234 themeData.controlStates = value;
236 var changeInfo = new ControlStateChangedEventArgs(prevState, value);
238 ControlStateChangeEventInternal?.Invoke(this, changeInfo);
240 if (themeData.ControlStatePropagation)
242 foreach (View child in Children)
244 child.ControlState = value;
248 OnControlStateChanged(changeInfo);
250 ControlStateChangedEvent?.Invoke(this, changeInfo);
255 /// Gets / Sets the status of whether the view is excluded from its parent's layouting or not.
257 /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
258 [EditorBrowsable(EditorBrowsableState.Never)]
259 public bool ExcludeLayouting
263 return (bool)GetValue(ExcludeLayoutingProperty);
267 SetValue(ExcludeLayoutingProperty, value);
268 NotifyPropertyChanged();
272 private bool InternalExcludeLayouting
276 return excludeLayouting;
280 excludeLayouting = value;
281 if (Layout != null && Layout.SetPositionByLayout == value)
283 Layout.SetPositionByLayout = !value;
284 Layout.RequestLayout();
289 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
290 [EditorBrowsable(EditorBrowsableState.Never)]
291 public bool IsResourcesCreated
295 return Application.Current.IsResourcesCreated;
299 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
300 [EditorBrowsable(EditorBrowsableState.Never)]
301 public ResourceDictionary XamlResources
305 return Application.Current.XamlResources;
309 Application.Current.XamlResources = value;
314 /// The StyleName, type string.
315 /// The value indicates DALi style name defined in json theme file.
317 /// <since_tizen> 3 </since_tizen>
318 public string StyleName
322 return (string)GetValue(StyleNameProperty);
326 SetValue(StyleNameProperty, value);
327 NotifyPropertyChanged();
332 /// The KeyInputFocus, type bool.
334 [EditorBrowsable(EditorBrowsableState.Never)]
335 public bool KeyInputFocus
339 return (bool)GetValue(KeyInputFocusProperty);
343 SetValue(KeyInputFocusProperty, value);
344 NotifyPropertyChanged();
349 /// The mutually exclusive with "backgroundImage" and "background" type Vector4.
353 /// The property cascade chaining set is not recommended.
356 /// Animatable - This property can be animated using <c>Animation</c> class.
358 /// animation.AnimateTo(view, "BackgroundColor", new Color(r, g, b, a));
363 /// This way is recommended for setting the property
365 /// var view = new View();
366 /// view.BackgroundColor = new Color(0.5f, 0.1f, 0, 1);
368 /// This way to set the property is prohibited
370 /// view.BackgroundColor.R = 0.5f; //This does not guarantee a proper operation
373 /// <since_tizen> 3 </since_tizen>
374 public Color BackgroundColor
378 return (Color)GetValue(BackgroundColorProperty);
382 SetValue(BackgroundColorProperty, value);
383 NotifyPropertyChanged();
388 /// The mutually exclusive with "backgroundColor" and "background" type Map.
390 /// <since_tizen> 3 </since_tizen>
391 public string BackgroundImage
395 return (string)GetValue(BackgroundImageProperty);
399 SetValue(BackgroundImageProperty, value);
400 NotifyPropertyChanged();
405 /// Get or set the border of background image.
407 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
408 [EditorBrowsable(EditorBrowsableState.Never)]
409 public Rectangle BackgroundImageBorder
413 return (Rectangle)GetValue(BackgroundImageBorderProperty);
417 SetValue(BackgroundImageBorderProperty, value);
418 NotifyPropertyChanged();
423 /// The background of view.
425 /// <since_tizen> 3 </since_tizen>
426 public Tizen.NUI.PropertyMap Background
430 return (PropertyMap)GetValue(BackgroundProperty);
434 SetValue(BackgroundProperty, value);
435 NotifyPropertyChanged();
440 /// Describes a shadow as an image for a View.
441 /// It is null by default.
444 /// Getter returns copied instance of current shadow.
447 /// The mutually exclusive with "BoxShadow".
451 /// Animatable - This property can be animated using <c>Animation</c> class.
452 /// To animate this property, specify a sub-property with separator ".", for example, "ImageShadow.Offset".
454 /// animation.AnimateTo(view, "ImageShadow.Offset", new Vector2(10, 10));
456 /// Animatable sub-property : Offset.
459 [EditorBrowsable(EditorBrowsableState.Never)]
460 public ImageShadow ImageShadow
464 return (ImageShadow)GetValue(ImageShadowProperty);
468 SetValue(ImageShadowProperty, value);
469 NotifyPropertyChanged();
474 /// Describes a box shaped shadow drawing for a View.
475 /// It is null by default.
478 /// The mutually exclusive with "ImageShadow".
482 /// Animatable - This property can be animated using <c>Animation</c> class.
483 /// To animate this property, specify a sub-property with separator ".", for example, "BoxShadow.BlurRadius".
485 /// animation.AnimateTo(view, "BoxShadow.BlurRadius", 10.0f);
487 /// Animatable sub-property : Offset, Color, BlurRadius.
490 /// <since_tizen> 9 </since_tizen>
491 public Shadow BoxShadow
495 return (Shadow)GetValue(BoxShadowProperty);
499 SetValue(BoxShadowProperty, value);
500 NotifyPropertyChanged();
505 /// The radius for the rounded corners of the View.
506 /// This will rounds background and shadow edges.
507 /// The values in Vector4 are used in clockwise order from top-left to bottom-left : Vector4(top-left-corner, top-right-corner, bottom-right-corner, bottom-left-corner).
508 /// Each radius will clamp internally to the half of smaller of the view's width or height.
509 /// Note that, an image background (or shadow) may not have rounded corners if it uses a Border property.
513 /// Animatable - This property can be animated using <c>Animation</c> class.
515 /// animation.AnimateTo(view, "CornerRadius", new Vector4(10, 10, 10, 10));
519 /// <since_tizen> 9 </since_tizen>
520 public Vector4 CornerRadius
524 return (Vector4)GetValue(CornerRadiusProperty);
528 SetValue(CornerRadiusProperty, value);
529 NotifyPropertyChanged();
534 /// Whether the CornerRadius property value is relative (percentage [0.0f to 0.5f] of the view size) or absolute (in world units).
535 /// It is absolute by default.
536 /// When the policy is relative, the corner radius is relative to the smaller of the view's width and height.
538 /// <since_tizen> 9 </since_tizen>
539 public VisualTransformPolicyType CornerRadiusPolicy
541 get => (VisualTransformPolicyType)GetValue(CornerRadiusPolicyProperty);
542 set => SetValue(CornerRadiusPolicyProperty, value);
546 /// The width for the borderline of the View.
550 /// Animatable - This property can be animated using <c>Animation</c> class.
552 /// animation.AnimateTo(view, "BorderlineWidth", 100.0f);
555 /// Note that, an image background may not have borderline if it uses the Border property.
557 /// <since_tizen> 9 </since_tizen>
558 public float BorderlineWidth
562 return (float)GetValue(BorderlineWidthProperty);
566 SetValue(BorderlineWidthProperty, value);
567 NotifyPropertyChanged();
572 /// The color for the borderline of the View.
573 /// It is Color.Black by default.
577 /// Animatable - This property can be animated using <c>Animation</c> class.
579 /// animation.AnimateTo(view, "BorderlineColor", new Color(r, g, b, a));
583 /// <since_tizen> 9 </since_tizen>
584 public Color BorderlineColor
588 return (Color)GetValue(BorderlineColorProperty);
592 SetValue(BorderlineColorProperty, value);
593 NotifyPropertyChanged();
598 /// The Relative offset for the borderline of the View.
599 /// Recommended range : [-1.0f to 1.0f].
600 /// If -1.0f, draw borderline inside of the View.
601 /// If 1.0f, draw borderline outside of the View.
602 /// If 0.0f, draw borderline half inside and half outside.
603 /// It is 0.0f by default.
607 /// Animatable - This property can be animated using <c>Animation</c> class.
609 /// animation.AnimateTo(view, "BorderlineOffset", -1.0f);
613 /// <since_tizen> 9 </since_tizen>
614 public float BorderlineOffset
618 return (float)GetValue(BorderlineOffsetProperty);
622 SetValue(BorderlineOffsetProperty, value);
623 NotifyPropertyChanged();
628 /// The current state of the view.
630 /// <since_tizen> 3 </since_tizen>
635 return (States)GetValue(StateProperty);
639 SetValue(StateProperty, value);
640 NotifyPropertyChanged();
645 /// The current sub state of the view.
647 /// <since_tizen> 3 </since_tizen>
648 public States SubState
652 return (States)GetValue(SubStateProperty);
656 SetValue(SubStateProperty, value);
657 NotifyPropertyChanged();
662 /// Displays a tooltip
664 /// <since_tizen> 3 </since_tizen>
665 public Tizen.NUI.PropertyMap Tooltip
669 return (PropertyMap)GetValue(TooltipProperty);
673 SetValue(TooltipProperty, value);
674 NotifyPropertyChanged();
679 /// Displays a tooltip as a text.
681 /// <since_tizen> 3 </since_tizen>
682 public string TooltipText
686 return GetValue(TooltipTextProperty) as string;
690 SetValue(TooltipTextProperty, value);
694 private string InternalTooltipText
698 using (var propertyValue = GetProperty(Property.TOOLTIP))
700 if (propertyValue != null && propertyValue.Get(out string retrivedValue))
702 return retrivedValue;
704 NUILog.Error($"[ERROR] Fail to get TooltipText! Return error MSG (error to get TooltipText)!");
705 return "error to get TooltipText";
710 var temp = new Tizen.NUI.PropertyValue(value);
711 SetProperty(View.Property.TOOLTIP, temp);
713 NotifyPropertyChanged();
718 /// The Child property of FlexContainer.<br />
719 /// The proportion of the free space in the container, the flex item will receive.<br />
720 /// If all items in the container set this property, their sizes will be proportional to the specified flex factor.<br />
722 /// <since_tizen> 3 </since_tizen>
723 [Obsolete("Deprecated in API8, will be removed in API10.")]
728 return (float)GetValue(FlexProperty);
732 SetValue(FlexProperty, value);
733 NotifyPropertyChanged();
738 /// The Child property of FlexContainer.<br />
739 /// The alignment of the flex item along the cross axis, which, if set, overrides the default alignment for all items in the container.<br />
741 /// <since_tizen> 3 </since_tizen>
742 [Obsolete("Deprecated in API8, will be removed in API10.")]
747 return (int)GetValue(AlignSelfProperty);
751 SetValue(AlignSelfProperty, value);
752 NotifyPropertyChanged();
757 /// The Child property of FlexContainer.<br />
758 /// The space around the flex item.<br />
761 /// The property cascade chaining set is possible. For example, this (view.FlexMargin.X = 0.1f;) is possible.
763 /// <since_tizen> 3 </since_tizen>
764 [Obsolete("Deprecated in API8, will be removed in API10.")]
765 public Vector4 FlexMargin
769 Vector4 temp = (Vector4)GetValue(FlexMarginProperty);
770 return new Vector4(OnFlexMarginChanged, temp.X, temp.Y, temp.Z, temp.W);
774 SetValue(FlexMarginProperty, value);
775 NotifyPropertyChanged();
780 /// The top-left cell this child occupies, if not set, the first available cell is used.
783 /// The property cascade chaining set is not recommended.
784 /// Also, this property is for <see cref="TableView"/> class. Please use the property for the child position of <see cref="TableView"/>.
787 /// This way is recommended for setting the property
789 /// var view = new View();
790 /// view.CellIndex = new Vector2(1, 3);
792 /// This way to set the property is prohibited
794 /// view.CellIndex.X = 1; //This does not guarantee a proper operation
797 /// <since_tizen> 3 </since_tizen>
798 public Vector2 CellIndex
802 return (Vector2)GetValue(CellIndexProperty);
806 SetValue(CellIndexProperty, value);
807 NotifyPropertyChanged();
812 /// The number of rows this child occupies, if not set, the default value is 1.
815 /// This property is for <see cref="TableView"/> class. Please use the property for the child position of <see cref="TableView"/>.
817 /// <since_tizen> 3 </since_tizen>
822 return (float)GetValue(RowSpanProperty);
826 SetValue(RowSpanProperty, value);
827 NotifyPropertyChanged();
832 /// The number of columns this child occupies, if not set, the default value is 1.
835 /// This property is for <see cref="TableView"/> class. Please use the property for the child position of <see cref="TableView"/>.
837 /// <since_tizen> 3 </since_tizen>
838 public float ColumnSpan
842 return (float)GetValue(ColumnSpanProperty);
846 SetValue(ColumnSpanProperty, value);
847 NotifyPropertyChanged();
852 /// The horizontal alignment of this child inside the cells, if not set, the default value is 'left'.
855 /// This property is for <see cref="TableView"/> class. Please use the property for the child position of <see cref="TableView"/>.
857 /// <since_tizen> 3 </since_tizen>
858 public Tizen.NUI.HorizontalAlignmentType CellHorizontalAlignment
862 return (HorizontalAlignmentType)GetValue(CellHorizontalAlignmentProperty);
866 SetValue(CellHorizontalAlignmentProperty, value);
867 NotifyPropertyChanged();
872 /// The vertical alignment of this child inside the cells, if not set, the default value is 'top'.
875 /// This property is for <see cref="TableView"/> class. Please use the property for the child position of <see cref="TableView"/>.
877 /// <since_tizen> 3 </since_tizen>
878 public Tizen.NUI.VerticalAlignmentType CellVerticalAlignment
882 return (VerticalAlignmentType)GetValue(CellVerticalAlignmentProperty);
886 SetValue(CellVerticalAlignmentProperty, value);
887 NotifyPropertyChanged();
892 /// The left focusable view.<br />
893 /// This will return null if not set.<br />
894 /// This will also return null if the specified left focusable view is not on a window.<br />
896 /// <since_tizen> 3 </since_tizen>
897 public View LeftFocusableView
899 // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
902 return (View)GetValue(LeftFocusableViewProperty);
906 SetValue(LeftFocusableViewProperty, value);
907 NotifyPropertyChanged();
912 /// The right focusable view.<br />
913 /// This will return null if not set.<br />
914 /// This will also return null if the specified right focusable view is not on a window.<br />
916 /// <since_tizen> 3 </since_tizen>
917 public View RightFocusableView
919 // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
922 return (View)GetValue(RightFocusableViewProperty);
926 SetValue(RightFocusableViewProperty, value);
927 NotifyPropertyChanged();
932 /// The up focusable view.<br />
933 /// This will return null if not set.<br />
934 /// This will also return null if the specified up focusable view is not on a window.<br />
936 /// <since_tizen> 3 </since_tizen>
937 public View UpFocusableView
939 // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
942 return (View)GetValue(UpFocusableViewProperty);
946 SetValue(UpFocusableViewProperty, value);
947 NotifyPropertyChanged();
952 /// The down focusable view.<br />
953 /// This will return null if not set.<br />
954 /// This will also return null if the specified down focusable view is not on a window.<br />
956 /// <since_tizen> 3 </since_tizen>
957 public View DownFocusableView
959 // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
962 return (View)GetValue(DownFocusableViewProperty);
966 SetValue(DownFocusableViewProperty, value);
967 NotifyPropertyChanged();
972 /// Whether the view should be focusable by keyboard navigation.
974 /// <since_tizen> 3 </since_tizen>
975 public bool Focusable
979 SetValue(FocusableProperty, value);
980 NotifyPropertyChanged();
984 return (bool)GetValue(FocusableProperty);
989 /// Whether the children of this view can be focusable by keyboard navigation. If user sets this to false, the children of this actor view will not be focused.
990 /// Note : Default value is true.
992 [EditorBrowsable(EditorBrowsableState.Never)]
993 public bool FocusableChildren
997 SetValue(FocusableChildrenProperty, value);
998 NotifyPropertyChanged();
1002 return (bool)GetValue(FocusableChildrenProperty);
1007 /// Whether this view can focus by touch.
1008 /// If Focusable is false, FocusableInTouch is disabled.
1009 /// If you want to have focus on touch, you need to set both Focusable and FocusableInTouch settings to true.
1011 [EditorBrowsable(EditorBrowsableState.Never)]
1012 public bool FocusableInTouch
1016 SetValue(FocusableInTouchProperty, value);
1017 NotifyPropertyChanged();
1021 return (bool)GetValue(FocusableInTouchProperty);
1026 /// Retrieves the position of the view.<br />
1027 /// The coordinates are relative to the view's parent.<br />
1029 /// <since_tizen> 3 </since_tizen>
1030 public Position CurrentPosition
1034 return GetCurrentPosition();
1039 /// Sets the size of a view for the width and the height.<br />
1040 /// Geometry can be scaled to fit within this area.<br />
1041 /// This does not interfere with the view's scale factor.<br />
1042 /// The views default depth is the minimum of width and height.<br />
1045 /// The property cascade chaining set is not recommended.
1048 /// This way is recommended for setting the property
1050 /// var view = new View();
1051 /// view.Size2D = new Size2D(100, 200);
1053 /// This way to set the property is prohibited
1055 /// view.Size2D.Width = 100; //This does not guarantee a proper operation
1058 /// <since_tizen> 3 </since_tizen>
1059 public Size2D Size2D
1063 var temp = (Size2D)GetValue(Size2DProperty);
1065 if (this.Layout == null)
1067 if (temp.Width < 0) { temp.Width = 0; }
1068 if (temp.Height < 0) { temp.Height = 0; }
1075 SetValue(Size2DProperty, value);
1077 NotifyPropertyChanged();
1082 /// Retrieves the size of the view.<br />
1083 /// The coordinates are relative to the view's parent.<br />
1085 /// <since_tizen> 3 </since_tizen>
1086 public Size2D CurrentSize
1090 return GetCurrentSize();
1095 /// Retrieves and sets the view's opacity.<br />
1099 /// Animatable - This property can be animated using <c>Animation</c> class.
1101 /// animation.AnimateTo(view, "Opacity", 0.5f);
1105 /// <since_tizen> 3 </since_tizen>
1106 public float Opacity
1110 return (float)GetValue(OpacityProperty);
1114 SetValue(OpacityProperty, value);
1115 NotifyPropertyChanged();
1120 /// Sets the position of the view for X and Y.<br />
1121 /// By default, sets the position vector between the parent origin and the pivot point (default).<br />
1122 /// If the position inheritance is disabled, sets the world position.<br />
1125 /// The property cascade chaining set is not recommended.
1128 /// This way is recommended for setting the property
1130 /// var view = new View();
1131 /// view.Position2D = new Position2D(100, 200);
1133 /// This way to set the property is prohibited
1135 /// view.Position2D.X = 100; //This does not guarantee a proper operation
1138 /// <since_tizen> 3 </since_tizen>
1139 public Position2D Position2D
1143 return (Position2D)GetValue(Position2DProperty);
1147 SetValue(Position2DProperty, value);
1148 NotifyPropertyChanged();
1153 /// Retrieves the screen position of the view.<br />
1155 /// <since_tizen> 3 </since_tizen>
1156 public Vector2 ScreenPosition
1160 Vector2 temp = new Vector2(0.0f, 0.0f);
1161 var pValue = GetProperty(View.Property.ScreenPosition);
1169 /// Determines whether the pivot point should be used to determine the position of the view.
1170 /// This is false by default.
1172 /// <remarks>If false, then the top-left of the view is used for the position.
1173 /// Setting this to false will allow scaling or rotation around the pivot point without affecting the view's position.
1175 /// <since_tizen> 3 </since_tizen>
1176 public bool PositionUsesPivotPoint
1180 return (bool)GetValue(PositionUsesPivotPointProperty);
1184 SetValue(PositionUsesPivotPointProperty, value);
1185 NotifyPropertyChanged();
1190 /// Deprecated in API5; Will be removed in API8. Please use PositionUsesPivotPoint instead!
1192 /// <since_tizen> 3 </since_tizen>
1193 [Obsolete("Deprecated in API5; Will be removed in API8. Please use PositionUsesPivotPoint instead! " +
1195 "View view = new View(); " +
1196 "view.PivotPoint = PivotPoint.Center; " +
1197 "view.PositionUsesPivotPoint = true;" +
1198 " Deprecated in API5: Will be removed in API8")]
1199 [EditorBrowsable(EditorBrowsableState.Never)]
1200 public bool PositionUsesAnchorPoint
1204 return (bool)GetValue(PositionUsesAnchorPointProperty);
1208 SetValue(PositionUsesAnchorPointProperty, value);
1212 private bool InternalPositionUsesAnchorPoint
1217 var pValue = GetProperty(View.Property.PositionUsesAnchorPoint);
1218 pValue.Get(out temp);
1224 var temp = new Tizen.NUI.PropertyValue(value);
1225 SetProperty(View.Property.PositionUsesAnchorPoint, temp);
1227 NotifyPropertyChanged();
1232 /// Queries whether the view is connected to the stage.<br />
1233 /// When a view is connected, it will be directly or indirectly parented to the root view.<br />
1235 /// <since_tizen> 3 </since_tizen>
1236 public bool IsOnWindow
1245 /// Gets the depth in the hierarchy for the view.
1247 /// <since_tizen> 3 </since_tizen>
1248 public int HierarchyDepth
1252 return GetHierarchyDepth();
1257 /// Sets the sibling order of the view so the depth position can be defined within the same parent.
1260 /// Note the initial value is 0. SiblingOrder should be bigger than 0 or equal to 0.
1261 /// Raise, Lower, RaiseToTop, LowerToBottom, RaiseAbove, and LowerBelow will override the sibling order.
1262 /// The values set by this property will likely change.
1264 /// <since_tizen> 3 </since_tizen>
1265 public int SiblingOrder
1269 return (int)GetValue(SiblingOrderProperty);
1273 SetValue(SiblingOrderProperty, value);
1275 Layout?.ChangeLayoutSiblingOrder(value);
1277 NotifyPropertyChanged();
1282 /// Returns the natural size of the view.
1285 /// Deriving classes stipulate the natural size and by default a view has a zero natural size.
1287 /// <since_tizen> 5 </since_tizen>
1288 public Vector3 NaturalSize
1292 Vector3 ret = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
1293 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
1299 /// Returns the natural size (Size2D) of the view.
1302 /// Deriving classes stipulate the natural size and by default a view has a zero natural size.
1304 /// <since_tizen> 4 </since_tizen>
1305 public Size2D NaturalSize2D
1309 Vector3 temp = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
1310 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
1312 Size2D sz = new Size2D((int)temp.Width, (int)temp.Height);
1319 /// Gets or sets the origin of a view within its parent's area.<br />
1320 /// This is expressed in unit coordinates, such that (0.0, 0.0, 0.5) is the top-left corner of the parent, and (1.0, 1.0, 0.5) is the bottom-right corner.<br />
1321 /// The default parent-origin is ParentOrigin.TopLeft (0.0, 0.0, 0.5).<br />
1322 /// A view's position is the distance between this origin and the view's anchor-point.<br />
1324 /// <pre>The view has been initialized.</pre>
1325 /// <since_tizen> 3 </since_tizen>
1326 public Position ParentOrigin
1330 Position tmp = (Position)GetValue(ParentOriginProperty);
1331 return new Position(OnParentOriginChanged, tmp.X, tmp.Y, tmp.Z);
1335 SetValue(ParentOriginProperty, value);
1336 NotifyPropertyChanged();
1341 /// Gets or sets the anchor-point of a view.<br />
1342 /// This is expressed in unit coordinates, such that (0.0, 0.0, 0.5) is the top-left corner of the view, and (1.0, 1.0, 0.5) is the bottom-right corner.<br />
1343 /// The default pivot point is PivotPoint.Center (0.5, 0.5, 0.5).<br />
1344 /// A view position is the distance between its parent-origin and this anchor-point.<br />
1345 /// A view's orientation is the rotation from its default orientation, the rotation is centered around its anchor-point.<br />
1346 /// <pre>The view has been initialized.</pre>
1349 /// The property cascade chaining set is not recommended.
1352 /// This way is recommended for setting the property
1354 /// var view = new View();
1355 /// view.PivotPoint = PivotPoint.Center;
1357 /// This way to set the property is prohibited
1359 /// view.PivotPoint.X = 0.5f; //This does not guarantee a proper operation
1362 /// <since_tizen> 3 </since_tizen>
1363 public Position PivotPoint
1367 return (Position)GetValue(PivotPointProperty);
1371 SetValue(PivotPointProperty, value);
1372 NotifyPropertyChanged();
1377 /// Gets or sets the size width of the view.
1381 /// Animatable - This property can be animated using <c>Animation</c> class.
1383 /// animation.AnimateTo(view, "SizeWidth", 500.0f);
1387 /// <since_tizen> 3 </since_tizen>
1388 public float SizeWidth
1392 return (float)GetValue(SizeWidthProperty);
1396 SetValue(SizeWidthProperty, value);
1397 NotifyPropertyChanged();
1402 /// Gets or sets the size height of the view.
1406 /// Animatable - This property can be animated using <c>Animation</c> class.
1409 /// animation.AnimateTo(view, "SizeHeight", 500.0f);
1412 /// <since_tizen> 3 </since_tizen>
1413 public float SizeHeight
1417 return (float)GetValue(SizeHeightProperty);
1421 SetValue(SizeHeightProperty, value);
1422 NotifyPropertyChanged();
1427 /// Gets or sets the position of the view.<br />
1428 /// By default, sets the position vector between the parent origin and pivot point (default).<br />
1429 /// If the position inheritance is disabled, sets the world position.<br />
1433 /// Animatable - This property can be animated using <c>Animation</c> class.
1435 /// animation.AnimateTo(view, "Position", new Position(50, 0));
1438 /// The property cascade chaining set is not recommended.
1441 /// This way is recommended for setting the property
1443 /// var view = new View();
1444 /// view.Position = new Position(100, 200.5f, 0);
1446 /// This way to set the property is prohibited
1448 /// view.Position.Y = 200.5f; //This does not guarantee a proper operation
1451 /// <since_tizen> 3 </since_tizen>
1452 public Position Position
1456 return (Position)GetValue(PositionProperty);
1460 SetValue(PositionProperty, value);
1461 NotifyPropertyChanged();
1466 /// Gets or sets the position X of the view.
1470 /// Animatable - This property can be animated using <c>Animation</c> class.
1472 /// animation.AnimateTo(view, "PositionX", 50.0f);
1476 /// <since_tizen> 3 </since_tizen>
1477 public float PositionX
1481 return (float)GetValue(PositionXProperty);
1485 SetValue(PositionXProperty, value);
1486 NotifyPropertyChanged();
1491 /// Gets or sets the position Y of the view.
1495 /// Animatable - This property can be animated using <c>Animation</c> class.
1497 /// animation.AnimateTo(view, "PositionY", 50.0f);
1501 /// <since_tizen> 3 </since_tizen>
1502 public float PositionY
1506 return (float)GetValue(PositionYProperty);
1510 SetValue(PositionYProperty, value);
1511 NotifyPropertyChanged();
1516 /// Gets or sets the position Z of the view.
1520 /// Animatable - This property can be animated using <c>Animation</c> class.
1522 /// animation.AnimateTo(view, "PositionZ", 50.0f);
1526 /// <since_tizen> 3 </since_tizen>
1527 public float PositionZ
1531 return (float)GetValue(PositionZProperty);
1535 SetValue(PositionZProperty, value);
1536 NotifyPropertyChanged();
1541 /// Gets or sets the world position of the view.
1543 /// <since_tizen> 3 </since_tizen>
1544 public Vector3 WorldPosition
1548 Vector3 temp = new Vector3(0.0f, 0.0f, 0.0f);
1549 var pValue = GetProperty(View.Property.WorldPosition);
1557 /// Gets or sets the orientation of the view.<br />
1558 /// The view's orientation is the rotation from its default orientation, and the rotation is centered around its anchor-point.<br />
1562 /// This is an asynchronous method.
1565 /// Animatable - This property can be animated using <c>Animation</c> class.
1567 /// animation.AnimateTo(view, "Orientation", new Rotation(new Radian((float)Math.PI), Vector3.XAxis));
1571 /// <since_tizen> 3 </since_tizen>
1572 public Rotation Orientation
1576 return (Rotation)GetValue(OrientationProperty);
1580 SetValue(OrientationProperty, value);
1581 NotifyPropertyChanged();
1586 /// Gets or sets the world orientation of the view.<br />
1588 /// <since_tizen> 3 </since_tizen>
1589 public Rotation WorldOrientation
1593 Rotation temp = new Rotation();
1594 var pValue = GetProperty(View.Property.WorldOrientation);
1602 /// Gets or sets the scale factor applied to the view.<br />
1606 /// Animatable - This property can be animated using <c>Animation</c> class.
1608 /// animation.AnimateTo(view, "Scale", new Vector3(1.5f, 1.5f, 1.0f));
1611 /// The property cascade chaining set is not recommended.
1614 /// This way is recommended for setting the property
1616 /// var view = new View();
1617 /// view.Scale = new Vector3(1.5f, 2.0f, 1.0f);
1619 /// This way to set the property is prohibited
1621 /// view.Scale.Width = 1.5f; //This does not guarantee a proper operation
1624 /// <since_tizen> 3 </since_tizen>
1625 public Vector3 Scale
1629 return (Vector3)GetValue(ScaleProperty);
1633 SetValue(ScaleProperty, value);
1634 NotifyPropertyChanged();
1639 /// Gets or sets the scale X factor applied to the view.
1643 /// Animatable - This property can be animated using <c>Animation</c> class.
1645 /// animation.AnimateTo(view, "ScaleX", 1.5f);
1649 /// <since_tizen> 3 </since_tizen>
1654 return (float)GetValue(ScaleXProperty);
1658 SetValue(ScaleXProperty, value);
1659 NotifyPropertyChanged();
1664 /// Gets or sets the scale Y factor applied to the view.
1668 /// Animatable - This property can be animated using <c>Animation</c> class.
1670 /// animation.AnimateTo(view, "ScaleY", 1.5f);
1674 /// <since_tizen> 3 </since_tizen>
1679 return (float)GetValue(ScaleYProperty);
1683 SetValue(ScaleYProperty, value);
1684 NotifyPropertyChanged();
1689 /// Gets or sets the scale Z factor applied to the view.
1693 /// Animatable - This property can be animated using <c>Animation</c> class.
1695 /// animation.AnimateTo(view, "ScaleZ", 1.5f);
1699 /// <since_tizen> 3 </since_tizen>
1704 return (float)GetValue(ScaleZProperty);
1708 SetValue(ScaleZProperty, value);
1709 NotifyPropertyChanged();
1714 /// Gets the world scale of the view.
1716 /// <since_tizen> 3 </since_tizen>
1717 public Vector3 WorldScale
1721 Vector3 temp = new Vector3(0.0f, 0.0f, 0.0f);
1722 var pValue = GetProperty(View.Property.WorldScale);
1730 /// Retrieves the visibility flag of the view.
1734 /// If the view is not visible, then the view and its children will not be rendered.
1735 /// This is regardless of the individual visibility values of the children, i.e., the view will only be rendered if all of its parents have visibility set to true.
1738 /// Animatable - This property can be animated using <c>Animation</c> class.
1740 /// animation.AnimateTo(view, "Visibility", false);
1744 /// <since_tizen> 3 </since_tizen>
1745 public bool Visibility
1750 var pValue = GetProperty(View.Property.VISIBLE);
1751 pValue.Get(out temp);
1758 /// Gets the view's world color.
1760 /// <since_tizen> 3 </since_tizen>
1761 public Vector4 WorldColor
1765 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
1766 var pValue = GetProperty(View.Property.WorldColor);
1774 /// Gets or sets the view's name.
1776 /// <since_tizen> 3 </since_tizen>
1781 return (string)GetValue(NameProperty);
1785 SetValue(NameProperty, value);
1786 NotifyPropertyChanged();
1791 /// Get the number of children held by the view.
1793 /// <since_tizen> 3 </since_tizen>
1794 public new uint ChildCount
1798 return Convert.ToUInt32(Children.Count);
1803 /// Gets the view's ID.
1806 /// <since_tizen> 3 </since_tizen>
1816 /// Gets or sets the status of whether the view should emit touch or hover signals.
1817 /// If a View is made insensitive, then the View and its children are not hittable.
1819 /// <since_tizen> 3 </since_tizen>
1820 public bool Sensitive
1824 return (bool)GetValue(SensitiveProperty);
1828 SetValue(SensitiveProperty, value);
1829 NotifyPropertyChanged();
1834 /// Gets or sets the status of whether the view should receive a notification when touch or hover motion events leave the boundary of the view.
1836 /// <since_tizen> 3 </since_tizen>
1837 public bool LeaveRequired
1841 return (bool)GetValue(LeaveRequiredProperty);
1845 SetValue(LeaveRequiredProperty, value);
1846 NotifyPropertyChanged();
1851 /// Gets or sets the status of whether a child view inherits it's parent's orientation.
1853 /// <since_tizen> 3 </since_tizen>
1854 public bool InheritOrientation
1858 return (bool)GetValue(InheritOrientationProperty);
1862 SetValue(InheritOrientationProperty, value);
1863 NotifyPropertyChanged();
1868 /// Gets or sets the status of whether a child view inherits it's parent's scale.
1870 /// <since_tizen> 3 </since_tizen>
1871 public bool InheritScale
1875 return (bool)GetValue(InheritScaleProperty);
1879 SetValue(InheritScaleProperty, value);
1880 NotifyPropertyChanged();
1885 /// Gets or sets the status of how the view and its children should be drawn.<br />
1886 /// Not all views are renderable, but DrawMode can be inherited from any view.<br />
1887 /// If an object is in a 3D layer, it will be depth-tested against other objects in the world, i.e., it may be obscured if other objects are in front.<br />
1888 /// If DrawMode.Overlay2D is used, the view and its children will be drawn as a 2D overlay.<br />
1889 /// Overlay views are drawn in a separate pass, after all non-overlay views within the layer.<br />
1890 /// For overlay views, the drawing order is with respect to tree levels of views, and depth-testing will not be used.<br />
1892 /// <since_tizen> 3 </since_tizen>
1893 public DrawModeType DrawMode
1897 return (DrawModeType)GetValue(DrawModeProperty);
1901 SetValue(DrawModeProperty, value);
1902 NotifyPropertyChanged();
1907 /// Gets or sets the relative to parent size factor of the view.<br />
1908 /// This factor is only used when ResizePolicyType is set to either: ResizePolicyType.SizeRelativeToParent or ResizePolicyType.SizeFixedOffsetFromParent.<br />
1909 /// This view's size is set to the view's size multiplied by or added to this factor, depending on ResizePolicyType.<br />
1912 /// The property cascade chaining set is not recommended.
1915 /// This way is recommended for setting the property
1917 /// var text = new TextField();
1918 /// text.SizeModeFactor = new Vector3(1.0f, 0.45f, 1.0f);
1920 /// This way to set the property is prohibited
1922 /// text.SizeModeFactor.Width = 1.0f; //This does not guarantee a proper operation
1925 /// <since_tizen> 3 </since_tizen>
1926 public Vector3 SizeModeFactor
1930 return (Vector3)GetValue(SizeModeFactorProperty);
1934 SetValue(SizeModeFactorProperty, value);
1935 NotifyPropertyChanged();
1940 /// Gets or sets the width resize policy to be used.
1942 /// <since_tizen> 3 </since_tizen>
1943 public ResizePolicyType WidthResizePolicy
1947 return (ResizePolicyType)GetValue(WidthResizePolicyProperty);
1951 // Store ResizePolicy to restore it when Layout is unset.
1952 widthResizePolicy = value;
1954 SetValue(WidthResizePolicyProperty, value);
1955 NotifyPropertyChanged();
1960 /// Gets or sets the height resize policy to be used.
1962 /// <since_tizen> 3 </since_tizen>
1963 public ResizePolicyType HeightResizePolicy
1967 return (ResizePolicyType)GetValue(HeightResizePolicyProperty);
1971 // Store ResizePolicy to restore it when Layout is unset.
1972 heightResizePolicy = value;
1974 SetValue(HeightResizePolicyProperty, value);
1975 NotifyPropertyChanged();
1980 /// Gets or sets the policy to use when setting size with size negotiation.<br />
1981 /// Defaults to SizeScalePolicyType.UseSizeSet.<br />
1983 /// <since_tizen> 3 </since_tizen>
1984 public SizeScalePolicyType SizeScalePolicy
1988 return (SizeScalePolicyType)GetValue(SizeScalePolicyProperty);
1992 SetValue(SizeScalePolicyProperty, value);
1993 NotifyPropertyChanged();
1998 /// Gets or sets the status of whether the width size is dependent on the height size.
2000 /// <since_tizen> 3 </since_tizen>
2001 public bool WidthForHeight
2005 return (bool)GetValue(WidthForHeightProperty);
2009 SetValue(WidthForHeightProperty, value);
2010 NotifyPropertyChanged();
2015 /// Gets or sets the status of whether the height size is dependent on the width size.
2017 /// <since_tizen> 3 </since_tizen>
2018 public bool HeightForWidth
2022 return (bool)GetValue(HeightForWidthProperty);
2026 SetValue(HeightForWidthProperty, value);
2027 NotifyPropertyChanged();
2032 /// Gets or sets the padding for use in layout.
2035 /// The property cascade chaining set is not recommended.
2038 /// This way is recommended for setting the property
2040 /// var view = new View();
2041 /// view.Padding = new Extents(5, 5, 5, 5);
2043 /// This way to set the property is prohibited
2045 /// view.Padding.Start = 5; //This does not guarantee a proper operation
2048 /// <since_tizen> 5 </since_tizen>
2049 public Extents Padding
2053 // If View has a Layout then padding in stored in the base Layout class
2056 return Layout.Padding;
2060 return (Extents)GetValue(PaddingProperty);
2062 // Two return points to prevent creating a zeroed Extent native object before assignment
2066 Extents padding = value;
2069 // Layout set so store Padding in LayoutItem instead of in View.
2070 // If View stores the Padding value then Legacy Size Negotiation will overwrite
2071 // the position and sizes measure in the Layouting.
2072 Layout.Padding = value;
2073 // If Layout is a LayoutItem then it could be a View that handles it's own padding.
2074 // Let the View keeps it's padding. Still store Padding in Layout to reduce code paths.
2075 if (typeof(LayoutGroup).IsAssignableFrom(Layout.GetType())) // If a Layout container of some kind.
2077 padding = new Extents(0, 0, 0, 0); // Reset value stored in View.
2081 SetValue(PaddingProperty, padding);
2082 NotifyPropertyChanged();
2087 /// Gets or sets the minimum size the view can be assigned in size negotiation.
2089 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
2091 /// The property cascade chaining set is not recommended.
2094 /// This way is recommended for setting the property
2096 /// var view = new View();
2097 /// view.MinimumSize = new Size2D(100, 200);
2099 /// This way to set the property is prohibited
2101 /// view.MinimumSize.Width = 100; //This does not guarantee a proper operation
2104 /// <since_tizen> 3 </since_tizen>
2105 public Size2D MinimumSize
2109 return (Size2D)GetValue(MinimumSizeProperty);
2115 throw new ArgumentNullException(nameof(value));
2119 // Note: it only works if minimum size is >= than natural size.
2120 // To force the size it should be done through the width&height spec or Size2D.
2121 layout.MinimumWidth = new Tizen.NUI.LayoutLength(value.Width);
2122 layout.MinimumHeight = new Tizen.NUI.LayoutLength(value.Height);
2123 layout.RequestLayout();
2125 SetValue(MinimumSizeProperty, value);
2126 NotifyPropertyChanged();
2131 /// Gets or sets the maximum size the view can be assigned in size negotiation.
2134 /// This way is recommended for setting the property
2136 /// var view = new View();
2137 /// view.MaximumSize = new Size2D(100, 200);
2139 /// This way to set the property is prohibited
2141 /// view.MaximumSize.Height = 200; //This does not guarantee a proper operation
2144 /// <since_tizen> 3 </since_tizen>
2145 public Size2D MaximumSize
2149 return (Size2D)GetValue(MaximumSizeProperty);
2153 // We don't have Layout.Maximum(Width|Height) so we cannot apply it to layout.
2154 // MATCH_PARENT spec + parent container size can be used to limit
2157 layout.RequestLayout();
2159 SetValue(MaximumSizeProperty, value);
2160 NotifyPropertyChanged();
2165 /// Gets or sets whether a child view inherits it's parent's position.<br />
2166 /// Default is to inherit.<br />
2167 /// Switching this off means that using position sets the view's world position, i.e., translates from the world origin (0,0,0) to the pivot point of the view.<br />
2169 /// <since_tizen> 3 </since_tizen>
2170 public bool InheritPosition
2174 return (bool)GetValue(InheritPositionProperty);
2178 SetValue(InheritPositionProperty, value);
2179 NotifyPropertyChanged();
2184 /// Gets or sets the clipping behavior (mode) of it's children.
2186 /// <since_tizen> 3 </since_tizen>
2187 public ClippingModeType ClippingMode
2191 return (ClippingModeType)GetValue(ClippingModeProperty);
2195 SetValue(ClippingModeProperty, value);
2196 NotifyPropertyChanged();
2201 /// Gets the number of renderers held by the view.
2203 /// <since_tizen> 3 </since_tizen>
2204 public uint RendererCount
2208 return GetRendererCount();
2213 /// Deprecated in API5; Will be removed in API8. Please use PivotPoint instead!
2216 /// The property cascade chaining set is possible. For example, this (view.AnchorPoint.X = 0.1f;) is possible.
2218 /// <since_tizen> 3 </since_tizen>
2219 [Obsolete("Deprecated in API5; Will be removed in API8. Please use PivotPoint instead! " +
2221 "View view = new View(); " +
2222 "view.PivotPoint = PivotPoint.Center; " +
2223 "view.PositionUsesPivotPoint = true;")]
2224 [EditorBrowsable(EditorBrowsableState.Never)]
2225 public Position AnchorPoint
2229 return GetValue(AnchorPointProperty) as Position;
2233 SetValue(AnchorPointProperty, value);
2237 private Position InternalAnchorPoint
2241 Position temp = new Position(0.0f, 0.0f, 0.0f);
2242 var pValue = GetProperty(View.Property.AnchorPoint);
2245 Position ret = new Position(OnAnchorPointChanged, temp.X, temp.Y, temp.Z);
2251 var temp = new Tizen.NUI.PropertyValue(value);
2252 SetProperty(View.Property.AnchorPoint, temp);
2254 NotifyPropertyChanged();
2259 /// Sets the size of a view for the width, the height and the depth.<br />
2260 /// Geometry can be scaled to fit within this area.<br />
2261 /// This does not interfere with the view's scale factor.<br />
2262 /// The views default depth is the minimum of width and height.<br />
2266 /// Animatable - This property can be animated using <c>Animation</c> class.
2268 /// animation.AnimateTo(view, "Size", new Size(100, 100));
2271 /// The property cascade chaining set is not recommended.
2274 /// This way is recommended for setting the property
2276 /// var view = new View();
2277 /// view.Size = new Size(100.5f, 200, 0);
2279 /// This way to set the property is prohibited
2281 /// view.Size.Width = 100.5f; //This does not guarantee a proper operation
2284 /// <since_tizen> 5 </since_tizen>
2289 return (Size)GetValue(SizeProperty);
2293 SetValue(SizeProperty, value);
2294 NotifyPropertyChanged();
2299 /// Deprecated in API5; Will be removed in API8. Please use 'Container GetParent() for derived class' instead!
2301 /// <since_tizen> 3 </since_tizen>
2302 [Obsolete("Deprecated in API5; Will be removed in API8. Please use 'Container GetParent() for derived class' instead! " +
2304 "Container parent = view.GetParent(); " +
2305 "View view = parent as View;")]
2306 [EditorBrowsable(EditorBrowsableState.Never)]
2307 public new View Parent
2312 IntPtr cPtr = Interop.Actor.GetParent(SwigCPtr);
2313 HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
2314 BaseHandle basehandle = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle);
2316 if (basehandle is Layer layer)
2318 ret = new View(Layer.getCPtr(layer).Handle, false);
2319 NUILog.Error("This Parent property is deprecated, should do not be used");
2323 ret = basehandle as View;
2326 Interop.BaseHandle.DeleteBaseHandle(CPtr);
2327 CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
2329 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
2335 /// Gets/Sets whether inherit parent's the layout Direction.
2337 /// <since_tizen> 4 </since_tizen>
2338 public bool InheritLayoutDirection
2342 return (bool)GetValue(InheritLayoutDirectionProperty);
2346 SetValue(InheritLayoutDirectionProperty, value);
2347 NotifyPropertyChanged();
2352 /// Gets/Sets the layout Direction.
2354 /// <since_tizen> 4 </since_tizen>
2355 public ViewLayoutDirectionType LayoutDirection
2359 return (ViewLayoutDirectionType)GetValue(LayoutDirectionProperty);
2363 SetValue(LayoutDirectionProperty, value);
2364 NotifyPropertyChanged();
2365 layout?.RequestLayout();
2370 /// Gets or sets the Margin for use in layout.
2373 /// Margin property is supported by Layout algorithms and containers.
2374 /// Please Set Layout if you want to use Margin property.
2375 /// The property cascade chaining set is not recommended.
2378 /// This way is recommended for setting the property
2380 /// var view = new View();
2381 /// view.Margin = new Extents(10, 5, 15, 20);
2383 /// This way to set the property is prohibited
2385 /// view.Margin.Top = 15; //This does not guarantee a proper operation
2388 /// <since_tizen> 4 </since_tizen>
2389 public Extents Margin
2393 // If View has a Layout then margin is stored in Layout.
2396 return Layout.Margin;
2400 // If Layout not set then return margin stored in View.
2401 return (Extents)GetValue(MarginProperty);
2403 // Two return points to prevent creating a zeroed Extent native object before assignment
2409 // Layout set so store Margin in LayoutItem instead of View.
2410 // If View stores the Margin too then the Legacy Size Negotiation will
2411 // overwrite the position and size values measured in the Layouting.
2412 Layout.Margin = value;
2413 SetValue(MarginProperty, new Extents(0, 0, 0, 0));
2414 layout?.RequestLayout();
2418 SetValue(MarginProperty, value);
2420 NotifyPropertyChanged();
2421 layout?.RequestLayout();
2426 /// The required policy for this dimension, <see cref="LayoutParamPolicies"/> values or exact value.
2430 /// // matchParentView matches its size to its parent size.
2431 /// matchParentView.WidthSpecification = LayoutParamPolicies.MatchParent;
2432 /// matchParentView.HeightSpecification = LayoutParamPolicies.MatchParent;
2434 /// // wrapContentView wraps its children with their desired size.
2435 /// wrapContentView.WidthSpecification = LayoutParamPolicies.WrapContent;
2436 /// wrapContentView.HeightSpecification = LayoutParamPolicies.WrapContent;
2438 /// // exactSizeView shows itself with an exact size.
2439 /// exactSizeView.WidthSpecification = 100;
2440 /// exactSizeView.HeightSpecification = 100;
2443 /// <since_tizen> 6 </since_tizen>
2444 [Binding.TypeConverter(typeof(IntDpTypeConverter))]
2445 public int WidthSpecification
2449 return (int)GetValue(WidthSpecificationProperty);
2453 SetValue(WidthSpecificationProperty, value);
2454 NotifyPropertyChanged();
2458 private int InternalWidthSpecification
2466 if (value == widthPolicy)
2469 widthPolicy = value;
2470 if (widthPolicy >= 0)
2472 if (heightPolicy >= 0) // Policy an exact value
2474 // Create Size2D only both _widthPolicy and _heightPolicy are set.
2475 Size2D = new Size2D(widthPolicy, heightPolicy);
2478 layout?.RequestLayout();
2483 /// The required policy for this dimension, <see cref="LayoutParamPolicies"/> values or exact value.
2487 /// // matchParentView matches its size to its parent size.
2488 /// matchParentView.WidthSpecification = LayoutParamPolicies.MatchParent;
2489 /// matchParentView.HeightSpecification = LayoutParamPolicies.MatchParent;
2491 /// // wrapContentView wraps its children with their desired size.
2492 /// wrapContentView.WidthSpecification = LayoutParamPolicies.WrapContent;
2493 /// wrapContentView.HeightSpecification = LayoutParamPolicies.WrapContent;
2495 /// // exactSizeView shows itself with an exact size.
2496 /// exactSizeView.WidthSpecification = 100;
2497 /// exactSizeView.HeightSpecification = 100;
2500 /// <since_tizen> 6 </since_tizen>
2501 [Binding.TypeConverter(typeof(IntDpTypeConverter))]
2502 public int HeightSpecification
2506 return (int)GetValue(HeightSpecificationProperty);
2510 SetValue(HeightSpecificationProperty, value);
2511 NotifyPropertyChanged();
2515 private int InternalHeightSpecification
2519 return heightPolicy;
2523 if (value == heightPolicy)
2526 heightPolicy = value;
2527 if (heightPolicy >= 0)
2529 if (widthPolicy >= 0) // Policy an exact value
2531 // Create Size2D only both _widthPolicy and _heightPolicy are set.
2532 Size2D = new Size2D(widthPolicy, heightPolicy);
2535 layout?.RequestLayout();
2540 /// Gets the List of transitions for this View.
2542 /// <since_tizen> 6 </since_tizen>
2543 public Dictionary<TransitionCondition, TransitionList> LayoutTransitions
2547 if (layoutTransitions == null)
2549 layoutTransitions = new Dictionary<TransitionCondition, TransitionList>();
2551 return layoutTransitions;
2556 /// Sets a layout transitions for this View.
2558 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
2560 /// Use LayoutTransitions to receive a collection of LayoutTransitions set on the View.
2562 /// <since_tizen> 6 </since_tizen>
2563 public LayoutTransition LayoutTransition
2567 return GetValue(LayoutTransitionProperty) as LayoutTransition;
2571 SetValue(LayoutTransitionProperty, value);
2572 NotifyPropertyChanged();
2576 private LayoutTransition InternalLayoutTransition
2580 return layoutTransition;
2586 throw new global::System.ArgumentNullException(nameof(value));
2588 if (layoutTransitions == null)
2590 layoutTransitions = new Dictionary<TransitionCondition, TransitionList>();
2593 LayoutTransitionsHelper.AddTransitionForCondition(layoutTransitions, value.Condition, value, true);
2595 AttachTransitionsToChildren(value);
2597 layoutTransition = value;
2602 /// Deprecated in API5; Will be removed in API8. Please use Padding instead.
2605 /// The property cascade chaining set is possible. For example, this (view.DecorationBoundingBox.X = 0.1f;) is possible.
2607 /// <since_tizen> 4 </since_tizen>
2608 [Obsolete("Deprecated in API5; Will be removed in API8. Please use Padding instead.")]
2609 [EditorBrowsable(EditorBrowsableState.Never)]
2610 public Extents PaddingEX
2614 return GetValue(PaddingEXProperty) as Extents;
2618 SetValue(PaddingEXProperty, value);
2622 private Extents InternalPaddingEX
2626 Extents temp = new Extents(0, 0, 0, 0);
2627 var pValue = GetProperty(View.Property.PADDING);
2630 Extents ret = new Extents(OnPaddingEXChanged, temp.Start, temp.End, temp.Top, temp.Bottom);
2636 var temp = new Tizen.NUI.PropertyValue(value);
2637 SetProperty(View.Property.PADDING, temp);
2639 NotifyPropertyChanged();
2640 layout?.RequestLayout();
2644 [EditorBrowsable(EditorBrowsableState.Never)]
2645 public XamlStyle XamlStyle
2649 return (XamlStyle)GetValue(XamlStyleProperty);
2653 SetValue(XamlStyleProperty, value);
2658 /// The Color of View. This is an RGBA value.
2662 /// Animatable - This property can be animated using <c>Animation</c> class.
2664 /// The property cascade chaining set is not recommended.
2667 /// This way is recommended for setting the property
2669 /// var view = new View();
2670 /// view.Color = new Color(0.5f, 0.2f, 0.1f, 0.5f);
2672 /// This way to set the property is prohibited
2674 /// view.Color.A = 0.5f; //This does not guarantee a proper operation
2677 [EditorBrowsable(EditorBrowsableState.Never)]
2682 return (Color)GetValue(ColorProperty);
2686 SetValue(ColorProperty, value);
2687 NotifyPropertyChanged();
2692 /// Set the layout on this View. Replaces any existing Layout.
2695 /// If this Layout is set as null explicitly, it means this View itself and it's child Views will not use Layout anymore.
2697 /// <since_tizen> 6 </since_tizen>
2698 public LayoutItem Layout
2702 return GetValue(LayoutProperty) as LayoutItem;
2706 // ResizePolicy is restored when Layout is unset and it is considered when View size is calculated.
2707 // SetValue(LayoutProperty, value) sets InternalLayout only if layout is not null.
2710 RestoreResizePolicy();
2713 SetValue(LayoutProperty, value);
2717 private LayoutItem InternalLayout
2725 // Do nothing if layout provided is already set on this View.
2726 if (value == layout)
2731 LayoutingDisabled = false;
2734 // If new layout being set already has a owner then that owner receives a replacement default layout.
2735 // First check if the layout to be set already has a owner.
2736 if (value?.Owner != null)
2738 // Previous owner of the layout gets a default layout as a replacement.
2739 value.Owner.Layout = new AbsoluteLayout()
2741 // Copy Margin and Padding to replacement LayoutGroup.
2742 Margin = value.Margin,
2743 Padding = value.Padding,
2747 // Copy Margin and Padding to new layout being set or restore padding and margin back to
2748 // View if no replacement. Previously margin and padding values would have been moved from
2749 // the View to the layout.
2750 if (layout != null) // Existing layout
2754 // Existing layout being replaced so copy over margin and padding values.
2755 value.Margin = layout.Margin;
2756 value.Padding = layout.Padding;
2757 value.SetPositionByLayout = !excludeLayouting;
2761 // Layout not being replaced so restore margin and padding to View.
2762 SetValue(MarginProperty, layout.Margin);
2763 SetValue(PaddingProperty, layout.Padding);
2764 NotifyPropertyChanged();
2769 // First Layout to be added to the View hence copy
2771 // Do not try to set Margins or Padding on a null Layout (when a layout is being removed from a View)
2774 Extents margin = Margin;
2775 Extents padding = Padding;
2776 if (margin.Top != 0 || margin.Bottom != 0 || margin.Start != 0 || margin.End != 0)
2778 // If View already has a margin set then store it in Layout instead.
2779 value.Margin = margin;
2780 SetValue(MarginProperty, new Extents(0, 0, 0, 0));
2781 NotifyPropertyChanged();
2784 if (padding.Top != 0 || padding.Bottom != 0 || padding.Start != 0 || padding.End != 0)
2786 // If View already has a padding set then store it in Layout instead.
2787 value.Padding = padding;
2789 // If Layout is a LayoutItem then it could be a View that handles it's own padding.
2790 // Let the View keeps it's padding. Still store Padding in Layout to reduce code paths.
2791 if (typeof(LayoutGroup).IsAssignableFrom(value.GetType()))
2793 SetValue(PaddingProperty, new Extents(0, 0, 0, 0));
2794 NotifyPropertyChanged();
2798 value.SetPositionByLayout = !excludeLayouting;
2802 // Remove existing layout from it's parent layout group.
2805 // Set layout to this view
2811 /// The weight of the View, used to share available space in a layout with siblings.
2813 /// <since_tizen> 6 </since_tizen>
2823 layout?.RequestLayout();
2828 /// Whether to load the BackgroundImage synchronously.
2829 /// If not specified, the default is false, i.e. the BackgroundImage is loaded asynchronously.
2830 /// Note: For Normal Quad images only.
2832 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
2833 [EditorBrowsable(EditorBrowsableState.Never)]
2834 public bool BackgroundImageSynchronosLoading
2838 return (bool)GetValue(BackgroundImageSynchronosLoadingProperty);
2842 SetValue(BackgroundImageSynchronosLoadingProperty, value);
2843 NotifyPropertyChanged();
2847 private bool InternalBackgroundImageSynchronosLoading
2851 return BackgroundImageSynchronousLoading;
2855 BackgroundImageSynchronousLoading = value;
2860 /// Whether to load the BackgroundImage synchronously.
2861 /// If not specified, the default is false, i.e. the BackgroundImage is loaded asynchronously.
2862 /// Note: For Normal Quad images only.
2864 /// This will be public opened in tizen_7.0 after ACR done. Before ACR, need to be hidden as inhouse API.
2865 [EditorBrowsable(EditorBrowsableState.Never)]
2866 public bool BackgroundImageSynchronousLoading
2870 return (bool)GetValue(BackgroundImageSynchronousLoadingProperty);
2874 SetValue(BackgroundImageSynchronousLoadingProperty, value);
2875 NotifyPropertyChanged();
2879 private bool InternalBackgroundImageSynchronousLoading
2883 return backgroundImageSynchronousLoading;
2887 backgroundImageSynchronousLoading = value;
2889 string bgUrl = null;
2890 var pValue = Background.Find(ImageVisualProperty.URL);
2891 pValue?.Get(out bgUrl);
2894 if (!string.IsNullOrEmpty(bgUrl))
2896 PropertyMap bgMap = this.Background;
2897 var temp = new PropertyValue(backgroundImageSynchronousLoading);
2898 bgMap.Add("synchronousLoading", temp);
2905 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
2906 [EditorBrowsable(EditorBrowsableState.Never)]
2907 public Vector2 UpdateSizeHint
2911 return (Vector2)GetValue(UpdateSizeHintProperty);
2915 SetValue(UpdateSizeHintProperty, value);
2916 NotifyPropertyChanged();
2921 /// Enable/Disable ControlState propagation for children.
2922 /// It is false by default.
2923 /// If the View needs to share ControlState with descendants, please set it true.
2924 /// Please note that, changing the value will also changes children's EnableControlStatePropagation value recursively.
2926 [EditorBrowsable(EditorBrowsableState.Never)]
2927 public bool EnableControlStatePropagation
2931 return (bool)GetValue(EnableControlStatePropagationProperty);
2935 SetValue(EnableControlStatePropagationProperty, value);
2936 NotifyPropertyChanged();
2940 private bool InternalEnableControlStatePropagation
2942 get => themeData?.ControlStatePropagation ?? false;
2945 if (InternalEnableControlStatePropagation == value) return;
2947 if (themeData == null) themeData = new ThemeData();
2949 themeData.ControlStatePropagation = value;
2951 foreach (View child in Children)
2953 child.EnableControlStatePropagation = value;
2959 /// By default, it is false in View, true in Control.
2960 /// Note that if the value is true, the View will be a touch receptor.
2962 [EditorBrowsable(EditorBrowsableState.Never)]
2963 public bool EnableControlState
2967 return (bool)GetValue(EnableControlStateProperty);
2971 SetValue(EnableControlStateProperty, value);
2976 /// Whether the actor grab all touches even if touch leaves its boundary.
2978 /// <returns>true, if it grab all touch after start</returns>
2979 [EditorBrowsable(EditorBrowsableState.Never)]
2980 public bool GrabTouchAfterLeave
2984 return (bool)GetValue(GrabTouchAfterLeaveProperty);
2988 SetValue(GrabTouchAfterLeaveProperty, value);
2992 private bool InternalGrabTouchAfterLeave
2997 var pValue = GetProperty(View.Property.CaptureAllTouchAfterStart);
2998 pValue.Get(out temp);
3004 var temp = new Tizen.NUI.PropertyValue(value);
3005 SetProperty(View.Property.CaptureAllTouchAfterStart, temp);
3007 NotifyPropertyChanged();
3012 /// Determines which blend equation will be used to render renderers of this actor.
3014 /// <returns>blend equation enum currently assigned</returns>
3015 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
3016 [EditorBrowsable(EditorBrowsableState.Never)]
3017 public BlendEquationType BlendEquation
3021 return (BlendEquationType)GetValue(BlendEquationProperty);
3025 SetValue(BlendEquationProperty, value);
3029 private BlendEquationType InternalBlendEquation
3034 var pValue = GetProperty(View.Property.BlendEquation);
3035 pValue.Get(out temp);
3037 return (BlendEquationType)temp;
3041 var temp = new Tizen.NUI.PropertyValue((int)value);
3042 SetProperty(View.Property.BlendEquation, temp);
3044 NotifyPropertyChanged();
3049 /// If the value is true, the View will change its style as the theme changes.
3050 /// The default value is false in normal case but it can be true when the NUIApplication is created with <see cref="NUIApplication.ThemeOptions.ThemeChangeSensitive"/>.
3052 /// <since_tizen> 9 </since_tizen>
3053 public bool ThemeChangeSensitive
3055 get => (bool)GetValue(ThemeChangeSensitiveProperty);
3056 set => SetValue(ThemeChangeSensitiveProperty, value);
3060 /// Create Style, it is abstract function and must be override.
3062 [EditorBrowsable(EditorBrowsableState.Never)]
3063 protected virtual ViewStyle CreateViewStyle()
3065 return new ViewStyle();
3069 /// Called after the View's ControlStates changed.
3071 /// <param name="controlStateChangedInfo">The information including state changed variables.</param>
3072 [EditorBrowsable(EditorBrowsableState.Never)]
3073 protected virtual void OnControlStateChanged(ControlStateChangedEventArgs controlStateChangedInfo)
3079 [EditorBrowsable(EditorBrowsableState.Never)]
3080 protected virtual void OnThemeChanged(object sender, ThemeChangedEventArgs e)
3082 if (string.IsNullOrEmpty(styleName)) ApplyStyle(ThemeManager.GetUpdateStyleWithoutClone(GetType()));
3083 else ApplyStyle(ThemeManager.GetUpdateStyleWithoutClone(styleName));
3087 /// Apply style instance to the view.
3088 /// Basically it sets the bindable property to the value of the bindable property with same name in the style.
3090 /// <since_tizen> 9 </since_tizen>
3091 public virtual void ApplyStyle(ViewStyle viewStyle)
3093 if (viewStyle == null || themeData?.viewStyle == viewStyle) return;
3095 if (themeData == null) themeData = new ThemeData();
3097 themeData.viewStyle = viewStyle;
3099 if (viewStyle.DirtyProperties == null || viewStyle.DirtyProperties.Count == 0)
3105 BindableProperty.GetBindablePropertysOfType(GetType(), out var bindablePropertyOfView);
3107 if (bindablePropertyOfView == null)
3112 var dirtyStyleProperties = new BindableProperty[viewStyle.DirtyProperties.Count];
3113 viewStyle.DirtyProperties.CopyTo(dirtyStyleProperties);
3115 foreach (var sourceProperty in dirtyStyleProperties)
3117 var sourceValue = viewStyle.GetValue(sourceProperty);
3119 if (sourceValue == null)
3124 bindablePropertyOfView.TryGetValue(sourceProperty.PropertyName, out var destinationProperty);
3126 if (destinationProperty != null)
3128 SetValue(destinationProperty, sourceValue);
3134 /// Get whether the View is culled or not.
3135 /// True means that the View is out of the view frustum.
3138 /// Hidden-API (Inhouse-API).
3140 [EditorBrowsable(EditorBrowsableState.Never)]
3146 var pValue = GetProperty(View.Property.Culled);
3147 pValue.Get(out temp);
3154 /// Set or Get TransitionOptions for the page transition.
3155 /// This property is used to define how this view will be transitioned during Page switching.
3157 /// <since_tizen> 9 </since_tizen>
3158 public TransitionOptions TransitionOptions
3162 return GetValue(TransitionOptionsProperty) as TransitionOptions;
3166 SetValue(TransitionOptionsProperty, value);
3167 NotifyPropertyChanged();
3171 private TransitionOptions InternalTransitionOptions
3175 transitionOptions = value;
3179 return transitionOptions;
3184 /// Gets or sets the status of whether the view should emit key event signals.
3185 /// If a View's DispatchKeyEvents is set to false, then it's children will not emit a key event signal either.
3187 [EditorBrowsable(EditorBrowsableState.Never)]
3188 public bool DispatchKeyEvents
3192 return (bool)GetValue(DispatchKeyEventsProperty);
3196 SetValue(DispatchKeyEventsProperty, value);
3197 NotifyPropertyChanged();