From: xb.teng Date: Wed, 10 May 2017 08:30:33 +0000 (+0800) Subject: visual high level class update X-Git-Tag: preview1-00180^2~52^2~75 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=69f01b940f72dd3b07bd5c19742e69e4369d83d5;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git visual high level class update - it's fix for NUI-276 Change-Id: I490c3083c55a8656d0a51f3333c1546278c8d7cf --- diff --git a/NUISamples/NUISamples/NUISamples.TizenTV/examples/visual-animation-test.cs b/NUISamples/NUISamples/NUISamples.TizenTV/examples/visual-animation-test.cs old mode 100644 new mode 100755 index 2165bc1..4edb9eb --- a/NUISamples/NUISamples/NUISamples.TizenTV/examples/visual-animation-test.cs +++ b/NUISamples/NUISamples/NUISamples.TizenTV/examples/visual-animation-test.cs @@ -38,6 +38,7 @@ namespace VisaulAnimationExample private SVGVisual svgVisual; private AnimatedImageVisual gifVisual; + private ImageVisual _icon; public Example() : base() { @@ -97,7 +98,7 @@ namespace VisaulAnimationExample //_contentView.Size2D = new Size2D(250, 250); _contentView.BackgroundImage = _resPath + "/images/background-blocks.jpg"; - ImageVisual _icon = new ImageVisual(); + _icon = new ImageVisual(); _icon.URL = _resPath + "/images/application-icon-0.png"; _icon.DepthIndex = 1; _icon.Size = new Size2D(50, 50); @@ -234,25 +235,11 @@ namespace VisaulAnimationExample if (activate) { - VisualAnimator grow = new VisualAnimator(); - grow.AlphaFunction = AlphaFunction.BuiltinFunctions.Linear; - grow.StartTime = 0; - grow.EndTime = 1000; - grow.Target = "icon_visual1"; - grow.PropertyIndex = "Size"; - grow.DestinationValue = new Size2D(200, 200); - _animation = _contentView.VisualAnimate(grow); + _animation = _contentView.AnimateVisual(_icon, "Size", new Size2D(200, 200), 0, 1000, AlphaFunction.BuiltinFunctions.Linear); } else { - VisualAnimator shrink = new VisualAnimator(); - shrink.AlphaFunction = AlphaFunction.BuiltinFunctions.Linear; - shrink.StartTime = 0; - shrink.EndTime = 1000; - shrink.Target = "icon_visual1"; - shrink.PropertyIndex = "Size"; - shrink.DestinationValue = new Size2D(50, 50); - _animation = _contentView.VisualAnimate(shrink); + _animation = _contentView.AnimateVisual(_icon, "Size", new Position2D(50, 50), 0, 1000, AlphaFunction.BuiltinFunctions.Linear); } if (_animation) diff --git a/NUISamples/NUISamples/NUISamples.TizenTV/examples/visual-animation-test2.cs b/NUISamples/NUISamples/NUISamples.TizenTV/examples/visual-animation-test2.cs old mode 100644 new mode 100755 index b8a9561..266f975 --- a/NUISamples/NUISamples/NUISamples.TizenTV/examples/visual-animation-test2.cs +++ b/NUISamples/NUISamples/NUISamples.TizenTV/examples/visual-animation-test2.cs @@ -122,7 +122,7 @@ namespace VisaulAnimationExample _shadowButton1.Clicked += (obj, ev) => { _active1 = !_active1; - StartTransition(_contentView1, "icon_visual1", "Offset", _active1); + StartTransition(_contentView1, _icon, "Offset", _active1); return true; }; _shadowButton1.WidthResizePolicy = ResizePolicyType.FillToParent; @@ -160,7 +160,7 @@ namespace VisaulAnimationExample _shadowButton2.Clicked += (obj, ev) => { _active2 = !_active2; - StartTransition(_contentView2, "icon_visual2", "Opacity", _active2); + StartTransition(_contentView2, _icon2, "Opacity", _active2); return true; }; _shadowButton2.WidthResizePolicy = ResizePolicyType.FillToParent; @@ -198,7 +198,7 @@ namespace VisaulAnimationExample _shadowButton3.Clicked += (obj, ev) => { _active3 = !_active3; - StartTransition(_contentView3, "icon_visual3", "MixColor", _active3); + StartTransition(_contentView3, _icon3, "MixColor", _active3); return true; }; _shadowButton3.WidthResizePolicy = ResizePolicyType.FillToParent; @@ -206,7 +206,7 @@ namespace VisaulAnimationExample contentLayout.AddChild(_shadowButton3, new TableView.CellPosition(2, 1)); } - private void StartTransition(VisualView view, string target, string property, bool activate) + private void StartTransition(VisualView view, VisualMap target, string property, bool activate) { if (_animation) { @@ -216,47 +216,33 @@ namespace VisaulAnimationExample if (activate) { - VisualAnimator state1 = new VisualAnimator(); - state1.AlphaFunction = AlphaFunction.BuiltinFunctions.Linear; - state1.StartTime = 0; - state1.EndTime = 1000; - state1.Target = target; - state1.PropertyIndex = property; if (property == "Offset") { - state1.DestinationValue = new Position2D(20, 20); + _animation = view.AnimateVisual(target, property, new Position2D(20, 20), 0, 1000, AlphaFunction.BuiltinFunctions.Linear); } else if (property == "Opacity") { - state1.DestinationValue = 0.0f; + _animation = view.AnimateVisual(target, property, 0.0f, 0, 1000, AlphaFunction.BuiltinFunctions.Linear); } else if (property == "MixColor") { - state1.DestinationValue = Color.Green; + _animation = view.AnimateVisual(target, property, Color.Green, 0, 1000, AlphaFunction.BuiltinFunctions.Linear); } - _animation = view.VisualAnimate(state1); } else { - VisualAnimator state2 = new VisualAnimator(); - state2.AlphaFunction = AlphaFunction.BuiltinFunctions.Linear; - state2.StartTime = 0; - state2.EndTime = 1000; - state2.Target = target; - state2.PropertyIndex = property; if (property == "Offset") { - state2.DestinationValue = new Position2D(5, 5); + _animation = view.AnimateVisual(target, property, new Position2D(5, 5), 0, 1000, AlphaFunction.BuiltinFunctions.Linear); } else if (property == "Opacity") { - state2.DestinationValue = 1.0f; + _animation = view.AnimateVisual(target, property, 1.0f, 0, 1000, AlphaFunction.BuiltinFunctions.Linear); } else if (property == "MixColor") { - state2.DestinationValue = Color.Red; + _animation = view.AnimateVisual(target, property, Color.Red, 0, 1000, AlphaFunction.BuiltinFunctions.Linear); } - _animation = view.VisualAnimate(state2); } if (_animation) diff --git a/src/Tizen.NUI/src/public/BaseComponents/VisualView.cs b/src/Tizen.NUI/src/public/BaseComponents/VisualView.cs old mode 100644 new mode 100755 index d816d7d..7cb39cd --- a/src/Tizen.NUI/src/public/BaseComponents/VisualView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/VisualView.cs @@ -204,17 +204,117 @@ namespace Tizen.NUI.BaseComponents } /// - /// Create visual animation (transition) with the input property map + /// Create visual animation (transition) with the input parameters. /// - /// property map to define visual animation + /// The visual map to animation. + /// The property of visual to animation. + /// The destination value of property after animation. + /// The start time of visual animation. + /// The end time of visual animation. + /// The alpha function of visual animation /// Animation instance - public Animation VisualAnimate(VisualAnimator visualMap) + public Animation AnimateVisual(VisualMap target, string property, object destinationValue, int startTime, int endTime, AlphaFunction.BuiltinFunctions alphaFunction) { + string _alphaFunction = ""; + switch (alphaFunction) + { + case Tizen.NUI.AlphaFunction.BuiltinFunctions.Linear: + { + _alphaFunction = "LINEAR"; + break; + } + case Tizen.NUI.AlphaFunction.BuiltinFunctions.Reverse: + { + _alphaFunction = "REVERSE"; + break; + } + case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInSquare: + { + _alphaFunction = "EASE_IN_SQUARE"; + break; + } + case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutSquare: + { + _alphaFunction = "EASE_OUT_SQUARE"; + break; + } + case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseIn: + { + _alphaFunction = "EASE_IN"; + break; + } + case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOut: + { + _alphaFunction = "EASE_OUT"; + break; + } + case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInOut: + { + _alphaFunction = "EASE_IN_OUT"; + break; + } + case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInSine: + { + _alphaFunction = "EASE_IN_SINE"; + break; + } + case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutSine: + { + _alphaFunction = "EASE_OUT_SINE"; + break; + } + case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInOutSine: + { + _alphaFunction = "EASE_IN_OUT_SINE"; + break; + } + case Tizen.NUI.AlphaFunction.BuiltinFunctions.Bounce: + { + _alphaFunction = "BOUNCE"; + break; + } + case Tizen.NUI.AlphaFunction.BuiltinFunctions.Sin: + { + _alphaFunction = "SIN"; + break; + } + case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutBack: + { + _alphaFunction = "EASE_OUT_BACK"; + break; + } + default: + { + _alphaFunction = "DEFAULT"; + break; + } + } + foreach (var item in _visualDictionary.ToList()) { - if (item.Value.Name == visualMap.Target) + if (item.Value.Name == target.Name) { - TransitionData _transitionData = new TransitionData(visualMap.OutputVisualMap); + PropertyMap _animator = new PropertyMap(); + _animator.Add("alphaFunction", new PropertyValue(_alphaFunction)); + + PropertyMap _timePeriod = new PropertyMap(); + _timePeriod.Add("duration", new PropertyValue((endTime - startTime) / 1000.0f)); + _timePeriod.Add("delay", new PropertyValue(startTime / 1000.0f)); + _animator.Add("timePeriod", new PropertyValue(_timePeriod)); + + string _str1 = property.Substring(0, 1); + string _str2 = property.Substring(1); + string _str = _str1.ToLower() + _str2; + + PropertyValue val = PropertyValue.CreateFromObject(destinationValue); + + PropertyMap _transition = new PropertyMap(); + _transition.Add("target", new PropertyValue(target.Name)); + _transition.Add("property", new PropertyValue(_str)); + _transition.Add("targetValue", val); + _transition.Add("animator", new PropertyValue(_animator)); + + TransitionData _transitionData = new TransitionData(_transition); return this.CreateTransition(_transitionData); } } diff --git a/src/Tizen.NUI/src/public/VisualMaps.cs b/src/Tizen.NUI/src/public/VisualMaps.cs old mode 100644 new mode 100755 index 959dd07..1e76181 --- a/src/Tizen.NUI/src/public/VisualMaps.cs +++ b/src/Tizen.NUI/src/public/VisualMaps.cs @@ -1978,220 +1978,5 @@ namespace Tizen.NUI } } - /// - /// A class encapsulating the property map of a visual transition(Animator). - /// - public class VisualAnimator : VisualMap - { - public VisualAnimator() : base() - { - } - - private string _alphaFunction = null; - private int _startTime = 0; - private int _endTime = 0; - private string _target = null; - private string _propertyIndex = null; - private object _destinationValue = null; - - public AlphaFunction.BuiltinFunctions AlphaFunction - { - get - { - switch (_alphaFunction) - { - case "LINEAR": - return Tizen.NUI.AlphaFunction.BuiltinFunctions.Linear; - case "REVERSE": - return Tizen.NUI.AlphaFunction.BuiltinFunctions.Reverse; - case "EASE_IN_SQUARE": - return Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInSquare; - case "EASE_OUT_SQUARE": - return Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutSquare; - case "EASE_IN": - return Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseIn; - case "EASE_OUT": - return Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOut; - case "EASE_IN_OUT": - return Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInOut; - case "EASE_IN_SINE": - return Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInSine; - case "EASE_OUT_SINE": - return Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutSine; - case "EASE_IN_OUT_SINE": - return Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInOutSine; - case "BOUNCE": - return Tizen.NUI.AlphaFunction.BuiltinFunctions.Bounce; - case "SIN": - return Tizen.NUI.AlphaFunction.BuiltinFunctions.Sin; - case "EASE_OUT_BACK": - return Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutBack; - default: - return Tizen.NUI.AlphaFunction.BuiltinFunctions.Default; - } - } - set - { - switch (value) - { - case Tizen.NUI.AlphaFunction.BuiltinFunctions.Linear: - { - _alphaFunction = "LINEAR"; - break; - } - case Tizen.NUI.AlphaFunction.BuiltinFunctions.Reverse: - { - _alphaFunction = "REVERSE"; - break; - } - case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInSquare: - { - _alphaFunction = "EASE_IN_SQUARE"; - break; - } - case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutSquare: - { - _alphaFunction = "EASE_OUT_SQUARE"; - break; - } - case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseIn: - { - _alphaFunction = "EASE_IN"; - break; - } - case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOut: - { - _alphaFunction = "EASE_OUT"; - break; - } - case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInOut: - { - _alphaFunction = "EASE_IN_OUT"; - break; - } - case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInSine: - { - _alphaFunction = "EASE_IN_SINE"; - break; - } - case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutSine: - { - _alphaFunction = "EASE_OUT_SINE"; - break; - } - case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInOutSine: - { - _alphaFunction = "EASE_IN_OUT_SINE"; - break; - } - case Tizen.NUI.AlphaFunction.BuiltinFunctions.Bounce: - { - _alphaFunction = "BOUNCE"; - break; - } - case Tizen.NUI.AlphaFunction.BuiltinFunctions.Sin: - { - _alphaFunction = "SIN"; - break; - } - case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutBack: - { - _alphaFunction = "EASE_OUT_BACK"; - break; - } - default: - { - _alphaFunction = "DEFAULT"; - break; - } - } - } - } - - public int StartTime - { - get - { - return _startTime; - } - set - { - _startTime = value; - } - } - - public int EndTime - { - get - { - return _endTime; - } - set - { - _endTime = value; - } - } - - public string Target - { - get - { - return _target; - } - set - { - _target = value; - } - } - - public string PropertyIndex - { - get - { - return _propertyIndex; - } - set - { - _propertyIndex = value; - } - } - - public object DestinationValue - { - get - { - return _destinationValue; - } - set - { - _destinationValue = value; - } - } - - protected override void ComposingPropertyMap() - { - PropertyMap _animator = new PropertyMap(); - _animator.Add("alphaFunction", new PropertyValue(_alphaFunction)); - - PropertyMap _timePeriod = new PropertyMap(); - _timePeriod.Add("duration", new PropertyValue((_endTime - _startTime) / 1000.0f)); - _timePeriod.Add("delay", new PropertyValue(_startTime / 1000.0f)); - _animator.Add("timePeriod", new PropertyValue(_timePeriod)); - - string _str1 = _propertyIndex.Substring(0, 1); - string _str2 = _propertyIndex.Substring(1); - string _str = _str1.ToLower() + _str2; - - PropertyValue val = PropertyValue.CreateFromObject(_destinationValue); - - PropertyMap _transition = new PropertyMap(); - _transition.Add("target", new PropertyValue(_target)); - _transition.Add("property", new PropertyValue(_str)); - _transition.Add("targetValue", val); - _transition.Add("animator", new PropertyValue(_animator)); - - _outputVisualMap = _transition; - } - } }