/* * Copyright(c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ using System; using System.ComponentModel; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; namespace Tizen.NUI.BaseComponents { /// /// RiveAnimationView renders an animated vector image (Rive file). /// [EditorBrowsable(EditorBrowsableState.Never)] public class RiveAnimationView : View { static RiveAnimationView() { } /// /// RiveAnimationView constructor. /// /// The rive resource URL ///[EditorBrowsable(EditorBrowsableState.Never)] public RiveAnimationView(string url) : this(Interop.RiveAnimationView.New(url), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal RiveAnimationView(global::System.IntPtr cPtr, bool shown = true) : base(cPtr, shown) { if (!shown) { SetVisible(false); } } /// /// Eanables the given animation. /// /// The animation to enable /// The enable state of given animation [EditorBrowsable(EditorBrowsableState.Never)] public void EnableAnimation(string animationName, bool on) { Interop.RiveAnimationView.EnableAnimation(SwigCPtr, animationName, on); } /// /// Play animation. /// [EditorBrowsable(EditorBrowsableState.Never)] public void Play() { Interop.RiveAnimationView.Play(SwigCPtr); } /// /// Pause animation. /// [EditorBrowsable(EditorBrowsableState.Never)] public void Pause() { Interop.RiveAnimationView.Pause(SwigCPtr); } /// /// Stop animation. /// [EditorBrowsable(EditorBrowsableState.Never)] public void Stop() { Interop.RiveAnimationView.Stop(SwigCPtr); } /// /// Sets the fill color of given fill. /// /// The shape fill name /// The rgba color [EditorBrowsable(EditorBrowsableState.Never)] public void SetShapeFillColor(string shapeFillName, Color color) { if (color == null) throw new ArgumentNullException(nameof(color)); Interop.RiveAnimationView.SetShapeFillColor(SwigCPtr, shapeFillName, color.SwigCPtr); } /// /// Sets the shape stroke color of given stroke. /// /// The shape stroke name /// The rgba color [EditorBrowsable(EditorBrowsableState.Never)] public void SetShapeStrokeColor(string shapeStrokeName, Color color) { if (color == null) throw new ArgumentNullException(nameof(color)); Interop.RiveAnimationView.SetShapeStrokeColor(SwigCPtr, shapeStrokeName, color.SwigCPtr); } /// /// Sets the opacity of given node. /// /// The node name /// The opacity of given node [EditorBrowsable(EditorBrowsableState.Never)] public void SetNodeOpacity(string nodeName, float opacity) { Interop.RiveAnimationView.SetNodeOpacity(SwigCPtr, nodeName, opacity); } /// /// Sets the scale of given node. /// /// The node name /// The scale of given node [EditorBrowsable(EditorBrowsableState.Never)] public void SetNodeScale(string nodeName, Vector2 scale) { if (scale == null) throw new ArgumentNullException(nameof(scale)); Interop.RiveAnimationView.SetNodeScale(SwigCPtr, nodeName, Vector2.getCPtr(scale)); } /// /// Sets the rotation of given node. /// /// The node name /// The degree of given node [EditorBrowsable(EditorBrowsableState.Never)] public void SetNodeRotation(string nodeName, Degree degree) { if (degree == null) throw new ArgumentNullException(nameof(degree)); Interop.RiveAnimationView.SetNodeRotation(SwigCPtr, nodeName, Degree.getCPtr(degree)); } /// /// Sets the position of given node. /// /// The node name /// The position of given node [EditorBrowsable(EditorBrowsableState.Never)] public void SetNodePosition(string nodeName, Position position) { if (position == null) throw new ArgumentNullException(nameof(position)); Interop.RiveAnimationView.SetNodePosition(SwigCPtr, nodeName, position.SwigCPtr); } /// /// Sets the animation elapsed time. /// /// The animation name /// The elapsed time [EditorBrowsable(EditorBrowsableState.Never)] public void SetAnimationElapsedTime(string animationName, float elapsed) { Interop.RiveAnimationView.SetAnimationElapsedTime(SwigCPtr, animationName, elapsed); } } }