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 internal BackgroundExtraData backgroundExtraData;
33 private bool layoutSet = false;
34 private LayoutItem layout; // Exclusive layout assigned to this View.
36 // List of transitions paired with the condition that uses the transition.
37 private Dictionary<TransitionCondition, TransitionList> layoutTransitions;
38 private int widthPolicy = LayoutParamPolicies.WrapContent; // Layout width policy
39 private int heightPolicy = LayoutParamPolicies.WrapContent; // Layout height policy
40 private float weight = 0.0f; // Weighting of child View in a Layout
41 private bool backgroundImageSynchronosLoading = false;
42 private bool excludeLayouting = false;
43 private LayoutTransition layoutTransition;
44 private TransitionOptions transitionOptions = null;
45 private ThemeData themeData;
47 internal class ThemeData
49 public bool controlStatePropagation = false;
50 public ViewStyle viewStyle;
51 public bool themeChangeSensitive = false;
52 public ControlState controlStates = ControlState.Normal;
53 public ViewSelectorData selectorData;
59 /// Creates a new instance of a view.
61 /// <since_tizen> 3 </since_tizen>
62 public View() : this(Interop.View.New(), true)
64 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
67 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
68 [EditorBrowsable(EditorBrowsableState.Never)]
69 public View(ViewStyle viewStyle) : this(Interop.View.New(), true, viewStyle)
74 /// Create a new instance of a View with setting the status of shown or hidden.
76 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
77 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
78 [EditorBrowsable(EditorBrowsableState.Never)]
79 public View(bool shown) : this(Interop.View.New(), true)
81 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
85 internal View(View uiControl, bool shown = true) : this(Interop.View.NewView(View.getCPtr(uiControl)), true)
87 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
93 backgroundExtraData = uiControl.backgroundExtraData == null ? null : new BackgroundExtraData(uiControl.backgroundExtraData);
96 internal View(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : this(cPtr, cMemoryOwn, shown)
98 InitializeStyle(viewStyle);
101 internal View(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(cPtr, cMemoryOwn)
105 PositionUsesPivotPoint = false;
108 onWindowSendEventCallback = SendViewAddedEventToWindow;
109 this.OnWindowSignal().Connect(onWindowSendEventCallback);
117 internal View(ViewImpl implementation, bool shown = true) : this(Interop.View.NewViewInternal(ViewImpl.getCPtr(implementation)), true)
119 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
128 /// The event that is triggered when the View's ControlState is changed.
130 [EditorBrowsable(EditorBrowsableState.Never)]
131 public event EventHandler<ControlStateChangedEventArgs> ControlStateChangedEvent;
133 internal event EventHandler<ControlStateChangedEventArgs> ControlStateChangeEventInternal;
137 /// Flag to indicate if layout set explicitly via API call or View was automatically given a Layout.
139 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
140 [EditorBrowsable(EditorBrowsableState.Never)]
141 public bool LayoutSet
150 /// Flag to allow Layouting to be disabled for Views.
151 /// Once a View has a Layout set then any children added to Views from then on will receive
152 /// automatic Layouts.
154 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
155 [EditorBrowsable(EditorBrowsableState.Never)]
156 public static bool LayoutingDisabled { get; set; } = true;
159 /// The style instance applied to this view.
160 /// Note that please do not modify the ViewStyle.
161 /// Modifying ViewStyle will affect other views with same ViewStyle.
163 [EditorBrowsable(EditorBrowsableState.Never)]
164 protected ViewStyle ViewStyle
168 if (themeData == null) themeData = new ThemeData();
170 if (themeData.viewStyle == null)
172 ApplyStyle(CreateViewStyle());
174 return themeData.viewStyle;
179 /// Get/Set the control state.
180 /// Note that the ControlState only available for the classes derived from Control.
181 /// If the classes that are not derived from Control (such as View, ImageView and TextLabel) want to use this system,
182 /// please set <see cref="EnableControlState"/> to true.
184 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
185 [EditorBrowsable(EditorBrowsableState.Never)]
186 public ControlState ControlState
190 return themeData == null ? ControlState.Normal : themeData.controlStates;
194 if (ControlState == value)
199 var prevState = ControlState;
201 if (themeData == null) themeData = new ThemeData();
202 themeData.controlStates = value;
204 var changeInfo = new ControlStateChangedEventArgs(prevState, value);
206 ControlStateChangeEventInternal?.Invoke(this, changeInfo);
208 if (themeData.controlStatePropagation)
210 foreach (View child in Children)
212 child.ControlState = value;
216 OnControlStateChanged(changeInfo);
218 ControlStateChangedEvent?.Invoke(this, changeInfo);
223 /// Gets / Sets the status of whether the view is excluded from its parent's layouting or not.
225 /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
226 [EditorBrowsable(EditorBrowsableState.Never)]
227 public bool ExcludeLayouting
231 return excludeLayouting;
235 excludeLayouting = value;
236 if (Layout != null && Layout.SetPositionByLayout == value)
238 Layout.SetPositionByLayout = !value;
239 Layout.RequestLayout();
244 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
245 [EditorBrowsable(EditorBrowsableState.Never)]
246 public bool IsResourcesCreated
250 return Application.Current.IsResourcesCreated;
254 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
255 [EditorBrowsable(EditorBrowsableState.Never)]
256 public ResourceDictionary XamlResources
260 return Application.Current.XamlResources;
264 Application.Current.XamlResources = value;
269 /// The StyleName, type string.
270 /// The value indicates DALi style name defined in json theme file.
272 /// <since_tizen> 3 </since_tizen>
273 public string StyleName
277 return (string)GetValue(StyleNameProperty);
281 SetValue(StyleNameProperty, value);
282 NotifyPropertyChanged();
287 /// The KeyInputFocus, type bool.
289 [EditorBrowsable(EditorBrowsableState.Never)]
290 public bool KeyInputFocus
294 return (bool)GetValue(KeyInputFocusProperty);
298 SetValue(KeyInputFocusProperty, value);
299 NotifyPropertyChanged();
304 /// The mutually exclusive with "backgroundImage" and "background" type Vector4.
308 /// The property cascade chaining set is possible. For example, this (view.BackgroundColor.X = 0.1f;) is possible.
311 /// Animatable - This property can be animated using <c>Animation</c> class.
313 /// animation.AnimateTo(view, "BackgroundColor", new Color(r, g, b, a));
317 /// <since_tizen> 3 </since_tizen>
318 public Color BackgroundColor
322 Color temp = (Color)GetValue(BackgroundColorProperty);
323 return new Color(OnBackgroundColorChanged, temp.R, temp.G, temp.B, temp.A);
327 SetValue(BackgroundColorProperty, value);
328 NotifyPropertyChanged();
333 /// The mutually exclusive with "backgroundColor" and "background" type Map.
335 /// <since_tizen> 3 </since_tizen>
336 public string BackgroundImage
340 return (string)GetValue(BackgroundImageProperty);
344 SetValue(BackgroundImageProperty, value);
345 NotifyPropertyChanged();
350 /// Get or set the border of background image.
352 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
353 [EditorBrowsable(EditorBrowsableState.Never)]
354 public Rectangle BackgroundImageBorder
358 return (Rectangle)GetValue(BackgroundImageBorderProperty);
362 SetValue(BackgroundImageBorderProperty, value);
363 NotifyPropertyChanged();
368 /// The background of view.
370 /// <since_tizen> 3 </since_tizen>
371 public Tizen.NUI.PropertyMap Background
375 return (PropertyMap)GetValue(BackgroundProperty);
379 SetValue(BackgroundProperty, value);
380 NotifyPropertyChanged();
385 /// Describes a shadow as an image for a View.
386 /// It is null by default.
389 /// Getter returns copied instance of current shadow.
392 /// The mutually exclusive with "BoxShadow".
396 /// Animatable - This property can be animated using <c>Animation</c> class.
397 /// To animate this property, specify a sub-property with separator ".", for example, "ImageShadow.Offset".
399 /// animation.AnimateTo(view, "ImageShadow.Offset", new Vector2(10, 10));
401 /// Animatable sub-property : Offset.
404 [EditorBrowsable(EditorBrowsableState.Never)]
405 public ImageShadow ImageShadow
409 return (ImageShadow)GetValue(ImageShadowProperty);
413 SetValue(ImageShadowProperty, value);
414 NotifyPropertyChanged();
419 /// Describes a box shaped shadow drawing for a View.
420 /// It is null by default.
423 /// The mutually exclusive with "ImageShadow".
427 /// Animatable - This property can be animated using <c>Animation</c> class.
428 /// To animate this property, specify a sub-property with separator ".", for example, "BoxShadow.BlurRadius".
430 /// animation.AnimateTo(view, "BoxShadow.BlurRadius", 10.0f);
432 /// Animatable sub-property : Offset, Color, BlurRadius.
435 /// <since_tizen> 9 </since_tizen>
436 public Shadow BoxShadow
440 return (Shadow)GetValue(BoxShadowProperty);
444 SetValue(BoxShadowProperty, value);
445 NotifyPropertyChanged();
450 /// The radius for the rounded corners of the View.
451 /// This will rounds background and shadow edges.
452 /// 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).
453 /// Note that, an image background (or shadow) may not have rounded corners if it uses a Border property.
457 /// Animatable - This property can be animated using <c>Animation</c> class.
460 /// <since_tizen> 9 </since_tizen>
461 public Vector4 CornerRadius
465 return (Vector4)GetValue(CornerRadiusProperty);
469 SetValue(CornerRadiusProperty, value);
470 NotifyPropertyChanged();
475 /// Whether the CornerRadius property value is relative (percentage [0.0f to 1.0f] of the view size) or absolute (in world units).
476 /// It is absolute by default.
477 /// When the policy is relative, the corner radius is relative to the smaller of the view's width and height.
479 /// <since_tizen> 9 </since_tizen>
480 public VisualTransformPolicyType CornerRadiusPolicy
482 get => (VisualTransformPolicyType)GetValue(CornerRadiusPolicyProperty);
483 set => SetValue(CornerRadiusPolicyProperty, value);
487 /// The width for the borderline of the View.
488 /// This will draw borderline at background.
489 /// Note that, an image background may not have borderline if it uses a Border property.
493 /// Animatable - This property can be animated using <c>Animation</c> class.
496 /// This will be public opened after ACR done. Before ACR, need to be hidden as inhouse API.
497 [EditorBrowsable(EditorBrowsableState.Never)]
498 public float BorderlineWidth
502 return (float)GetValue(BorderlineWidthProperty);
506 SetValue(BorderlineWidthProperty, value);
507 NotifyPropertyChanged();
512 /// The color for the borderline of the View.
513 /// It is Color.Black by default.
517 /// Animatable - This property can be animated using <c>Animation</c> class.
520 /// This will be public opened after ACR done. Before ACR, need to be hidden as inhouse API.
521 [EditorBrowsable(EditorBrowsableState.Never)]
522 public Color BorderlineColor
526 return (Color)GetValue(BorderlineColorProperty);
530 SetValue(BorderlineColorProperty, value);
531 NotifyPropertyChanged();
536 /// The Relative offset for the borderline of the View.
537 /// recommand [-1.0f to 1.0f] range.
538 /// If -1.0f, borderline draw inside of View.
539 /// If 1.0f, borderline draw outside of View.
540 /// If 0.0f, borderline draw half at inside and half at outside.
541 /// It is 0.0f by default.
545 /// Animatable - This property can be animated using <c>Animation</c> class.
548 /// This will be public opened after ACR done. Before ACR, need to be hidden as inhouse API.
549 [EditorBrowsable(EditorBrowsableState.Never)]
550 public float BorderlineOffset
554 return (float)GetValue(BorderlineOffsetProperty);
558 SetValue(BorderlineOffsetProperty, value);
559 NotifyPropertyChanged();
564 /// The current state of the view.
566 /// <since_tizen> 3 </since_tizen>
571 return (States)GetValue(StateProperty);
575 SetValue(StateProperty, value);
576 NotifyPropertyChanged();
581 /// The current sub state of the view.
583 /// <since_tizen> 3 </since_tizen>
584 public States SubState
588 return (States)GetValue(SubStateProperty);
592 SetValue(SubStateProperty, value);
593 NotifyPropertyChanged();
598 /// Displays a tooltip
600 /// <since_tizen> 3 </since_tizen>
601 public Tizen.NUI.PropertyMap Tooltip
605 return (PropertyMap)GetValue(TooltipProperty);
609 SetValue(TooltipProperty, value);
610 NotifyPropertyChanged();
615 /// Displays a tooltip as a text.
617 /// <since_tizen> 3 </since_tizen>
618 public string TooltipText
622 using (var propertyValue = GetProperty(Property.TOOLTIP))
624 if (propertyValue != null && propertyValue.Get(out string retrivedValue))
626 return retrivedValue;
628 NUILog.Error($"[ERROR] Fail to get TooltipText! Return error MSG (error to get TooltipText)!");
629 return "error to get TooltipText";
634 var temp = new Tizen.NUI.PropertyValue(value);
635 SetProperty(View.Property.TOOLTIP, temp);
637 NotifyPropertyChanged();
642 /// The Child property of FlexContainer.<br />
643 /// The proportion of the free space in the container, the flex item will receive.<br />
644 /// If all items in the container set this property, their sizes will be proportional to the specified flex factor.<br />
646 /// <since_tizen> 3 </since_tizen>
647 [Obsolete("Deprecated in API8, will be removed in API10.")]
652 return (float)GetValue(FlexProperty);
656 SetValue(FlexProperty, value);
657 NotifyPropertyChanged();
662 /// The Child property of FlexContainer.<br />
663 /// The alignment of the flex item along the cross axis, which, if set, overrides the default alignment for all items in the container.<br />
665 /// <since_tizen> 3 </since_tizen>
666 [Obsolete("Deprecated in API8, will be removed in API10.")]
671 return (int)GetValue(AlignSelfProperty);
675 SetValue(AlignSelfProperty, value);
676 NotifyPropertyChanged();
681 /// The Child property of FlexContainer.<br />
682 /// The space around the flex item.<br />
685 /// The property cascade chaining set is possible. For example, this (view.FlexMargin.X = 0.1f;) is possible.
687 /// <since_tizen> 3 </since_tizen>
688 [Obsolete("Deprecated in API8, will be removed in API10.")]
689 public Vector4 FlexMargin
693 Vector4 temp = (Vector4)GetValue(FlexMarginProperty);
694 return new Vector4(OnFlexMarginChanged, temp.X, temp.Y, temp.Z, temp.W);
698 SetValue(FlexMarginProperty, value);
699 NotifyPropertyChanged();
704 /// The top-left cell this child occupies, if not set, the first available cell is used.
707 /// The property cascade chaining set is possible. For example, this (view.CellIndex.X = 0.1f;) is possible.
708 /// Also, this property is for <see cref="TableView"/> class. Please use the property for the child position of <see cref="TableView"/>.
710 /// <since_tizen> 3 </since_tizen>
711 public Vector2 CellIndex
715 Vector2 temp = (Vector2)GetValue(CellIndexProperty);
716 return new Vector2(OnCellIndexChanged, temp.X, temp.Y);
720 SetValue(CellIndexProperty, value);
721 NotifyPropertyChanged();
726 /// The number of rows this child occupies, if not set, the default value is 1.
729 /// This property is for <see cref="TableView"/> class. Please use the property for the child position of <see cref="TableView"/>.
731 /// <since_tizen> 3 </since_tizen>
736 return (float)GetValue(RowSpanProperty);
740 SetValue(RowSpanProperty, value);
741 NotifyPropertyChanged();
746 /// The number of columns this child occupies, if not set, the default value is 1.
749 /// This property is for <see cref="TableView"/> class. Please use the property for the child position of <see cref="TableView"/>.
751 /// <since_tizen> 3 </since_tizen>
752 public float ColumnSpan
756 return (float)GetValue(ColumnSpanProperty);
760 SetValue(ColumnSpanProperty, value);
761 NotifyPropertyChanged();
766 /// The horizontal alignment of this child inside the cells, if not set, the default value is 'left'.
769 /// This property is for <see cref="TableView"/> class. Please use the property for the child position of <see cref="TableView"/>.
771 /// <since_tizen> 3 </since_tizen>
772 public Tizen.NUI.HorizontalAlignmentType CellHorizontalAlignment
776 return (HorizontalAlignmentType)GetValue(CellHorizontalAlignmentProperty);
780 SetValue(CellHorizontalAlignmentProperty, value);
781 NotifyPropertyChanged();
786 /// The vertical alignment of this child inside the cells, if not set, the default value is 'top'.
789 /// This property is for <see cref="TableView"/> class. Please use the property for the child position of <see cref="TableView"/>.
791 /// <since_tizen> 3 </since_tizen>
792 public Tizen.NUI.VerticalAlignmentType CellVerticalAlignment
796 return (VerticalAlignmentType)GetValue(CellVerticalAlignmentProperty);
800 SetValue(CellVerticalAlignmentProperty, value);
801 NotifyPropertyChanged();
806 /// The left focusable view.<br />
807 /// This will return null if not set.<br />
808 /// This will also return null if the specified left focusable view is not on a window.<br />
810 /// <since_tizen> 3 </since_tizen>
811 public View LeftFocusableView
813 // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
816 return (View)GetValue(LeftFocusableViewProperty);
820 SetValue(LeftFocusableViewProperty, value);
821 NotifyPropertyChanged();
826 /// The right focusable view.<br />
827 /// This will return null if not set.<br />
828 /// This will also return null if the specified right focusable view is not on a window.<br />
830 /// <since_tizen> 3 </since_tizen>
831 public View RightFocusableView
833 // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
836 return (View)GetValue(RightFocusableViewProperty);
840 SetValue(RightFocusableViewProperty, value);
841 NotifyPropertyChanged();
846 /// The up focusable view.<br />
847 /// This will return null if not set.<br />
848 /// This will also return null if the specified up focusable view is not on a window.<br />
850 /// <since_tizen> 3 </since_tizen>
851 public View UpFocusableView
853 // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
856 return (View)GetValue(UpFocusableViewProperty);
860 SetValue(UpFocusableViewProperty, value);
861 NotifyPropertyChanged();
866 /// The down focusable view.<br />
867 /// This will return null if not set.<br />
868 /// This will also return null if the specified down focusable view is not on a window.<br />
870 /// <since_tizen> 3 </since_tizen>
871 public View DownFocusableView
873 // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
876 return (View)GetValue(DownFocusableViewProperty);
880 SetValue(DownFocusableViewProperty, value);
881 NotifyPropertyChanged();
886 /// Whether the view should be focusable by keyboard navigation.
888 /// <since_tizen> 3 </since_tizen>
889 public bool Focusable
893 SetValue(FocusableProperty, value);
894 NotifyPropertyChanged();
898 return (bool)GetValue(FocusableProperty);
903 /// Retrieves the position of the view.<br />
904 /// The coordinates are relative to the view's parent.<br />
906 /// <since_tizen> 3 </since_tizen>
907 public Position CurrentPosition
911 return GetCurrentPosition();
916 /// Sets the size of a view for the width and the height.<br />
917 /// Geometry can be scaled to fit within this area.<br />
918 /// This does not interfere with the view's scale factor.<br />
919 /// The views default depth is the minimum of width and height.<br />
922 /// This NUI object (Size2D) typed property can be configured by multiple cascade setting. <br />
923 /// For example, this code ( view.Size2D.Width = 100; view.Size2D.Height = 100; ) is equivalent to this ( view.Size2D = new Size2D(100, 100); ). <br />
925 /// <since_tizen> 3 </since_tizen>
930 Size2D temp = (Size2D)GetValue(Size2DProperty);
931 int width = temp.Width;
932 int height = temp.Height;
934 if (this.Layout == null)
936 if (width < 0) { width = 0; }
937 if (height < 0) { height = 0; }
940 return new Size2D(OnSize2DChanged, width, height);
944 SetValue(Size2DProperty, value);
946 NotifyPropertyChanged();
951 /// Retrieves the size of the view.<br />
952 /// The coordinates are relative to the view's parent.<br />
954 /// <since_tizen> 3 </since_tizen>
955 public Size2D CurrentSize
959 return GetCurrentSize();
964 /// Retrieves and sets the view's opacity.<br />
966 /// <since_tizen> 3 </since_tizen>
971 return (float)GetValue(OpacityProperty);
975 SetValue(OpacityProperty, value);
976 NotifyPropertyChanged();
981 /// Sets the position of the view for X and Y.<br />
982 /// By default, sets the position vector between the parent origin and the pivot point (default).<br />
983 /// If the position inheritance is disabled, sets the world position.<br />
986 /// This NUI object (Position2D) typed property can be configured by multiple cascade setting. <br />
987 /// For example, this code ( view.Position2D.X = 100; view.Position2D.Y = 100; ) is equivalent to this ( view.Position2D = new Position2D(100, 100); ). <br />
989 /// <since_tizen> 3 </since_tizen>
990 public Position2D Position2D
994 Position2D temp = (Position2D)GetValue(Position2DProperty);
995 return new Position2D(OnPosition2DChanged, temp.X, temp.Y);
999 SetValue(Position2DProperty, value);
1000 NotifyPropertyChanged();
1005 /// Retrieves the screen position of the view.<br />
1007 /// <since_tizen> 3 </since_tizen>
1008 public Vector2 ScreenPosition
1012 Vector2 temp = new Vector2(0.0f, 0.0f);
1013 var pValue = GetProperty(View.Property.ScreenPosition);
1021 /// Determines whether the pivot point should be used to determine the position of the view.
1022 /// This is false by default.
1024 /// <remarks>If false, then the top-left of the view is used for the position.
1025 /// Setting this to false will allow scaling or rotation around the pivot point without affecting the view's position.
1027 /// <since_tizen> 3 </since_tizen>
1028 public bool PositionUsesPivotPoint
1032 return (bool)GetValue(PositionUsesPivotPointProperty);
1036 SetValue(PositionUsesPivotPointProperty, value);
1037 NotifyPropertyChanged();
1042 /// Deprecated in API5; Will be removed in API8. Please use PositionUsesPivotPoint instead!
1044 /// <since_tizen> 3 </since_tizen>
1045 [Obsolete("Deprecated in API5; Will be removed in API8. Please use PositionUsesPivotPoint instead! " +
1047 "View view = new View(); " +
1048 "view.PivotPoint = PivotPoint.Center; " +
1049 "view.PositionUsesPivotPoint = true;" +
1050 " Deprecated in API5: Will be removed in API8")]
1051 [EditorBrowsable(EditorBrowsableState.Never)]
1052 public bool PositionUsesAnchorPoint
1057 var pValue = GetProperty(View.Property.PositionUsesAnchorPoint);
1058 pValue.Get(out temp);
1064 var temp = new Tizen.NUI.PropertyValue(value);
1065 SetProperty(View.Property.PositionUsesAnchorPoint, temp);
1067 NotifyPropertyChanged();
1072 /// Queries whether the view is connected to the stage.<br />
1073 /// When a view is connected, it will be directly or indirectly parented to the root view.<br />
1075 /// <since_tizen> 3 </since_tizen>
1076 public bool IsOnWindow
1085 /// Gets the depth in the hierarchy for the view.
1087 /// <since_tizen> 3 </since_tizen>
1088 public int HierarchyDepth
1092 return GetHierarchyDepth();
1097 /// Sets the sibling order of the view so the depth position can be defined within the same parent.
1100 /// Note the initial value is 0. SiblingOrder should be bigger than 0 or equal to 0.
1101 /// Raise, Lower, RaiseToTop, LowerToBottom, RaiseAbove, and LowerBelow will override the sibling order.
1102 /// The values set by this property will likely change.
1104 /// <since_tizen> 3 </since_tizen>
1105 public int SiblingOrder
1109 return (int)GetValue(SiblingOrderProperty);
1113 SetValue(SiblingOrderProperty, value);
1115 LayoutGroup layout = Layout as LayoutGroup;
1116 layout?.ChangeLayoutSiblingOrder(value);
1118 NotifyPropertyChanged();
1123 /// Returns the natural size of the view.
1126 /// Deriving classes stipulate the natural size and by default a view has a zero natural size.
1128 /// <since_tizen> 5 </since_tizen>
1129 public Vector3 NaturalSize
1133 Vector3 ret = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
1134 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
1140 /// Returns the natural size (Size2D) of the view.
1143 /// Deriving classes stipulate the natural size and by default a view has a zero natural size.
1145 /// <since_tizen> 4 </since_tizen>
1146 public Size2D NaturalSize2D
1150 Vector3 temp = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
1151 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
1153 Size2D sz = new Size2D((int)temp.Width, (int)temp.Height);
1160 /// Gets or sets the origin of a view within its parent's area.<br />
1161 /// 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 />
1162 /// The default parent-origin is ParentOrigin.TopLeft (0.0, 0.0, 0.5).<br />
1163 /// A view's position is the distance between this origin and the view's anchor-point.<br />
1165 /// <pre>The view has been initialized.</pre>
1166 /// <since_tizen> 3 </since_tizen>
1167 public Position ParentOrigin
1171 Position tmp = (Position)GetValue(ParentOriginProperty);
1172 return new Position(OnParentOriginChanged, tmp.X, tmp.Y, tmp.Z);
1176 SetValue(ParentOriginProperty, value);
1177 NotifyPropertyChanged();
1182 /// Gets or sets the anchor-point of a view.<br />
1183 /// 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 />
1184 /// The default pivot point is PivotPoint.Center (0.5, 0.5, 0.5).<br />
1185 /// A view position is the distance between its parent-origin and this anchor-point.<br />
1186 /// A view's orientation is the rotation from its default orientation, the rotation is centered around its anchor-point.<br />
1187 /// <pre>The view has been initialized.</pre>
1190 /// The property cascade chaining set is possible. For example, this (view.PivotPoint.X = 0.1f;) is possible.
1192 /// <since_tizen> 3 </since_tizen>
1193 public Position PivotPoint
1197 Position tmp = (Position)GetValue(PivotPointProperty);
1198 return new Position(OnPivotPointChanged, tmp.X, tmp.Y, tmp.Z);
1202 SetValue(PivotPointProperty, value);
1203 NotifyPropertyChanged();
1208 /// Gets or sets the size width of the view.
1212 /// Animatable - This property can be animated using <c>Animation</c> class.
1215 /// <since_tizen> 3 </since_tizen>
1216 public float SizeWidth
1220 return (float)GetValue(SizeWidthProperty);
1224 SetValue(SizeWidthProperty, value);
1225 NotifyPropertyChanged();
1230 /// Gets or sets the size height of the view.
1234 /// Animatable - This property can be animated using <c>Animation</c> class.
1237 /// <since_tizen> 3 </since_tizen>
1238 public float SizeHeight
1242 return (float)GetValue(SizeHeightProperty);
1246 SetValue(SizeHeightProperty, value);
1247 NotifyPropertyChanged();
1252 /// Gets or sets the position of the view.<br />
1253 /// By default, sets the position vector between the parent origin and pivot point (default).<br />
1254 /// If the position inheritance is disabled, sets the world position.<br />
1258 /// Animatable - This property can be animated using <c>Animation</c> class.
1260 /// The property cascade chaining set is possible. For example, this (view.Position.X = 1.0f;) is possible.
1262 /// <since_tizen> 3 </since_tizen>
1263 public Position Position
1267 Position tmp = (Position)GetValue(PositionProperty);
1268 return new Position(OnPositionChanged, tmp.X, tmp.Y, tmp.Z);
1272 SetValue(PositionProperty, value);
1273 NotifyPropertyChanged();
1278 /// Gets or sets the position X of the view.
1282 /// Animatable - This property can be animated using <c>Animation</c> class.
1285 /// <since_tizen> 3 </since_tizen>
1286 public float PositionX
1290 return (float)GetValue(PositionXProperty);
1294 SetValue(PositionXProperty, value);
1295 NotifyPropertyChanged();
1300 /// Gets or sets the position Y of the view.
1304 /// Animatable - This property can be animated using <c>Animation</c> class.
1307 /// <since_tizen> 3 </since_tizen>
1308 public float PositionY
1312 return (float)GetValue(PositionYProperty);
1316 SetValue(PositionYProperty, value);
1317 NotifyPropertyChanged();
1322 /// Gets or sets the position Z of the view.
1326 /// Animatable - This property can be animated using <c>Animation</c> class.
1329 /// <since_tizen> 3 </since_tizen>
1330 public float PositionZ
1334 return (float)GetValue(PositionZProperty);
1338 SetValue(PositionZProperty, value);
1339 NotifyPropertyChanged();
1344 /// Gets or sets the world position of the view.
1346 /// <since_tizen> 3 </since_tizen>
1347 public Vector3 WorldPosition
1351 Vector3 temp = new Vector3(0.0f, 0.0f, 0.0f);
1352 var pValue = GetProperty(View.Property.WorldPosition);
1360 /// Gets or sets the orientation of the view.<br />
1361 /// The view's orientation is the rotation from its default orientation, and the rotation is centered around its anchor-point.<br />
1365 /// This is an asynchronous method.
1368 /// Animatable - This property can be animated using <c>Animation</c> class.
1371 /// <since_tizen> 3 </since_tizen>
1372 public Rotation Orientation
1376 return (Rotation)GetValue(OrientationProperty);
1380 SetValue(OrientationProperty, value);
1381 NotifyPropertyChanged();
1386 /// Gets or sets the world orientation of the view.<br />
1388 /// <since_tizen> 3 </since_tizen>
1389 public Rotation WorldOrientation
1393 Rotation temp = new Rotation();
1394 var pValue = GetProperty(View.Property.WorldOrientation);
1402 /// Gets or sets the scale factor applied to the view.<br />
1406 /// Animatable - This property can be animated using <c>Animation</c> class.
1408 /// The property cascade chaining set is possible. For example, this (view.Scale.X = 0.1f;) is possible.
1410 /// <since_tizen> 3 </since_tizen>
1411 public Vector3 Scale
1415 Vector3 temp = (Vector3)GetValue(ScaleProperty);
1416 return new Vector3(OnScaleChanged, temp.X, temp.Y, temp.Z);
1420 SetValue(ScaleProperty, value);
1421 NotifyPropertyChanged();
1426 /// Gets or sets the scale X factor applied to the view.
1430 /// Animatable - This property can be animated using <c>Animation</c> class.
1433 /// <since_tizen> 3 </since_tizen>
1438 return (float)GetValue(ScaleXProperty);
1442 SetValue(ScaleXProperty, value);
1443 NotifyPropertyChanged();
1448 /// Gets or sets the scale Y factor applied to the view.
1452 /// Animatable - This property can be animated using <c>Animation</c> class.
1455 /// <since_tizen> 3 </since_tizen>
1460 return (float)GetValue(ScaleYProperty);
1464 SetValue(ScaleYProperty, value);
1465 NotifyPropertyChanged();
1470 /// Gets or sets the scale Z factor applied to the view.
1474 /// Animatable - This property can be animated using <c>Animation</c> class.
1477 /// <since_tizen> 3 </since_tizen>
1482 return (float)GetValue(ScaleZProperty);
1486 SetValue(ScaleZProperty, value);
1487 NotifyPropertyChanged();
1492 /// Gets the world scale of the view.
1494 /// <since_tizen> 3 </since_tizen>
1495 public Vector3 WorldScale
1499 Vector3 temp = new Vector3(0.0f, 0.0f, 0.0f);
1500 var pValue = GetProperty(View.Property.WorldScale);
1508 /// Retrieves the visibility flag of the view.
1512 /// If the view is not visible, then the view and its children will not be rendered.
1513 /// 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.
1516 /// Animatable - This property can be animated using <c>Animation</c> class.
1519 /// <since_tizen> 3 </since_tizen>
1520 public bool Visibility
1525 var pValue = GetProperty(View.Property.VISIBLE);
1526 pValue.Get(out temp);
1533 /// Gets the view's world color.
1535 /// <since_tizen> 3 </since_tizen>
1536 public Vector4 WorldColor
1540 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
1541 var pValue = GetProperty(View.Property.WorldColor);
1549 /// Gets or sets the view's name.
1551 /// <since_tizen> 3 </since_tizen>
1556 return (string)GetValue(NameProperty);
1560 SetValue(NameProperty, value);
1561 NotifyPropertyChanged();
1566 /// Get the number of children held by the view.
1568 /// <since_tizen> 3 </since_tizen>
1569 public new uint ChildCount
1573 return Convert.ToUInt32(Children.Count);
1578 /// Gets the view's ID.
1581 /// <since_tizen> 3 </since_tizen>
1591 /// Gets or sets the status of whether the view should emit touch or hover signals.
1593 /// <since_tizen> 3 </since_tizen>
1594 public bool Sensitive
1598 return (bool)GetValue(SensitiveProperty);
1602 SetValue(SensitiveProperty, value);
1603 NotifyPropertyChanged();
1608 /// 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.
1610 /// <since_tizen> 3 </since_tizen>
1611 public bool LeaveRequired
1615 return (bool)GetValue(LeaveRequiredProperty);
1619 SetValue(LeaveRequiredProperty, value);
1620 NotifyPropertyChanged();
1625 /// Gets or sets the status of whether a child view inherits it's parent's orientation.
1627 /// <since_tizen> 3 </since_tizen>
1628 public bool InheritOrientation
1632 return (bool)GetValue(InheritOrientationProperty);
1636 SetValue(InheritOrientationProperty, value);
1637 NotifyPropertyChanged();
1642 /// Gets or sets the status of whether a child view inherits it's parent's scale.
1644 /// <since_tizen> 3 </since_tizen>
1645 public bool InheritScale
1649 return (bool)GetValue(InheritScaleProperty);
1653 SetValue(InheritScaleProperty, value);
1654 NotifyPropertyChanged();
1659 /// Gets or sets the status of how the view and its children should be drawn.<br />
1660 /// Not all views are renderable, but DrawMode can be inherited from any view.<br />
1661 /// 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 />
1662 /// If DrawMode.Overlay2D is used, the view and its children will be drawn as a 2D overlay.<br />
1663 /// Overlay views are drawn in a separate pass, after all non-overlay views within the layer.<br />
1664 /// For overlay views, the drawing order is with respect to tree levels of views, and depth-testing will not be used.<br />
1666 /// <since_tizen> 3 </since_tizen>
1667 public DrawModeType DrawMode
1671 return (DrawModeType)GetValue(DrawModeProperty);
1675 SetValue(DrawModeProperty, value);
1676 NotifyPropertyChanged();
1681 /// Gets or sets the relative to parent size factor of the view.<br />
1682 /// This factor is only used when ResizePolicyType is set to either: ResizePolicyType.SizeRelativeToParent or ResizePolicyType.SizeFixedOffsetFromParent.<br />
1683 /// This view's size is set to the view's size multiplied by or added to this factor, depending on ResizePolicyType.<br />
1686 /// The property cascade chaining set is possible. For example, this (view.DecorationBoundingBox.X = 0.1f;) is possible.
1688 /// <since_tizen> 3 </since_tizen>
1689 [Obsolete("Deprecated. Since Tizen.NUI.ResizePolicyType is deprecated, SizeModeFactor is no longer supported. Instead, please use parent view having Tizen.NUI.RelativeLayout as its Layout.")]
1690 public Vector3 SizeModeFactor
1694 Vector3 temp = (Vector3)GetValue(SizeModeFactorProperty);
1695 return new Vector3(OnSizeModeFactorChanged, temp.X, temp.Y, temp.Z);
1699 SetValue(SizeModeFactorProperty, value);
1700 NotifyPropertyChanged();
1705 /// Gets or sets the width resize policy to be used.
1707 /// <since_tizen> 3 </since_tizen>
1708 [Obsolete("Deprecated. Please use WidthSpecification instead.")]
1709 public ResizePolicyType WidthResizePolicy
1713 return (ResizePolicyType)GetValue(WidthResizePolicyProperty);
1717 SetValue(WidthResizePolicyProperty, value);
1718 NotifyPropertyChanged();
1723 /// Gets or sets the height resize policy to be used.
1725 /// <since_tizen> 3 </since_tizen>
1726 [Obsolete("Deprecated. Please use HeightSpecification instead.")]
1727 public ResizePolicyType HeightResizePolicy
1731 return (ResizePolicyType)GetValue(HeightResizePolicyProperty);
1735 SetValue(HeightResizePolicyProperty, value);
1736 NotifyPropertyChanged();
1741 /// Gets or sets the policy to use when setting size with size negotiation.<br />
1742 /// Defaults to SizeScalePolicyType.UseSizeSet.<br />
1744 /// <since_tizen> 3 </since_tizen>
1745 public SizeScalePolicyType SizeScalePolicy
1749 return (SizeScalePolicyType)GetValue(SizeScalePolicyProperty);
1753 SetValue(SizeScalePolicyProperty, value);
1754 NotifyPropertyChanged();
1759 /// Gets or sets the status of whether the width size is dependent on the height size.
1761 /// <since_tizen> 3 </since_tizen>
1762 public bool WidthForHeight
1766 return (bool)GetValue(WidthForHeightProperty);
1770 SetValue(WidthForHeightProperty, value);
1771 NotifyPropertyChanged();
1776 /// Gets or sets the status of whether the height size is dependent on the width size.
1778 /// <since_tizen> 3 </since_tizen>
1779 public bool HeightForWidth
1783 return (bool)GetValue(HeightForWidthProperty);
1787 SetValue(HeightForWidthProperty, value);
1788 NotifyPropertyChanged();
1793 /// Gets or sets the padding for use in layout.
1796 /// The property cascade chaining set is possible. For example, this (view.Padding.X = 0.1f;) is possible.
1798 /// <since_tizen> 5 </since_tizen>
1799 public Extents Padding
1803 // If View has a Layout then padding in stored in the base Layout class
1806 return Layout.Padding;
1810 Extents temp = (Extents)GetValue(PaddingProperty);
1811 return new Extents(OnPaddingChanged, temp.Start, temp.End, temp.Top, temp.Bottom);
1813 // Two return points to prevent creating a zeroed Extent native object before assignment
1817 Extents padding = value;
1820 // Layout set so store Padding in LayoutItem instead of in View.
1821 // If View stores the Padding value then Legacy Size Negotiation will overwrite
1822 // the position and sizes measure in the Layouting.
1823 Layout.Padding = value;
1824 // If Layout is a LayoutItem then it could be a View that handles it's own padding.
1825 // Let the View keeps it's padding. Still store Padding in Layout to reduce code paths.
1826 if (typeof(LayoutGroup).IsAssignableFrom(Layout.GetType())) // If a Layout container of some kind.
1828 padding = new Extents(0, 0, 0, 0); // Reset value stored in View.
1832 SetValue(PaddingProperty, padding);
1833 NotifyPropertyChanged();
1838 /// Gets or sets the minimum size the view can be assigned in size negotiation.
1840 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
1842 /// The property cascade chaining set is possible. For example, this (view.MinimumSize.Width = 1;) is possible.
1844 /// <since_tizen> 3 </since_tizen>
1845 public Size2D MinimumSize
1849 Size2D tmp = (Size2D)GetValue(MinimumSizeProperty);
1850 return new Size2D(OnMinimumSizeChanged, tmp.Width, tmp.Height);
1856 throw new ArgumentNullException(nameof(value));
1860 // Note: it only works if minimum size is >= than natural size.
1861 // To force the size it should be done through the width&height spec or Size2D.
1862 layout.MinimumWidth = new Tizen.NUI.LayoutLength(value.Width);
1863 layout.MinimumHeight = new Tizen.NUI.LayoutLength(value.Height);
1864 layout.RequestLayout();
1866 SetValue(MinimumSizeProperty, value);
1867 NotifyPropertyChanged();
1872 /// Gets or sets the maximum size the view can be assigned in size negotiation.
1875 /// The property cascade chaining set is possible. For example, this (view.MaximumSize.Width = 1;) is possible.
1877 /// <since_tizen> 3 </since_tizen>
1878 public Size2D MaximumSize
1882 Size2D tmp = (Size2D)GetValue(MaximumSizeProperty);
1883 return new Size2D(OnMaximumSizeChanged, tmp.Width, tmp.Height);
1887 // We don't have Layout.Maximum(Width|Height) so we cannot apply it to layout.
1888 // MATCH_PARENT spec + parent container size can be used to limit
1891 layout.RequestLayout();
1893 SetValue(MaximumSizeProperty, value);
1894 NotifyPropertyChanged();
1899 /// Gets or sets whether a child view inherits it's parent's position.<br />
1900 /// Default is to inherit.<br />
1901 /// 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 />
1903 /// <since_tizen> 3 </since_tizen>
1904 public bool InheritPosition
1908 return (bool)GetValue(InheritPositionProperty);
1912 SetValue(InheritPositionProperty, value);
1913 NotifyPropertyChanged();
1918 /// Gets or sets the clipping behavior (mode) of it's children.
1920 /// <since_tizen> 3 </since_tizen>
1921 public ClippingModeType ClippingMode
1925 return (ClippingModeType)GetValue(ClippingModeProperty);
1929 SetValue(ClippingModeProperty, value);
1930 NotifyPropertyChanged();
1935 /// Gets the number of renderers held by the view.
1937 /// <since_tizen> 3 </since_tizen>
1938 public uint RendererCount
1942 return GetRendererCount();
1947 /// Deprecated in API5; Will be removed in API8. Please use PivotPoint instead!
1950 /// The property cascade chaining set is possible. For example, this (view.AnchorPoint.X = 0.1f;) is possible.
1952 /// <since_tizen> 3 </since_tizen>
1953 [Obsolete("Deprecated in API5; Will be removed in API8. Please use PivotPoint instead! " +
1955 "View view = new View(); " +
1956 "view.PivotPoint = PivotPoint.Center; " +
1957 "view.PositionUsesPivotPoint = true;")]
1958 [EditorBrowsable(EditorBrowsableState.Never)]
1959 public Position AnchorPoint
1963 Position temp = new Position(0.0f, 0.0f, 0.0f);
1964 var pValue = GetProperty(View.Property.AnchorPoint);
1967 Position ret = new Position(OnAnchorPointChanged, temp.X, temp.Y, temp.Z);
1973 var temp = new Tizen.NUI.PropertyValue(value);
1974 SetProperty(View.Property.AnchorPoint, temp);
1976 NotifyPropertyChanged();
1981 /// Sets the size of a view for the width, the height and the depth.<br />
1982 /// Geometry can be scaled to fit within this area.<br />
1983 /// This does not interfere with the view's scale factor.<br />
1984 /// The views default depth is the minimum of width and height.<br />
1988 /// Animatable - This property can be animated using <c>Animation</c> class.
1990 /// The property cascade chaining set is possible. For example, this (view.Size.Width = 1.0f;) is possible.
1992 /// <since_tizen> 5 </since_tizen>
1997 Size tmp = (Size)GetValue(SizeProperty);
1998 return new Size(OnSizeChanged, tmp.Width, tmp.Height, tmp.Depth);
2002 SetValue(SizeProperty, value);
2003 NotifyPropertyChanged();
2008 /// Deprecated in API5; Will be removed in API8. Please use 'Container GetParent() for derived class' instead!
2010 /// <since_tizen> 3 </since_tizen>
2011 [Obsolete("Deprecated in API5; Will be removed in API8. Please use 'Container GetParent() for derived class' instead! " +
2013 "Container parent = view.GetParent(); " +
2014 "View view = parent as View;")]
2015 [EditorBrowsable(EditorBrowsableState.Never)]
2016 public new View Parent
2021 IntPtr cPtr = Interop.Actor.GetParent(SwigCPtr);
2022 HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
2023 BaseHandle basehandle = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle);
2025 if (basehandle is Layer layer)
2027 ret = new View(Layer.getCPtr(layer).Handle, false);
2028 NUILog.Error("This Parent property is deprecated, should do not be used");
2032 ret = basehandle as View;
2035 Interop.BaseHandle.DeleteBaseHandle(CPtr);
2036 CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
2038 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
2044 /// Gets/Sets whether inherit parent's the layout Direction.
2046 /// <since_tizen> 4 </since_tizen>
2047 public bool InheritLayoutDirection
2051 return (bool)GetValue(InheritLayoutDirectionProperty);
2055 SetValue(InheritLayoutDirectionProperty, value);
2056 NotifyPropertyChanged();
2061 /// Gets/Sets the layout Direction.
2063 /// <since_tizen> 4 </since_tizen>
2064 public ViewLayoutDirectionType LayoutDirection
2068 return (ViewLayoutDirectionType)GetValue(LayoutDirectionProperty);
2072 SetValue(LayoutDirectionProperty, value);
2073 NotifyPropertyChanged();
2074 layout?.RequestLayout();
2079 /// Gets or sets the Margin for use in layout.
2082 /// Margin property is supported by Layout algorithms and containers.
2083 /// Please Set Layout if you want to use Margin property.
2084 /// The property cascade chaining set is possible. For example, this (view.Margin.X = 0.1f;) is possible.
2086 /// <since_tizen> 4 </since_tizen>
2087 public Extents Margin
2091 // If View has a Layout then margin is stored in Layout.
2094 return Layout.Margin;
2098 // If Layout not set then return margin stored in View.
2099 Extents temp = (Extents)GetValue(MarginProperty);
2100 return new Extents(OnMarginChanged, temp.Start, temp.End, temp.Top, temp.Bottom);
2102 // Two return points to prevent creating a zeroed Extent native object before assignment
2108 // Layout set so store Margin in LayoutItem instead of View.
2109 // If View stores the Margin too then the Legacy Size Negotiation will
2110 // overwrite the position and size values measured in the Layouting.
2111 Layout.Margin = value;
2112 SetValue(MarginProperty, new Extents(0, 0, 0, 0));
2113 layout?.RequestLayout();
2117 SetValue(MarginProperty, value);
2119 NotifyPropertyChanged();
2120 layout?.RequestLayout();
2125 /// The required policy for this dimension, <see cref="LayoutParamPolicies"/> values or exact value.
2129 /// // matchParentView matches its size to its parent size.
2130 /// matchParentView.WidthSpecification = LayoutParamPolicies.MatchParent;
2131 /// matchParentView.HeightSpecification = LayoutParamPolicies.MatchParent;
2133 /// // wrapContentView wraps its children with their desired size.
2134 /// wrapContentView.WidthSpecification = LayoutParamPolicies.WrapContent;
2135 /// wrapContentView.HeightSpecification = LayoutParamPolicies.WrapContent;
2137 /// // exactSizeView shows itself with an exact size.
2138 /// exactSizeView.WidthSpecification = 100;
2139 /// exactSizeView.HeightSpecification = 100;
2142 /// <since_tizen> 6 </since_tizen>
2143 public int WidthSpecification
2151 if (value == widthPolicy)
2154 widthPolicy = value;
2155 if (widthPolicy >= 0)
2157 if (heightPolicy >= 0) // Policy an exact value
2159 // Create Size2D only both _widthPolicy and _heightPolicy are set.
2160 Size2D = new Size2D(widthPolicy, heightPolicy);
2165 if (value == LayoutParamPolicies.MatchParent)
2167 SetValue(WidthResizePolicyProperty, ResizePolicyType.FillToParent);
2168 NotifyPropertyChanged();
2170 else if (value == LayoutParamPolicies.WrapContent)
2172 SetValue(WidthResizePolicyProperty, ResizePolicyType.FitToChildren);
2173 NotifyPropertyChanged();
2176 layout?.RequestLayout();
2181 /// The required policy for this dimension, <see cref="LayoutParamPolicies"/> values or exact value.
2185 /// // matchParentView matches its size to its parent size.
2186 /// matchParentView.WidthSpecification = LayoutParamPolicies.MatchParent;
2187 /// matchParentView.HeightSpecification = LayoutParamPolicies.MatchParent;
2189 /// // wrapContentView wraps its children with their desired size.
2190 /// wrapContentView.WidthSpecification = LayoutParamPolicies.WrapContent;
2191 /// wrapContentView.HeightSpecification = LayoutParamPolicies.WrapContent;
2193 /// // exactSizeView shows itself with an exact size.
2194 /// exactSizeView.WidthSpecification = 100;
2195 /// exactSizeView.HeightSpecification = 100;
2198 /// <since_tizen> 6 </since_tizen>
2199 public int HeightSpecification
2203 return heightPolicy;
2207 if (value == heightPolicy)
2210 heightPolicy = value;
2211 if (heightPolicy >= 0)
2213 if (widthPolicy >= 0) // Policy an exact value
2215 // Create Size2D only both _widthPolicy and _heightPolicy are set.
2216 Size2D = new Size2D(widthPolicy, heightPolicy);
2221 if (value == LayoutParamPolicies.MatchParent)
2223 SetValue(HeightResizePolicyProperty, ResizePolicyType.FillToParent);
2224 NotifyPropertyChanged();
2226 else if (value == LayoutParamPolicies.WrapContent)
2228 SetValue(HeightResizePolicyProperty, ResizePolicyType.FitToChildren);
2229 NotifyPropertyChanged();
2232 layout?.RequestLayout();
2237 /// Gets the List of transitions for this View.
2239 /// <since_tizen> 6 </since_tizen>
2240 public Dictionary<TransitionCondition, TransitionList> LayoutTransitions
2244 if (layoutTransitions == null)
2246 layoutTransitions = new Dictionary<TransitionCondition, TransitionList>();
2248 return layoutTransitions;
2253 /// Sets a layout transitions for this View.
2255 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
2257 /// Use LayoutTransitions to receive a collection of LayoutTransitions set on the View.
2259 /// <since_tizen> 6 </since_tizen>
2260 public LayoutTransition LayoutTransition
2264 return layoutTransition;
2270 throw new global::System.ArgumentNullException(nameof(value));
2272 if (layoutTransitions == null)
2274 layoutTransitions = new Dictionary<TransitionCondition, TransitionList>();
2277 LayoutTransitionsHelper.AddTransitionForCondition(layoutTransitions, value.Condition, value, true);
2279 AttachTransitionsToChildren(value);
2281 layoutTransition = value;
2286 /// Deprecated in API5; Will be removed in API8. Please use Padding instead.
2289 /// The property cascade chaining set is possible. For example, this (view.DecorationBoundingBox.X = 0.1f;) is possible.
2291 /// <since_tizen> 4 </since_tizen>
2292 [Obsolete("Deprecated in API5; Will be removed in API8. Please use Padding instead.")]
2293 [EditorBrowsable(EditorBrowsableState.Never)]
2294 public Extents PaddingEX
2298 Extents temp = new Extents(0, 0, 0, 0);
2299 var pValue = GetProperty(View.Property.PADDING);
2302 Extents ret = new Extents(OnPaddingEXChanged, temp.Start, temp.End, temp.Top, temp.Bottom);
2308 var temp = new Tizen.NUI.PropertyValue(value);
2309 SetProperty(View.Property.PADDING, temp);
2311 NotifyPropertyChanged();
2312 layout?.RequestLayout();
2317 /// The Color of View. This is an RGBA value.
2321 /// Animatable - This property can be animated using <c>Animation</c> class.
2323 /// The property cascade chaining set is possible. For example, this (view.Color.X = 0.1f;) is possible.
2325 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
2326 [EditorBrowsable(EditorBrowsableState.Never)]
2331 Color temp = (Color)GetValue(ColorProperty);
2332 return new Color(OnColorChanged, temp.R, temp.G, temp.B, temp.A);
2336 SetValue(ColorProperty, value);
2337 NotifyPropertyChanged();
2342 /// Set the layout on this View. Replaces any existing Layout.
2345 /// If this Layout is set as null explicitly, it means this View itself and it's child Views will not use Layout anymore.
2347 /// <since_tizen> 6 </since_tizen>
2348 public LayoutItem Layout
2356 // Do nothing if layout provided is already set on this View.
2357 if (value == layout)
2362 LayoutingDisabled = false;
2365 // If new layout being set already has a owner then that owner receives a replacement default layout.
2366 // First check if the layout to be set already has a owner.
2367 if (value?.Owner != null)
2369 // Previous owner of the layout gets a default layout as a replacement.
2370 value.Owner.Layout = new AbsoluteLayout();
2372 // Copy Margin and Padding to replacement LayoutGroup.
2373 if (value.Owner.Layout != null)
2375 value.Owner.Layout.Margin = value.Margin;
2376 value.Owner.Layout.Padding = value.Padding;
2380 // Copy Margin and Padding to new layout being set or restore padding and margin back to
2381 // View if no replacement. Previously margin and padding values would have been moved from
2382 // the View to the layout.
2383 if (layout != null) // Existing layout
2387 // Existing layout being replaced so copy over margin and padding values.
2388 value.Margin = layout.Margin;
2389 value.Padding = layout.Padding;
2393 // Layout not being replaced so restore margin and padding to View.
2394 SetValue(MarginProperty, layout.Margin);
2395 SetValue(PaddingProperty, layout.Padding);
2396 NotifyPropertyChanged();
2401 // First Layout to be added to the View hence copy
2403 // Do not try to set Margins or Padding on a null Layout (when a layout is being removed from a View)
2406 Extents margin = Margin;
2407 Extents padding = Padding;
2408 if (margin.Top != 0 || margin.Bottom != 0 || margin.Start != 0 || margin.End != 0)
2410 // If View already has a margin set then store it in Layout instead.
2411 value.Margin = margin;
2412 SetValue(MarginProperty, new Extents(0, 0, 0, 0));
2413 NotifyPropertyChanged();
2416 if (padding.Top != 0 || padding.Bottom != 0 || padding.Start != 0 || padding.End != 0)
2418 // If View already has a padding set then store it in Layout instead.
2419 value.Padding = padding;
2421 // If Layout is a LayoutItem then it could be a View that handles it's own padding.
2422 // Let the View keeps it's padding. Still store Padding in Layout to reduce code paths.
2423 if (typeof(LayoutGroup).IsAssignableFrom(value.GetType()))
2425 SetValue(PaddingProperty, new Extents(0, 0, 0, 0));
2426 NotifyPropertyChanged();
2432 // Remove existing layout from it's parent layout group.
2435 value.SetPositionByLayout = !excludeLayouting;
2437 // Set layout to this view
2443 /// The weight of the View, used to share available space in a layout with siblings.
2445 /// <since_tizen> 6 </since_tizen>
2455 layout?.RequestLayout();
2460 /// Whether to load the BackgroundImage synchronously.
2461 /// If not specified, the default is false, i.e. the BackgroundImage is loaded asynchronously.
2462 /// Note: For Normal Quad images only.
2464 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
2465 [EditorBrowsable(EditorBrowsableState.Never)]
2466 public bool BackgroundImageSynchronosLoading
2470 return backgroundImageSynchronosLoading;
2474 backgroundImageSynchronosLoading = value;
2476 string bgUrl = null;
2477 var pValue = Background.Find(ImageVisualProperty.URL);
2478 pValue?.Get(out bgUrl);
2481 if (!string.IsNullOrEmpty(bgUrl))
2483 PropertyMap bgMap = this.Background;
2484 var temp = new PropertyValue(backgroundImageSynchronosLoading);
2485 bgMap.Add("synchronousLoading", temp);
2492 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
2493 [EditorBrowsable(EditorBrowsableState.Never)]
2494 public Vector2 UpdateSizeHint
2498 return (Vector2)GetValue(UpdateSizeHintProperty);
2502 SetValue(UpdateSizeHintProperty, value);
2503 NotifyPropertyChanged();
2508 /// Enable/Disable ControlState propagation for children.
2509 /// It is false by default.
2510 /// If the View needs to share ControlState with descendants, please set it true.
2511 /// Please note that, changing the value will also changes children's EnableControlStatePropagation value recursively.
2513 [EditorBrowsable(EditorBrowsableState.Never)]
2514 public bool EnableControlStatePropagation
2516 get => themeData?.controlStatePropagation ?? false;
2519 if (EnableControlStatePropagation == value) return;
2521 if (themeData == null) themeData = new ThemeData();
2523 themeData.controlStatePropagation = value;
2525 foreach (View child in Children)
2527 child.EnableControlStatePropagation = value;
2533 /// By default, it is false in View, true in Control.
2534 /// Note that if the value is true, the View will be a touch receptor.
2536 [EditorBrowsable(EditorBrowsableState.Never)]
2537 public bool EnableControlState
2541 return (bool)GetValue(EnableControlStateProperty);
2545 SetValue(EnableControlStateProperty, value);
2550 /// Whether the actor grab all touches even if touch leaves its boundary.
2552 /// <returns>true, if it grab all touch after start</returns>
2553 [EditorBrowsable(EditorBrowsableState.Never)]
2554 public bool GrabTouchAfterLeave
2559 var pValue = GetProperty(View.Property.CaptureAllTouchAfterStart);
2560 pValue.Get(out temp);
2566 var temp = new Tizen.NUI.PropertyValue(value);
2567 SetProperty(View.Property.CaptureAllTouchAfterStart, temp);
2569 NotifyPropertyChanged();
2574 /// Determines which blend equation will be used to render renderers of this actor.
2576 /// <returns>blend equation enum currently assigned</returns>
2577 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
2578 [EditorBrowsable(EditorBrowsableState.Never)]
2579 public BlendEquationType BlendEquation
2584 var pValue = GetProperty(View.Property.BlendEquation);
2585 pValue.Get(out temp);
2587 return (BlendEquationType)temp;
2591 var temp = new Tizen.NUI.PropertyValue((int)value);
2592 SetProperty(View.Property.BlendEquation, temp);
2594 NotifyPropertyChanged();
2599 /// If the value is true, the View will change its style as the theme changes.
2600 /// It is false by default, but turned to true when setting StyleName (by setting property or using specified constructor).
2602 /// <since_tizen> 9 </since_tizen>
2603 public bool ThemeChangeSensitive
2605 get => (bool)GetValue(ThemeChangeSensitiveProperty);
2606 set => SetValue(ThemeChangeSensitiveProperty, value);
2610 /// Create Style, it is abstract function and must be override.
2612 [EditorBrowsable(EditorBrowsableState.Never)]
2613 protected virtual ViewStyle CreateViewStyle()
2615 return new ViewStyle();
2619 /// Called after the View's ControlStates changed.
2621 /// <param name="controlStateChangedInfo">The information including state changed variables.</param>
2622 [EditorBrowsable(EditorBrowsableState.Never)]
2623 protected virtual void OnControlStateChanged(ControlStateChangedEventArgs controlStateChangedInfo)
2629 [EditorBrowsable(EditorBrowsableState.Never)]
2630 protected virtual void OnThemeChanged(object sender, ThemeChangedEventArgs e)
2636 /// Apply style instance to the view.
2637 /// Basically it sets the bindable property to the value of the bindable property with same name in the style.
2639 /// <since_tizen> 9 </since_tizen>
2640 public virtual void ApplyStyle(ViewStyle viewStyle)
2642 if (viewStyle == null || themeData?.viewStyle == viewStyle) return;
2644 if (themeData == null) themeData = new ThemeData();
2646 themeData.viewStyle = viewStyle;
2648 if (viewStyle.DirtyProperties == null || viewStyle.DirtyProperties.Count == 0)
2654 BindableProperty.GetBindablePropertysOfType(GetType(), out var bindablePropertyOfView);
2656 if (bindablePropertyOfView == null)
2661 var dirtyStyleProperties = new BindableProperty[viewStyle.DirtyProperties.Count];
2662 viewStyle.DirtyProperties.CopyTo(dirtyStyleProperties);
2664 foreach (var sourceProperty in dirtyStyleProperties)
2666 var sourceValue = viewStyle.GetValue(sourceProperty);
2668 if (sourceValue == null)
2673 bindablePropertyOfView.TryGetValue(sourceProperty.PropertyName, out var destinationProperty);
2675 if (destinationProperty != null)
2677 SetValue(destinationProperty, sourceValue);
2683 /// Get whether the View is culled or not.
2684 /// True means that the View is out of the view frustum.
2687 /// Hidden-API (Inhouse-API).
2689 [EditorBrowsable(EditorBrowsableState.Never)]
2695 var pValue = GetProperty(View.Property.Culled);
2696 pValue.Get(out temp);
2703 /// Set or Get TransitionOptions for the page transition.
2704 /// This property is used to define how this view will be transitioned during Page switching.
2706 /// <since_tizen> 9 </since_tizen>
2707 public TransitionOptions TransitionOptions
2711 transitionOptions = value;
2715 return transitionOptions;