Skip to content

Commit

Permalink
[NUI] Add IsUsingXaml flag in properties of View and AnimatedVectorIm…
Browse files Browse the repository at this point in the history
…ageView
  • Loading branch information
dongsug-song committed Apr 19, 2024
1 parent e115d2f commit a810696
Show file tree
Hide file tree
Showing 9 changed files with 4,127 additions and 1,147 deletions.
2 changes: 1 addition & 1 deletion src/Tizen.NUI/Tizen.NUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup>
<DefineConstants>$(DefineConstants);NUI_DEBUG_OFF</DefineConstants>
<DefineConstants>$(DefineConstants);NUI_DEBUG_OFF;REMOVE_READONLY_FOR_BINDABLE_PROPERTY;</DefineConstants>
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 7 additions & 0 deletions src/Tizen.NUI/src/internal/Application/NUICoreBackend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.Collections.Generic;
using Tizen.Applications.CoreBackend;
using Tizen.Applications;
using Tizen.NUI.BaseComponents;

namespace Tizen.NUI
{
Expand Down Expand Up @@ -392,6 +393,12 @@ private void OnInitialized(object source, NUIApplicationInitEventArgs e)

Log.Info("NUI", "NUICorebackend OnPreCreated Called");

#if REMOVE_READONLY_FOR_BINDABLE_PROPERTY
if(NUIApplication.IsUsingXaml)
{
View.CreateBindableProperties();
}
#endif
Tizen.Tracer.Begin("[NUI] OnInitialized(): OnPreCreated event handler");
var preCreateHandler = Handlers[EventType.PreCreated] as Action;
preCreateHandler?.Invoke();
Expand Down
11 changes: 11 additions & 0 deletions src/Tizen.NUI/src/public/Application/NUIWidgetApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ public void AddWidgetType(Dictionary<System.Type, string> widgetTypes)
core?.AddWidgetInfo(widgetTypes);
}

/// <summary>
/// Set to true if XAML is used.
/// This must be called before or immediately after the NUIWidgetApplication constructor is called.
/// The default value is true.
/// </summary>
/// <remarks>
/// This must be called before or immediately after the NUIWidgetApplication constructor is called.
/// </remarks>
[EditorBrowsable(EditorBrowsableState.Never)]
static public bool IsUsingXaml { get; set; } = true;

internal WidgetApplication ApplicationHandle
{
get
Expand Down
115 changes: 105 additions & 10 deletions src/Tizen.NUI/src/public/BaseComponents/AnimatedVectorImageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

using global::System;
using System.ComponentModel;
using Tizen.NUI.Binding;

namespace Tizen.NUI.BaseComponents
{
Expand All @@ -27,6 +28,30 @@ namespace Tizen.NUI.BaseComponents
public partial class AnimatedVectorImageView : LottieAnimationView
{
#region Constructor, Destructor, Dispose

static AnimatedVectorImageView()
{
//to get "IsUsingXaml" feature working at preload, we need to remove readonly for BindableProperty.
//this AnimatedVectorImageView is not preloaded.
if (NUIApplication.IsUsingXaml)
{
ResourceURLProperty = BindableProperty.Create(nameof(ResourceURL), typeof(string), typeof(AnimatedVectorImageView), string.Empty,
propertyChanged: SetInternalResourceURLProperty, defaultValueCreator: GetInternalResourceURLProperty);

ResourceUrlProperty = BindableProperty.Create(nameof(ResourceUrl), typeof(string), typeof(AnimatedVectorImageView), string.Empty,
propertyChanged: SetInternalResourceUrlProperty, defaultValueCreator: GetInternalResourceUrlProperty);

RepeatCountProperty = BindableProperty.Create(nameof(RepeatCount), typeof(int), typeof(AnimatedVectorImageView), 0,
propertyChanged: SetInternalRepeatCountProperty, defaultValueCreator: GetInternalRepeatCountProperty);

CurrentFrameProperty = BindableProperty.Create(nameof(CurrentFrame), typeof(int), typeof(AnimatedVectorImageView), 0,
propertyChanged: SetInternalCurrentFrameProperty, defaultValueCreator: GetInternalCurrentFrameProperty);

RepeatModeProperty = BindableProperty.Create(nameof(RepeatMode), typeof(RepeatModes), typeof(AnimatedVectorImageView), default(RepeatModes),
propertyChanged: SetInternalRepeatModeProperty, defaultValueCreator: GetInternalRepeatModeProperty);
}
}

/// <summary>
/// Construct VectorAnimationView.
/// </summary>
Expand Down Expand Up @@ -80,11 +105,25 @@ public string ResourceURL
{
get
{
return GetValue(ResourceURLProperty) as string;
if (NUIApplication.IsUsingXaml)
{
return GetValue(ResourceURLProperty) as string;
}
else
{
return GetInternalResourceURLProperty(this) as string;
}
}
set
{
SetValue(ResourceURLProperty, value);
if (NUIApplication.IsUsingXaml)
{
SetValue(ResourceURLProperty, value);
}
else
{
SetInternalResourceURLProperty(this, null, value);
}
NotifyPropertyChanged();
}
}
Expand Down Expand Up @@ -117,11 +156,25 @@ private string InternalResourceURL
{
get
{
return GetValue(ResourceUrlProperty) as string;
if (NUIApplication.IsUsingXaml)
{
return GetValue(ResourceUrlProperty) as string;
}
else
{
return GetInternalResourceUrlProperty(this) as string;
}
}
set
{
SetValue(ResourceUrlProperty, value);
if (NUIApplication.IsUsingXaml)
{
SetValue(ResourceUrlProperty, value);
}
else
{
SetInternalResourceUrlProperty(this, null, value);
}
NotifyPropertyChanged();
}
}
Expand Down Expand Up @@ -154,11 +207,25 @@ public int RepeatCount
{
get
{
return (int)GetValue(RepeatCountProperty);
if (NUIApplication.IsUsingXaml)
{
return (int)GetValue(RepeatCountProperty);
}
else
{
return (int)GetInternalRepeatCountProperty(this);
}
}
set
{
SetValue(RepeatCountProperty, value);
if (NUIApplication.IsUsingXaml)
{
SetValue(RepeatCountProperty, value);
}
else
{
SetInternalRepeatCountProperty(this, null, value);
}
NotifyPropertyChanged();
}
}
Expand Down Expand Up @@ -201,11 +268,25 @@ private int totalFrameNum
{
get
{
return (int)GetValue(CurrentFrameProperty);
if (NUIApplication.IsUsingXaml)
{
return (int)GetValue(CurrentFrameProperty);
}
else
{
return (int)GetInternalCurrentFrameProperty(this);
}
}
set
{
SetValue(CurrentFrameProperty, value);
if (NUIApplication.IsUsingXaml)
{
SetValue(CurrentFrameProperty, value);
}
else
{
SetInternalCurrentFrameProperty(this, null, value);
}
NotifyPropertyChanged();
}
}
Expand Down Expand Up @@ -245,11 +326,25 @@ public RepeatModes RepeatMode
{
get
{
return (RepeatModes)GetValue(RepeatModeProperty);
if (NUIApplication.IsUsingXaml)
{
return (RepeatModes)GetValue(RepeatModeProperty);
}
else
{
return (RepeatModes)GetInternalRepeatModeProperty(this);
}
}
set
{
SetValue(RepeatModeProperty, value);
if (NUIApplication.IsUsingXaml)
{
SetValue(RepeatModeProperty, value);
}
else
{
SetInternalRepeatModeProperty(this, null, value);
}
NotifyPropertyChanged();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,84 +26,109 @@ public partial class AnimatedVectorImageView
/// ResourceURLProperty
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ResourceURLProperty = BindableProperty.Create(nameof(ResourceURL), typeof(string), typeof(AnimatedVectorImageView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
#if REMOVE_READONLY_FOR_BINDABLE_PROPERTY
public static BindableProperty ResourceURLProperty = null;
#else
public static readonly BindableProperty ResourceURLProperty = null;
#endif
internal static void SetInternalResourceURLProperty(BindableObject bindable, object oldValue, object newValue)
{
var instance = (Tizen.NUI.BaseComponents.AnimatedVectorImageView)bindable;
instance.InternalResourceURL = (string)newValue;
},
defaultValueCreator: (bindable) =>
}
internal static object GetInternalResourceURLProperty(BindableObject bindable)
{
var instance = (Tizen.NUI.BaseComponents.AnimatedVectorImageView)bindable;
return instance.InternalResourceURL;
});
}

/// <summary>
/// ResourceUrlProperty
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static new readonly BindableProperty ResourceUrlProperty = BindableProperty.Create(nameof(ResourceUrl), typeof(string), typeof(AnimatedVectorImageView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
#if REMOVE_READONLY_FOR_BINDABLE_PROPERTY
public static new BindableProperty ResourceUrlProperty = null;
#else
public static readonly new BindableProperty ResourceUrlProperty = null;
#endif
internal static void SetInternalResourceUrlProperty(BindableObject bindable, object oldValue, object newValue)
{
var instance = (Tizen.NUI.BaseComponents.AnimatedVectorImageView)bindable;
instance.InternalResourceUrl = (string)newValue;
},
defaultValueCreator: (bindable) =>
}
internal static object GetInternalResourceUrlProperty(BindableObject bindable)
{
var instance = (Tizen.NUI.BaseComponents.AnimatedVectorImageView)bindable;
return instance.InternalResourceUrl;
});
}

/// <summary>
/// RepeatCountProperty
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty RepeatCountProperty = BindableProperty.Create(nameof(RepeatCount), typeof(int), typeof(AnimatedVectorImageView), 0, propertyChanged: (bindable, oldValue, newValue) =>
#if REMOVE_READONLY_FOR_BINDABLE_PROPERTY
public static BindableProperty RepeatCountProperty = null;
#else
public static readonly BindableProperty RepeatCountProperty = null;
#endif
internal static void SetInternalRepeatCountProperty(BindableObject bindable, object oldValue, object newValue)
{
var instance = (Tizen.NUI.BaseComponents.AnimatedVectorImageView)bindable;
if (newValue != null)
{
instance.InternalRepeatCount = (int)newValue;
}
},
defaultValueCreator: (bindable) =>
}
internal static object GetInternalRepeatCountProperty(BindableObject bindable)
{
var instance = (Tizen.NUI.BaseComponents.AnimatedVectorImageView)bindable;
return instance.InternalRepeatCount;
});
}

/// <summary>
/// CurrentFrameProperty
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static new readonly BindableProperty CurrentFrameProperty = BindableProperty.Create(nameof(CurrentFrame), typeof(int), typeof(AnimatedVectorImageView), 0, propertyChanged: (bindable, oldValue, newValue) =>
#if REMOVE_READONLY_FOR_BINDABLE_PROPERTY
public static new BindableProperty CurrentFrameProperty = null;
#else
public static readonly new BindableProperty CurrentFrameProperty = null;
#endif
internal static void SetInternalCurrentFrameProperty(BindableObject bindable, object oldValue, object newValue)
{
var instance = (Tizen.NUI.BaseComponents.AnimatedVectorImageView)bindable;
if (newValue != null)
{
instance.InternalCurrentFrame = (int)newValue;
}
},
defaultValueCreator: (bindable) =>
}
internal static object GetInternalCurrentFrameProperty(BindableObject bindable)
{
var instance = (Tizen.NUI.BaseComponents.AnimatedVectorImageView)bindable;
return instance.InternalCurrentFrame;
});
}

/// <summary>
/// RepeatModeProperty
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty RepeatModeProperty = BindableProperty.Create(nameof(RepeatMode), typeof(RepeatModes), typeof(AnimatedVectorImageView), default(RepeatModes), propertyChanged: (bindable, oldValue, newValue) =>
#if REMOVE_READONLY_FOR_BINDABLE_PROPERTY
public static BindableProperty RepeatModeProperty = null;
#else
public static readonly BindableProperty RepeatModeProperty = null;
#endif
static internal void SetInternalRepeatModeProperty(BindableObject bindable, object oldValue, object newValue)
{
var instance = (Tizen.NUI.BaseComponents.AnimatedVectorImageView)bindable;
if (newValue != null)
{
instance.InternalRepeatMode = (Tizen.NUI.BaseComponents.AnimatedVectorImageView.RepeatModes)newValue;
}
},
defaultValueCreator: (bindable) =>
}
static internal object GetInternalRepeatModeProperty(BindableObject bindable)
{
var instance = (Tizen.NUI.BaseComponents.AnimatedVectorImageView)bindable;
return instance.InternalRepeatMode;
});
}
}
}
Loading

0 comments on commit a810696

Please sign in to comment.