using System.IO;
using System.Runtime.InteropServices;
using Tizen.NUI.Binding;
+using Tizen.NUI.Xaml;
namespace Tizen.NUI.BaseComponents
{
public const int WrapContent = -2;
}
- /// <summary>
- /// [Draft] Replaced by LayoutParamPolicies, will be removed once occurrences replaced.
- /// </summary>
- internal enum ChildLayoutData
- {
- /// <summary>
- /// Constant which indicates child size should match parent size
- /// </summary>
- MatchParent = LayoutParamPolicies.MatchParent,
- /// <summary>
- /// Constant which indicates parent should take the smallest size possible to wrap it's children with their desired size
- /// </summary>
- WrapContent = LayoutParamPolicies.WrapContent,
- }
-
internal enum ResourceLoadingStatusType
{
Invalid = -1,
/// View is the base class for all views.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- public class View : Container
+ public class View : Container, IResourcesProvider
{
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.MARGIN).Get(temp);
return temp;
});
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty XamlStyleProperty = BindableProperty.Create("XamlStyle", typeof(Style), typeof(View), default(Style), propertyChanged: (bindable, oldvalue, newvalue) => ((View)bindable)._mergedStyle.Style = (Style)newvalue);
/// <summary>
/// Flag to indicate if layout set explicitly via API call or View was automatically given a Layout.
[EditorBrowsable(EditorBrowsableState.Never)]
public static bool layoutingDisabled{get; set;} = true;
+ private MergedStyle mergedStyle = null;
+ internal MergedStyle _mergedStyle
+ {
+ get
+ {
+ if (null == mergedStyle)
+ {
+ mergedStyle = new MergedStyle(GetType(), this);
+ }
+
+ return mergedStyle;
+ }
+ }
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
private LayoutItem _layout; // Exclusive layout assigned to this View.
+
+ // List of transitions paired with the condition that uses the transition.
+ private Dictionary<TransitionCondition, TransitionList> _layoutTransitions;
private int _widthPolicy = LayoutParamPolicies.WrapContent; // Layout width policy
private int _heightPolicy = LayoutParamPolicies.WrapContent; // Layout height policy
private float _weight = 0.0f; // Weighting of child View in a Layout
/// Event when a child is removed.
/// </summary>
/// <since_tizen> 5 </since_tizen>
- public event EventHandler<ChildRemovedEventArgs> ChildRemoved;
+ public new event EventHandler<ChildRemovedEventArgs> ChildRemoved;
/// <summary>
/// Event when a child is added.
/// </summary>
/// <since_tizen> 5 </since_tizen>
- public event EventHandler<ChildAddedEventArgs> ChildAdded;
+ public new event EventHandler<ChildAddedEventArgs> ChildAdded;
/// <summary>
/// An event for the KeyInputFocusGained signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
CONTROL_PROPERTY_END_INDEX = CONTROL_PROPERTY_START_INDEX + 1000
}
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool IsResourcesCreated
+ {
+ get
+ {
+ return Application.Current.IsResourcesCreated;
+ }
+ }
+
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ResourceDictionary XamlResources
+ {
+ get
+ {
+ return Application.Current.XamlResources;
+ }
+ set
+ {
+ Application.Current.XamlResources = value;
+ }
+ }
+
/// <summary>
/// The StyleName, type string.
/// </summary>
/// This means by default others are impossible so it is recommended that NUI object typed properties are configured by their constructor with parameters. <br />
/// For example, this code is working fine : view.Scale = new Vector3( 2.0f, 1.5f, 0.0f); <br />
/// but this will not work! : view.Scale.X = 2.0f; view.Scale.Y = 1.5f; <br />
- /// It may not match the current value in some cases, i.e. when the animation is progressing or the maximum or minimu size is set. <br />
+ /// It may not match the current value in some cases, i.e. when the animation is progressing or the maximum or minimum size is set. <br />
/// </remarks>
/// <since_tizen> 3 </since_tizen>
public Size2D Size2D
// All Views are currently Layouts.
MeasureSpecificationWidth = new MeasureSpecification(new LayoutLength(value.Width), MeasureSpecification.ModeType.Exactly);
MeasureSpecificationHeight = new MeasureSpecification(new LayoutLength(value.Height), MeasureSpecification.ModeType.Exactly);
+ _widthPolicy = value.Width;
+ _heightPolicy = value.Height;
+ _layout?.RequestLayout();
NotifyPropertyChanged();
}
}
}
///<summary>
- /// The required policy for this dimension, ChildLayoutData enum or exact value.
+ /// The required policy for this dimension, LayoutParamPolicies enum or exact value.
///</summary>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ /// <remarks>
+ /// Previously named LayoutWidthSpecification
+ /// </remarks>
[EditorBrowsable(EditorBrowsableState.Never)]
public int WidthSpecification
{
if (_widthPolicy >= 0)
{
_measureSpecificationWidth = new MeasureSpecification( new LayoutLength(value), MeasureSpecification.ModeType.Exactly );
+ //Tizen.NUI.Object.SetProperty(swigCPtr, View.Property.SIZE_WIDTH, new Tizen.NUI.PropertyValue(value));
Size2D.Width = _widthPolicy;
}
_layout?.RequestLayout();
}
///<summary>
- /// The required policy for this dimension, ChildLayoutData enum or exact value.
+ /// The required policy for this dimension, LayoutParamPolicies enum or exact value.
///</summary>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ /// <remarks>
+ /// Previously named LayoutHeightSpecification
+ /// </remarks>
[EditorBrowsable(EditorBrowsableState.Never)]
public int HeightSpecification
{
if (_heightPolicy >= 0)
{
_measureSpecificationHeight = new MeasureSpecification( new LayoutLength(value), MeasureSpecification.ModeType.Exactly );
+ //Tizen.NUI.Object.SetProperty(swigCPtr, View.Property.SIZE_HEIGHT, new Tizen.NUI.PropertyValue(value));
Size2D.Height = _heightPolicy;
}
_layout?.RequestLayout();
}
}
+ ///<summary>
+ /// Gets the List of transitions for this View.
+ ///</summary>
+ /// Hidden-API which is usually used as Inhouse-API. If required to be opened as Public-API, ACR process is needed.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Dictionary<TransitionCondition, TransitionList> LayoutTransitions
+ {
+ get
+ {
+ if (_layoutTransitions == null)
+ {
+ _layoutTransitions = new Dictionary<TransitionCondition, TransitionList>();
+ }
+ return _layoutTransitions;
+ }
+ }
+
+ internal LayoutTransition LayoutTransition
+ {
+ set
+ {
+ if (_layoutTransitions == null)
+ {
+ _layoutTransitions = new Dictionary<TransitionCondition, TransitionList>();
+ }
+ LayoutTransitionsHelper.AddTransitionForCondition(_layoutTransitions,value.Condition,value, true);
+
+ AttachTransitionsToChildren(value);
+ }
+ }
/// <summary>
/// [Obsolete("Please do not use! this will be deprecated")]
}
}
- /// <summary>
- /// Child property to specify desired width
- /// </summary>
- internal int LayoutWidthSpecificationFixed
+ /// <since_tizen> 6 </since_tizen>
+ /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Style XamlStyle
{
get
{
- return _widthPolicy;
+ return (Style)GetValue(XamlStyleProperty);
}
set
{
- _widthPolicy = value;
- _measureSpecificationWidth = new MeasureSpecification(new LayoutLength(value), MeasureSpecification.ModeType.Exactly);
- Size2D.Width = value;
- _layout?.RequestLayout();
+ SetValue(XamlStyleProperty, value);
}
}
/// <summary>
- /// Child property to specify desired height
+ /// The Color of View. This is an RGBA value.
/// </summary>
- internal int LayoutHeightSpecificationFixed
+ /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Color Color
{
- get
- {
- return _heightPolicy;
- }
set
{
- _heightPolicy = value;
- _measureSpecificationHeight = new MeasureSpecification(new LayoutLength(value), MeasureSpecification.ModeType.Exactly);
- Size2D.Height = value;
- _layout?.RequestLayout();
+ SetColor(value);
}
- }
-
- /// <summary>
- /// Child property to specify desired width, use MatchParent/WrapContent)
- /// </summary>
- internal ChildLayoutData LayoutWidthSpecification
- {
get
{
- return (ChildLayoutData)_widthPolicy;
- }
- set
- {
- _widthPolicy = (int)value;
+ return GetCurrentColor();
}
}
/// <summary>
- /// Child property to specify desired height, use MatchParent/WrapContent)
+ /// The color mode of View.
+ /// This specifies whether the View uses its own color, or inherits its parent color.
+ /// The default is ColorMode.UseOwnMultiplyParentColor.
/// </summary>
- internal ChildLayoutData LayoutHeightSpecification
+ internal ColorMode ColorMode
{
- get
+ set
{
- return (ChildLayoutData)_heightPolicy;
+ SetColorMode(value);
}
- set
+ get
{
- _heightPolicy = (int)value;
+ return GetColorMode();
}
}
set
{
_weight = value;
- _layout.RequestLayout();
+ _layout?.RequestLayout();
}
}
- internal bool BackgroundImageSynchronosLoading
+ /// <summary>
+ /// Whether to load the BackgroundImage synchronously.
+ /// If not specified, the default is false, i.e. the BackgroundImage is loaded asynchronously.
+ /// Note: For Normal Quad images only.
+ /// </summary>
+ /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool BackgroundImageSynchronosLoading
{
get
{
/// <summary>
/// Set the layout on this View. Replaces any existing Layout.
/// </summary>
- /// <remarks>
- /// </remarks>
internal LayoutItem Layout
{
get
}
}
+ internal void AttachTransitionsToChildren(LayoutTransition transition)
+ {
+ // Iterate children, adding the transition unless a transition
+ // for the same condition and property has already been
+ // explicitly added.
+ foreach (View view in Children)
+ {
+ LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions,transition.Condition, transition, false);
+ }
+ }
+
internal float ParentOriginX
{
get
public override void Add(View child)
{
bool hasLayout = (_layout != null);
- Log.Info("NUI", "Add:" + child.Name + " to View:" + Name + "which has layout[" + hasLayout + "] + \n");
+ Log.Info("NUI", "Add:" + child.Name + " to View:" + Name + " which has layout[" + hasLayout + "] + \n");
if (null == child)
{
};
ChildAdded(this, e);
}
+ BindableObject.SetInheritedBindingContext(child, this?.BindingContext);
}
}
/// <since_tizen> 4 </since_tizen>
public override void Remove(View child)
{
- bool hasLayout = (_layout != null);
- Log.Info("NUI","Removing View:" + child.Name + "layout[" + hasLayout.ToString() +"]\n");
-
- Interop.Actor.Actor_Remove(swigCPtr, View.getCPtr(child));
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ if (!child || child.GetParent()==null) // Early out if child null.
+ return;
- Children.Remove(child);
- child.InternalParent = null;
+ bool hasLayout = (_layout != null);
+ Log.Info("NUI","Removing View:" + child.Name + " layout[" + hasLayout.ToString() +"]\n");
- if (ChildRemoved != null)
+ // If View has a layout then do a deferred child removal
+ // Actual child removal is performed by the layouting system so
+ // transitions can be completed.
+ if (hasLayout)
{
- ChildRemovedEventArgs e = new ChildRemovedEventArgs
- {
- Removed = child
- };
- ChildRemoved(this, e);
+ (_layout as LayoutGroup)?.RemoveChildFromLayoutGroup( child );
+ }
+ else
+ {
+ RemoveChild(child);
}
}
return ret;
}
- internal void SetColorMode(ColorMode colorMode)
+ /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetColorMode(ColorMode colorMode)
{
Interop.ActorInternal.Actor_SetColorMode(swigCPtr, (int)colorMode);
if (NDalicPINVOKE.SWIGPendingException.Pending)
return ret;
}
- internal void SetBackgroundColor(Vector4 color)
- {
- Interop.ViewInternal.View_SetBackgroundColor(swigCPtr, Vector4.getCPtr(color));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal Vector4 GetBackgroundColor()
- {
- Vector4 ret = new Vector4(Interop.ViewInternal.View_GetBackgroundColor(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal void SetBackgroundImage(Image image)
- {
- Interop.ViewInternal.View_SetBackgroundImage(swigCPtr, Image.getCPtr(image));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
internal ControlKeySignal KeyEventSignal()
{
ControlKeySignal ret = new ControlKeySignal(Interop.ViewSignal.View_KeyEventSignal(swigCPtr), false);
return (IntPtr)swigCPtr;
}
+ internal void RemoveChild(View child)
+ {
+ // Do actual child removal
+ Interop.Actor.Actor_Remove(swigCPtr, View.getCPtr(child));
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
+ Children.Remove(child);
+ child.InternalParent = null;
+
+ if (ChildRemoved != null)
+ {
+ ChildRemovedEventArgs e = new ChildRemovedEventArgs
+ {
+ Removed = child
+ };
+ ChildRemoved(this, e);
+ }
+ }
+
/// <summary>
/// Removes the layout from this View.
/// </summary>
return;
}
+ //_mergedStyle = null;
+
if (type == DisposeTypes.Explicit)
{
//Called by User
private View ConvertIdToView(uint id)
{
- return GetParent()?.FindCurrentChildById(id);
+ View view = GetParent()?.FindCurrentChildById(id);
+
+ //If we can't find the parent's children, find in the top layer.
+ if (!view)
+ {
+ Container parent = GetParent();
+ while ((parent is View) && (parent != null))
+ {
+ parent = parent.GetParent();
+ if (parent is Layer)
+ {
+ view = parent.FindCurrentChildById(id);
+ break;
+ }
+ }
+ }
+
+ return view;
}
private void OnBackgroundResourceLoaded(IntPtr view)
}
}
+
+ private Dictionary<string, Transition> transDictionary = new Dictionary<string, Transition>();
+
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Transition GetTransition(string transitionName)
+ {
+ Transition trans = null;
+ transDictionary.TryGetValue(transitionName, out trans);
+ return trans;
+ }
+
+ private void LoadTransitions()
+ {
+ foreach (string str in transitionNames)
+ {
+ string resourceName = str + ".xaml";
+ Transition trans = null;
+
+ string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
+
+ string likelyResourcePath = resource + "animation/" + resourceName;
+
+ if (File.Exists(likelyResourcePath))
+ {
+ trans = Extensions.LoadObject<Transition>(likelyResourcePath);
+ }
+ if (trans)
+ {
+ transDictionary.Add(trans.Name, trans);
+ }
+ }
+ }
+
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string[] TransitionNames
+ {
+ get
+ {
+ return transitionNames;
+ }
+ set
+ {
+ transitionNames = value;
+ LoadTransitions();
+ }
+ }
+ private string[] transitionNames;
+
internal class BackgroundResourceLoadedEventArgs : EventArgs
{
private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;