2 * Copyright(c) 2019 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.ComponentModel;
24 /// The platform provided shadow drawing for View
26 [EditorBrowsable(EditorBrowsableState.Never)]
27 public class Shadow : TransformablePropertyMap
29 private static readonly Color noColor = new Color(0, 0, 0, 0);
31 private static readonly Color defaultColor = new Color(0, 0, 0, 0.5f);
35 private uint blurRadius;
40 [EditorBrowsable(EditorBrowsableState.Never)]
41 public Shadow() : base()
47 /// The boolean conversion
49 [EditorBrowsable(EditorBrowsableState.Never)]
50 public static implicit operator Shadow(bool value)
52 Shadow shadow = new Shadow()
54 Color = value ? defaultColor : noColor,
59 private void OnColorChanged(float r, float g, float b, float a)
64 private void UpdateColor()
66 propertyMap[ColorVisualProperty.MixColor] = PropertyValue.CreateWithGuard(color);
67 OnPropertyChanged?.Invoke(this);
70 private void UpdateBlurRadius()
72 // TODO update blur radius value in the property map
73 OnPropertyChanged?.Invoke(this);
77 /// The color for the shadow.
79 [EditorBrowsable(EditorBrowsableState.Never)]
94 /// The blur radius value for the shadow. Bigger value, much blurry.
96 private uint BlurRadius
109 override internal string ToDebugString()
116 override internal bool IsValid()
118 return color != null && color.A != 0;
121 static internal new PropertyValue ToPropertyValue(TransformablePropertyMap instance)
123 if (instance == null || !instance.IsValid())
125 return new PropertyValue();
128 // TODO to be other blurable visual in the future
129 instance.propertyMap.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Color));
131 return new PropertyValue(instance.propertyMap);