Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NUI] Fix Animation issue for Background and BoxShadow color #6413

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 8 additions & 43 deletions src/Tizen.NUI/src/internal/Common/PropertyHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ internal static class PropertyHelper
{
private static readonly Dictionary<string, VisualPropertyData> visualPropertyTable = new Dictionary<string, VisualPropertyData>()
{
{ "backgroundColor", new VisualPropertyData(View.Property.BACKGROUND, ColorVisualProperty.MixColor, ObjectColorToVector3, PropertyValueColorToVector3,
new VisualPropertyData(View.Property.BACKGROUND, Visual.Property.Opacity, ObjectColorToAlpha, PropertyValueColorToAlpha)) },
{ "backgroundColor", new VisualPropertyData(View.Property.BACKGROUND, ColorVisualProperty.MixColor, ObjectColorToVector4, PropertyValueColorToVector4) },
{ "backgroundOpacity", new VisualPropertyData(View.Property.BACKGROUND, Visual.Property.Opacity, ObjectIntToFloat) },
{ "boxShadow.BlurRadius", new VisualPropertyData(View.Property.SHADOW, ColorVisualProperty.BlurRadius) },
{ "boxShadow.Color", new VisualPropertyData(View.Property.SHADOW, ColorVisualProperty.MixColor, ObjectColorToVector3, PropertyValueColorToVector3,
new VisualPropertyData(View.Property.SHADOW, Visual.Property.Opacity, ObjectColorToAlpha, PropertyValueColorToAlpha)) },
{ "boxShadow.Color", new VisualPropertyData(View.Property.SHADOW, ColorVisualProperty.MixColor, ObjectColorToVector4, PropertyValueColorToVector4) },
{ "boxShadow.CornerRadius", new VisualPropertyData(View.Property.SHADOW, Visual.Property.CornerRadius, ObjectIntToFloat) },
{ "boxShadow.Offset", new VisualPropertyData(View.Property.SHADOW, (int)VisualTransformPropertyType.Offset) },
{ "boxShadow.Opacity", new VisualPropertyData(View.Property.SHADOW, Visual.Property.Opacity, ObjectIntToFloat) },
Expand Down Expand Up @@ -141,24 +139,24 @@ private static string LowerFirstLetter(string original)
return sb.ToString();
}

private static object ObjectColorToVector3(object value)
private static object ObjectColorToVector4(object value)
{
if (value is Vector4)
{
var colorValue = value as Vector4;
return new Vector3(colorValue.R, colorValue.G, colorValue.B);
return new Vector4(colorValue.R, colorValue.G, colorValue.B, colorValue.A);
}

if (value is Color)
{
var colorValue = value as Color;
return new Vector3(colorValue.R, colorValue.G, colorValue.B);
return new Vector4(colorValue.R, colorValue.G, colorValue.B, colorValue.A);
}

return null;
}

private static PropertyValue PropertyValueColorToVector3(PropertyValue value)
private static PropertyValue PropertyValueColorToVector4(PropertyValue value)
{
var valueType = value.GetType();

Expand All @@ -169,43 +167,10 @@ private static PropertyValue PropertyValueColorToVector3(PropertyValue value)

var colorValue = new Vector4();
value.Get(colorValue);
using (var v3 = new Vector3(colorValue.R, colorValue.G, colorValue.B))
using (var v4 = new Vector4(colorValue.R, colorValue.G, colorValue.B, colorValue.A))
{
colorValue.Dispose();
return new PropertyValue(v3);
}
}

private static object ObjectColorToAlpha(object value)
{
if (value is Vector4)
{
var colorValue = value as Vector4;
return colorValue.A;
}

if (value is Color)
{
var colorValue = value as Color;
return colorValue.A;
}

return null;
}

private static PropertyValue PropertyValueColorToAlpha(PropertyValue value)
{
var valueType = value.GetType();

if (valueType != PropertyType.Vector4)
{
return null;
}

using (var colorValue = new Vector4())
{
value.Get(colorValue);
return new PropertyValue(colorValue.A);
return new PropertyValue(v4);
}
}

Expand Down
Loading