/// <since_tizen> 9 </since_tizen>
public class Navigator : Control
{
- private static readonly int DefaultTransitionDuration = 500;
+ private const int DefaultTransitionDuration = 500;
//This will be replaced with view transition class instance.
private Animation curAnimation = null;
}
newTransitionSet.AddTransition(pairTransition);
}
- newTransitionSet.Play();
newTransitionSet.Finished += (object sender, EventArgs e) =>
{
currentTopPage.Opacity = 1.0f;
};
- // default entering/exit transition - fast fade (half duration compaired with that of view pair transition)
+ // default appearing/disappearing transition - fast fade (half duration compaired with that of view pair transition)
int duration = (transition.TimePeriod.DurationMilliseconds + transition.TimePeriod.DelayMilliseconds);
float durationSeconds = (float)duration / 1000.0f;
- Animation fade = new Animation(0.8f * durationSeconds);
- fade.AnimateTo(currentTopPage, "Opacity", 0.0f);
- KeyFrames keyframes = new KeyFrames();
- keyframes.Add(0.0f, 0.0f);
- keyframes.Add(1.0f, 1.0f);
- fade.AnimateBetween(newTopPage, "Opacity", keyframes);
- fade.Play();
+
+ TransitionItemBase disappearingTransition = currentTopPage.DisappearingTransition.CreateTransition(currentTopPage, false);
+ TransitionItemBase appearingTransition = newTopPage.AppearingTransition.CreateTransition(newTopPage, true);
+ disappearingTransition.TransitionWithChild = true;
+ appearingTransition.TransitionWithChild = true;
+ newTransitionSet.AddTransition(disappearingTransition);
+ newTransitionSet.AddTransition(appearingTransition);
+
+ newTransitionSet.Play();
return newTransitionSet;
}
/// <since_tizen> 9 </since_tizen>
public abstract class Page : Control
{
+ private const int DefaultTransitionDuration = 500;
+
private Navigator navigator = null;
+ // Default transition is Fade.
+ private TransitionBase appearingTransition = new Fade()
+ {
+ TimePeriod = new TimePeriod(DefaultTransitionDuration),
+ AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default),
+ };
+
+ private TransitionBase disappearingTransition = new Fade()
+ {
+ TimePeriod = new TimePeriod(DefaultTransitionDuration),
+ AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default),
+ };
+
/// <summary>
/// Creates a new instance of a Page.
/// </summary>
}
/// <summary>
+ /// Transition properties for the transition of Views in this page during this page is pushed to Navigator.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public TransitionBase AppearingTransition
+ {
+ set
+ {
+ appearingTransition = value;
+ }
+ get
+ {
+ return appearingTransition;
+ }
+ }
+
+ /// <summary>
+ /// Transition properties for the transition of Views in this page during this page is popped from Navigator.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public TransitionBase DisappearingTransition
+ {
+ set
+ {
+ disappearingTransition = value;
+ }
+ get
+ {
+ return disappearingTransition;
+ }
+ }
+
+ /// <summary>
/// An event for the page appearing signal which can be used to subscribe or unsubscribe the event handler provided by the user.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
--- /dev/null
+/*
+ * 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.
+ *
+ */
+
+namespace Tizen.NUI
+{
+ using global::System;
+ using global::System.Runtime.InteropServices;
+
+ internal static partial class Interop
+ {
+ internal static partial class FadeItem
+ {
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_Fade")]
+ public static extern IntPtr NewEmpty();
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Fade_New")]
+ public static extern IntPtr New(HandleRef view, float opacity, HandleRef timePeriod);
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_Fade")]
+ public static extern void Delete(HandleRef fade);
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_Fade_Set")]
+ public static extern IntPtr NewFadeItem(HandleRef fade);
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Fade_Assign")]
+ public static extern IntPtr Assign(HandleRef destination, HandleRef source);
+ }
+ }
+}
[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TransitionBase_TransitionWithChild")]
public static extern void TransitionWithChild(HandleRef transition, bool transitionWithChild);
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TransitionBase_SetAppearingTransition")]
+ public static extern void SetAppearingTransition(HandleRef transition, bool appearingTransition);
}
}
}
--- /dev/null
+/*
+ * 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.
+ *
+ */
+
+namespace Tizen.NUI
+{
+ using System;
+ using System.ComponentModel;
+
+ using Tizen.NUI.BaseComponents;
+
+ /// <summary>
+ /// FadeItem is an object to set Fade transition of a View that will appear or disappear.
+ /// FadeItem object is required to be added to the TransitionSet to play.
+ /// </summary>
+ internal class FadeItem : TransitionItemBase
+ {
+ /// <summary>
+ /// Creates an initialized fade.<br />
+ /// </summary>
+ /// <remarks>DurationmSeconds must be greater than zero.</remarks>
+ public FadeItem(View view, float opacity, bool isAppearing, TimePeriod timePeriod, AlphaFunction alphaFunction) : this(Interop.FadeItem.New(view.SwigCPtr, opacity, timePeriod.SwigCPtr), true)
+ {
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ AppearingTransition = isAppearing;
+ AlphaFunction = alphaFunction;
+ }
+
+ internal FadeItem(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
+ {
+ }
+
+ internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FadeItem obj)
+ {
+ return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
+ }
+
+ internal FadeItem(FadeItem handle) : this(Interop.FadeItem.NewFadeItem(FadeItem.getCPtr(handle)), true)
+ {
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ internal FadeItem Assign(FadeItem rhs)
+ {
+ FadeItem ret = new FadeItem(Interop.FadeItem.Assign(SwigCPtr, FadeItem.getCPtr(rhs)), false);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+
+ /// <summary>
+ /// To make fade instance be disposed.
+ /// </summary>
+ protected override void Dispose(DisposeTypes type)
+ {
+ if (disposed)
+ {
+ return;
+ }
+ base.Dispose(type);
+ }
+
+ /// This will not be public opened.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
+ {
+ if (swigCPtr.Handle == IntPtr.Zero || this.HasBody() == false)
+ {
+ Tizen.Log.Fatal("NUI", $"[ERROR] FadeItem ReleaseSwigCPtr()! IntPtr=0x{swigCPtr.Handle:X} HasBody={this.HasBody()}");
+ return;
+ }
+ Interop.FadeItem.Delete(swigCPtr);
+ }
+ }
+}
/// <summary>
/// Creates an initialized TransitionItemBase.<br />
/// </summary>
- public TransitionItemBase(View target, bool isEntering, TimePeriod timePeriod, AlphaFunction alphaFunction) : this(Interop.TransitionItemBase.New(/*target.SwigCPtr, isEntering, timePeriod.SwigCPtr*/), true)
+ public TransitionItemBase(View target, bool isAppearing, TimePeriod timePeriod, AlphaFunction alphaFunction) : this(Interop.TransitionItemBase.New(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
+ AppearingTransition = isAppearing;
+ TimePeriod = timePeriod;
AlphaFunction = alphaFunction;
}
}
/// <summary>
+ /// Gets or sets whether this transition is appearing transition or not.
+ /// </summary>
+ public bool AppearingTransition
+ {
+ set
+ {
+ Interop.TransitionItemBase.SetAppearingTransition(SwigCPtr, value);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ }
+
+ /// <summary>
/// Downcasts a handle to TransitionItemBase handle.<br />
/// If handle points to an TransitionItemBase object, the downcast produces a valid handle.<br />
/// If not, the returned handle is left uninitialized.<br />
--- /dev/null
+/*
+ * 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.
+ *
+ */
+
+namespace Tizen.NUI
+{
+ using System;
+ using System.ComponentModel;
+ using Tizen.NUI.BaseComponents;
+
+ /// <summary>
+ /// Fade class is a cluster of properties for the fade transition of a View.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class Fade : TransitionBase
+ {
+ private float opacity = 0.0f;
+
+ /// <summary>
+ /// Create a Fade for the View pair.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Fade()
+ {
+ }
+
+ /// <summary>
+ /// Set Opacity for this fade transition.
+ /// If this transition is for appearing, the opacity of target View is animated from this property.
+ /// If this transition is for disappearing, the opacity of target View is animated to this property.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public float Opacity
+ {
+ get
+ {
+ return opacity;
+ }
+ set
+ {
+ opacity = value;
+ }
+ }
+
+ internal override TransitionItemBase CreateTransition(View view, bool isAppearing)
+ {
+ FadeItem fade = new FadeItem(view, Opacity, isAppearing, TimePeriod, AlphaFunction);
+ return fade;
+ }
+ }
+}
}
}
- internal TransitionItemBase CreateTransition(View target, bool isEntering)
+ internal virtual TransitionItemBase CreateTransition(View view, bool isAppearing)
{
- return new TransitionItemBase(target, isEntering, timePeriod, alphaFunction);
+ return new TransitionItemBase(view, isAppearing, timePeriod, alphaFunction);
}
[EditorBrowsable(EditorBrowsableState.Never)]