namespace ElmSharp
{
/// <summary>
+ /// Enumeration for the AnimationView state
+ /// </summary>
+ /// <since_tizen> preview </since_tizen>
+ public enum AnimationViewState
+ {
+ /// <summary>
+ /// Animation is not ready to play.
+ /// </summary>
+ NotReady,
+
+ /// <summary>
+ /// Animation is on playing.
+ /// </summary>
+ Play,
+
+ /// <summary>
+ /// Animation is on reverse playing.
+ /// </summary>
+ ReversedPlay,
+
+ /// <summary>
+ /// Animation has been paused.
+ /// </summary>
+ Pause,
+
+ /// <summary>
+ /// AnimationView successfully loaded a file then readied for playing. Otherwise after finished animation or stopped forcely by request.
+ /// </summary>
+ Stop
+ }
+
+ /// <summary>
/// The AnimationView is designed to show and play animation of vector graphics based content.
/// Currently ElmSharp AnimationView is supporting only json format (known for Lottie file as well).
/// </summary>
}
/// <summary>
- /// Sets or gets current keyframe position of animation view.
+ /// Sets or gets current progress position of animation view.
+ /// <remarks>
+ /// When you required to jump on a certain progress instantly,
+ /// you can change current position by using this property
+ /// The range of progress is 0 ~ 1.
+ /// </remarks>
+ /// </summary>
+ /// <since_tizen> preview </since_tizen>
+ public double Progress
+ {
+ get
+ {
+ return Interop.Elementary.elm_animation_view_progress_get(Handle);
+ }
+ set
+ {
+ Interop.Elementary.elm_animation_view_progress_set(Handle, value);
+ }
+ }
+
+ /// <summary>
+ /// Sets or gets current frame position of animation view.
+ /// <remarks>
+ /// The range of frame is from 0 to FrameCount - 1
+ /// </remarks>
+ /// </summary>
+ /// <since_tizen> preview </since_tizen>
+ public int Frame
+ {
+ get
+ {
+ return Interop.Elementary.elm_animation_view_frame_get(Handle);
+ }
+ set
+ {
+ Interop.Elementary.elm_animation_view_frame_set(Handle, value);
+ }
+ }
+
+ /// <summary>
+ /// Get the default view size that specified from vector resource.
+ /// </summary>
+ /// <since_tizen> preview </since_tizen>
+ public Size DefaultSize
+ {
+ get
+ {
+ Interop.Elementary.elm_animation_view_default_size_get(Handle, out int w, out int h);
+ return new Size(w, h);
+ }
+ }
+
+ /// <summary>
+ /// Get current animation view state.
+ /// </summary>
+ /// <since_tizen> preview </since_tizen>
+ public AnimationViewState State
+ {
+ get
+ {
+ return (AnimationViewState)Interop.Elementary.elm_animation_view_state_get(Handle);
+ }
+ }
+
+ /// <summary>
+ /// Get the status whether current animation is on playing forward or backward.
+ /// </summary>
/// <remarks>
- /// When you required to jump on a certain frame instantly,
- /// you can change current keyframe by using this property
- /// The range of keyframe is 0 ~ 1.
+ /// If AnimationView is not on playing, it will return False.
/// </remarks>
+ /// <since_tizen> preview </since_tizen>
+ public bool IsReversedPlaying
+ {
+ get
+ {
+ return Interop.Elementary.elm_animation_view_is_playing_back_get(Handle);
+ }
+ }
+
+ /// <summary>
+ /// Get the index of end frame of the AnimationView, if it's animated.
/// </summary>
+ /// <remarks>
+ /// Frame number starts with 0.
+ /// </remarks>
+ /// <since_tizen> preview </since_tizen>
+ public int FrameCount
+ {
+ get
+ {
+ return Interop.Elementary.elm_animation_view_frame_count_get(Handle);
+ }
+ }
+
+ /// <summary>
+ /// Sets or Gets the start progress of the play
+ /// </summary>
+ /// <remarks>
+ /// Default value is 0.
+ /// </remarks>
+ /// <since_tizen> preview </since_tizen>
+ public double MinProgress
+ {
+ get
+ {
+ return Interop.Elementary.elm_animation_view_min_progress_get(Handle);
+ }
+ set
+ {
+ Interop.Elementary.elm_animation_view_min_progress_set(Handle, value);
+ }
+ }
+
+ /// <summary>
+ /// Sets or Gets the last progress of the play
+ /// </summary>
+ /// <remarks>
+ /// Default value is 1.
+ /// </remarks>
+ /// <since_tizen> preview </since_tizen>
+ public double MaxProgress
+ {
+ get
+ {
+ return Interop.Elementary.elm_animation_view_max_progress_get(Handle);
+ }
+ set
+ {
+ Interop.Elementary.elm_animation_view_max_progress_set(Handle, value);
+ }
+ }
+
+ /// <summary>
+ /// Sets or Gets the start frame of the play
+ /// </summary>
+ /// <remarks>
+ /// Default value is 0.
+ /// </remarks>
+ /// <since_tizen> preview </since_tizen>
+ public int MinFrame
+ {
+ get
+ {
+ return Interop.Elementary.elm_animation_view_min_frame_get(Handle);
+ }
+ set
+ {
+ Interop.Elementary.elm_animation_view_min_frame_set(Handle, value);
+ }
+ }
+
+ /// <summary>
+ /// Sets or Gets the last frame of the play
+ /// </summary>
+ /// <remarks>
+ /// Default value is FrameCount -1.
+ /// </remarks>
/// <since_tizen> preview </since_tizen>
- public double KeyFrame
+ public int MaxFrame
{
get
{
- return Interop.Elementary.elm_animation_view_keyframe_get(Handle);
+ return Interop.Elementary.elm_animation_view_max_frame_get(Handle);
}
set
{
- Interop.Elementary.elm_animation_view_keyframe_set(Handle, value);
+ Interop.Elementary.elm_animation_view_max_frame_set(Handle, value);
}
}
{
internal static partial class Eina
{
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct Size2D
+ {
+ public int w;
+ public int h;
+ };
+
[DllImport(Libraries.Eina)]
[return: MarshalAs(UnmanagedType.U1)]
internal static extern bool eina_main_loop_is();
internal static extern double elm_animation_view_duration_time_get(IntPtr obj);
[DllImport(Libraries.Elementary)]
- internal static extern double elm_animation_view_keyframe_get(IntPtr obj);
+ internal static extern double elm_animation_view_progress_get(IntPtr obj);
[DllImport(Libraries.Elementary)]
- internal static extern void elm_animation_view_keyframe_set(IntPtr obj, double keyframe);
+ internal static extern void elm_animation_view_progress_set(IntPtr obj, double progress);
+
+ [DllImport(Libraries.Elementary)]
+ internal static extern int elm_animation_view_frame_get(IntPtr obj);
+
+ [DllImport(Libraries.Elementary)]
+ internal static extern void elm_animation_view_frame_set(IntPtr obj, int frame_num);
[DllImport(Libraries.Elementary)]
internal static extern bool elm_animation_view_play(IntPtr obj);
[DllImport(Libraries.Elementary)]
internal static extern bool elm_animation_view_stop(IntPtr obj);
+ [DllImport(Libraries.Elementary, EntryPoint = "elm_animation_view_default_size_get")]
+ internal static extern Eina.Size2D _elm_animation_view_default_size_get(IntPtr obj);
+
+ internal static void elm_animation_view_default_size_get(IntPtr obj, out int w, out int h)
+ {
+ var info = _elm_animation_view_default_size_get(obj);
+ w = info.w;
+ h = info.h;
+ }
+
+ [DllImport(Libraries.Elementary)]
+ internal static extern int elm_animation_view_state_get(IntPtr obj);
+
+ [DllImport(Libraries.Elementary)]
+ internal static extern bool elm_animation_view_is_playing_back_get(IntPtr obj);
+
+ [DllImport(Libraries.Elementary)]
+ internal static extern int elm_animation_view_frame_count_get(IntPtr obj);
+
+ [DllImport(Libraries.Elementary)]
+ internal static extern double elm_animation_view_min_progress_get(IntPtr obj);
+
+ [DllImport(Libraries.Elementary)]
+ internal static extern void elm_animation_view_min_progress_set(IntPtr obj, double min_progress);
+
+ [DllImport(Libraries.Elementary)]
+ internal static extern double elm_animation_view_max_progress_get(IntPtr obj);
+
+ [DllImport(Libraries.Elementary)]
+ internal static extern void elm_animation_view_max_progress_set(IntPtr obj, double max_progress);
+
+ [DllImport(Libraries.Elementary)]
+ internal static extern int elm_animation_view_min_frame_get(IntPtr obj);
+
+ [DllImport(Libraries.Elementary)]
+ internal static extern void elm_animation_view_min_frame_set(IntPtr obj, int min_frame);
+
+ [DllImport(Libraries.Elementary)]
+ internal static extern int elm_animation_view_max_frame_get(IntPtr obj);
+
+ [DllImport(Libraries.Elementary)]
+ internal static extern void elm_animation_view_max_frame_set(IntPtr obj, double max_frame);
+
[DllImport(Libraries.Elementary)]
internal static extern bool elm_animation_view_file_set(IntPtr obj, string file, string key);
}
public override string TestName => "AnimationViewTest1";
public override string TestDescription => "To test basic operation of AnimationView";
- private enum AnimationState
+ void UpdateAnimationViewStateLabel(AnimationView aniview, Label _stateLabel)
{
- NotReady,
- Play,
- ReversePlay,
- Pause,
- Stop,
- }
-
- private AnimationState _state;
- private bool _isPlayingReverse;
+ AnimationViewState _state = aniview.State;
- void UpdateAnimationViewStateLabel(Label _stateLabel)
- {
- if (_state == AnimationState.NotReady)
+ if (_state == AnimationViewState.NotReady)
{
_stateLabel.Text = "<font_size=32>State = Not Ready</font_size>";
}
- else if (_state == AnimationState.Play)
+ else if (_state == AnimationViewState.Play)
{
_stateLabel.Text = "<font_size=32>State = Playing</font_size>";
}
- else if (_state == AnimationState.ReversePlay)
+ else if (_state == AnimationViewState.ReversePlay)
{
_stateLabel.Text = "<font_size=32>State = Reverse Playing</font_size>";
}
- else if (_state == AnimationState.Pause)
+ else if (_state == AnimationViewState.Pause)
{
_stateLabel.Text = "<font_size=32>State = Paused</font_size>";
}
- else if (_state == AnimationState.Stop)
+ else if (_state == AnimationViewState.Stop)
{
_stateLabel.Text = "<font_size=32>State = Stopped</font_size>";
}
};
aniview.SetAnimation(Path.Combine(TestRunner.ResourceDir, "a_mountain.json"));
aniview.Show();
- box.PackEnd(aniview);
+
+ Box box1 = new Box(box)
+ {
+ WeightX = 1,
+ WeightY = 0,
+ AlignmentX = -1,
+ AlignmentY = 1,
+ IsHorizontal = true,
+ };
+ box1.Show();
+ box.PackEnd(box1);
+
+ Label label1 = new Label(box)
+ {
+ WeightX = 1,
+ WeightY = 0,
+ AlignmentX = 0.0,
+ AlignmentY = 0.5,
+ Text = "Default Size = (" + aniview.DefaultSize.Width + "," + aniview.DefaultSize.Height + ")",
+ };
+ label1.Show();
+ box1.PackEnd(label1);
Label label2 = new Label(box)
{
WeightY = 0,
AlignmentX = 1.0,
AlignmentY = 0.5,
- Text = "Duration : " + (Math.Round(Convert.ToDouble(aniview.DurationTime), 2)).ToString(),
+ Text = "FrameCount : " + (aniview.FrameCount).ToString(),
};
label2.Show();
- box.PackEnd(label2);
+ box1.PackEnd(label2);
+
+ Label label3 = new Label(box)
+ {
+ WeightX = 1,
+ WeightY = 0,
+ AlignmentX = 1.0,
+ AlignmentY = 0.5,
+ Text = "Duration : " + (Math.Round(Convert.ToDouble(aniview.DurationTime), 2)).ToString(),
+ };
+ label3.Show();
+ box.PackEnd(label3);
+
+ box.PackEnd(aniview);
Box box2 = new Box(box)
{
slider.ValueChanged += (s, e) =>
{
- aniview.KeyFrame = slider.Value;
+ aniview.Progress = slider.Value;
};
Box box3 = new Box(box)
box3.Show();
box.PackEnd(box3);
- Button btn1 = new Button(box3)
+ Label label4 = new Label(box)
+ {
+ WeightX = 1,
+ WeightY = 0,
+ AlignmentX = 0.0,
+ AlignmentY = 0.5,
+ Text = (aniview.MinFrame).ToString() + " / " + (aniview.MaxFrame).ToString(),
+ };
+ label4.Show();
+ box3.PackEnd(label4);
+
+ Label label5 = new Label(box)
+ {
+ WeightX = 1,
+ WeightY = 0,
+ AlignmentX = 1.0,
+ AlignmentY = 0.5,
+ Text = (aniview.MinProgress).ToString() + " / " + (aniview.MaxProgress).ToString(),
+ };
+ label5.Show();
+ box3.PackEnd(label5);
+
+ Box box4 = new Box(box)
+ {
+ WeightX = 1,
+ WeightY = 0,
+ AlignmentX = -1,
+ AlignmentY = 1,
+ IsHorizontal = true,
+ };
+ box4.Show();
+ box.PackEnd(box4);
+
+ Button btn1 = new Button(box4)
{
WeightX = 1,
WeightY = 0,
Text = "Play",
};
btn1.Show();
- box3.PackEnd(btn1);
+ box4.PackEnd(btn1);
btn1.Clicked += (s, e) =>
{
- _isPlayingReverse = false;
- if (_state == AnimationState.ReversePlay)
- {
- UpdateAnimationViewStateLabel(label);
- }
aniview.Play();
+ UpdateAnimationViewStateLabel(aniview, label);
};
- Button btn2 = new Button(box3)
+ Button btn2 = new Button(box4)
{
WeightX = 1,
WeightY = 0,
Text = "Reverse",
};
btn2.Show();
- box3.PackEnd(btn2);
+ box4.PackEnd(btn2);
btn2.Clicked += (s, e) =>
{
- _isPlayingReverse = true;
- if (_state == AnimationState.Play)
- {
- UpdateAnimationViewStateLabel(label);
- }
aniview.Play(true);
+ UpdateAnimationViewStateLabel(aniview, label);
};
- Button btn3 = new Button(box3)
+ Button btn3 = new Button(box4)
{
WeightX = 1,
WeightY = 0,
Text = "Stop",
};
btn3.Show();
- box3.PackEnd(btn3);
+ box4.PackEnd(btn3);
btn3.Clicked += (s, e) =>
{
aniview.Stop();
};
- Box box4 = new Box(box)
+ Box box5 = new Box(box)
{
WeightX = 1,
WeightY = 0,
AlignmentY = 1,
IsHorizontal = true,
};
- box4.Show();
- box.PackEnd(box4);
+ box5.Show();
+ box.PackEnd(box5);
- Button btn4 = new Button(box3)
+ Button btn4 = new Button(box5)
{
WeightX = 1,
WeightY = 0,
Text = "Pause",
};
btn4.Show();
- box4.PackEnd(btn4);
+ box5.PackEnd(btn4);
btn4.Clicked += (s, e) =>
{
aniview.Pause();
};
- Button btn5 = new Button(box3)
+ Button btn5 = new Button(box5)
{
WeightX = 1,
WeightY = 0,
Text = "Resume",
};
btn5.Show();
- box4.PackEnd(btn5);
+ box5.PackEnd(btn5);
btn5.Clicked += (s, e) =>
{
aniview.Started += (s, e) =>
{
- if (!_isPlayingReverse)
- {
- _state = AnimationState.Play;
- }
- else
- {
- _state = AnimationState.ReversePlay;
- }
- UpdateAnimationViewStateLabel(label);
+ UpdateAnimationViewStateLabel(aniview, label);
};
aniview.Stopped += (s, e) =>
{
- _state = AnimationState.Stop;
- UpdateAnimationViewStateLabel(label);
-
+ UpdateAnimationViewStateLabel(aniview, label);
+ label4.Text = "0 / " + (aniview.MaxFrame).ToString();
+ label5.Text = "0 / " + (aniview.MaxProgress).ToString();
slider.Value = 0;
};
aniview.Paused += (s, e) =>
{
- _state = AnimationState.Pause;
- UpdateAnimationViewStateLabel(label);
+ UpdateAnimationViewStateLabel(aniview, label);
};
aniview.Resumed += (s, e) =>
{
- if (!_isPlayingReverse)
- {
- _state = AnimationState.Play;
- }
- else
- {
- _state = AnimationState.ReversePlay;
- }
- UpdateAnimationViewStateLabel(label);
+ UpdateAnimationViewStateLabel(aniview, label);
};
aniview.Updated += (s, e) =>
{
- slider.Value = aniview.KeyFrame;
+ slider.Value = aniview.Progress;
+ label4.Text = (aniview.Frame).ToString() + " / " + (aniview.MaxFrame).ToString();
+ label5.Text = (Math.Round(Convert.ToDouble(aniview.Progress), 2)).ToString() + " / " + (aniview.MaxProgress).ToString();
};
- _state = AnimationState.NotReady;
- UpdateAnimationViewStateLabel(label);
+ UpdateAnimationViewStateLabel(aniview, label);
navi.Push(layout, "AnimationView Test");
}