--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.Collections.Generic;
+using System.ComponentModel;
+using System.Text;
+using Tizen.NUI.BaseComponents;
+
+namespace Tizen.NUI
+{
+ internal class DefaultFrameBroker : FrameBrokerBase
+ {
+ private Window window;
+ private ImageView providerImage;
+
+ public delegate void AnimationEventHandler();
+ internal event AnimationEventHandler AnimationInitialized;
+ internal event AnimationEventHandler AnimationFinished;
+
+ internal DefaultFrameBroker(Window window) : base(window)
+ {
+ this.window = window;
+ }
+
+ protected override void OnFrameResumed(FrameData frame)
+ {
+ base.OnFrameResumed(frame);
+ if (AnimationInitialized != null)
+ {
+ AnimationInitialized();
+ }
+
+ if (frame.DirectionForward)
+ {
+ PlayAnimateTo(frame, ForwardAnimation);
+ }
+ else
+ {
+ PlayAnimateTo(frame, BackwardAnimation);
+ }
+
+ StartAnimation();
+ }
+
+ private void PlayAnimateTo(FrameData frame, TransitionAnimation animation)
+ {
+ if (animation)
+ {
+ providerImage = frame.Image;
+ providerImage.Size = window.Size;
+ window.Add(providerImage);
+
+ if (animation is SlideIn)
+ {
+ SlideIn slideIn = animation as SlideIn;
+ providerImage.PositionX = slideIn.GetDefaultInitValue();
+ }
+
+ animation.PlayAnimateTo(providerImage);
+ }
+ else
+ {
+ FinishAnimation();
+ }
+ }
+
+ private TransitionAnimation forwardAnimation;
+ internal TransitionAnimation ForwardAnimation
+ {
+ get
+ {
+ return forwardAnimation;
+ }
+ set
+ {
+ forwardAnimation = value;
+ forwardAnimation.Finished += Ani_Finished;
+ }
+ }
+
+ private TransitionAnimation backwardAnimation;
+ internal TransitionAnimation BackwardAnimation
+ {
+ get
+ {
+ return backwardAnimation;
+ }
+ set
+ {
+ backwardAnimation = value;
+ backwardAnimation.Finished += Ani_Finished;
+ }
+ }
+
+ private void Ani_Finished(object sender, EventArgs e)
+ {
+ if (AnimationFinished != null)
+ {
+ AnimationFinished();
+ }
+
+ if (providerImage != null)
+ {
+ providerImage.Unparent();
+ providerImage.Dispose();
+ providerImage = null;
+ }
+ FinishAnimation();
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.Collections.Generic;
+using System.ComponentModel;
+using System.Threading.Tasks;
+using Tizen.Applications;
+using Tizen.Applications.Exceptions;
+
+namespace Tizen.NUI
+{
+ /// <summary>
+ /// Represents the Frame Broker.
+ /// </summary>
+ internal abstract class FrameBrokerBase : IDisposable
+ {
+ private string LogTag = "NUI";
+ private readonly SafeFrameBrokerHandle _handle;
+ private Dictionary<int, Interop.FrameBroker.AppControlResultCallback> _resultCallbackMaps = new Dictionary<int, Interop.FrameBroker.AppControlResultCallback>();
+ private int _resultId = 0;
+ private Interop.FrameBroker.FrameContextLifecycleCallbacks _callbacks;
+ private IntPtr _context = IntPtr.Zero;
+ private bool _disposed = false;
+
+ /// <summary>
+ /// Initializes the FrameBroker class.
+ /// </summary>
+ /// <param name="window">The window instance of Ecore_Wl2_Window pointer.</param>
+ /// <exception cref="ArgumentException">Thrown when failed because of an invalid parameter.</exception>
+ /// <exception cref="OutOfMemoryException">Thrown when the memory is insufficient.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when failed to create the frame broker handle.</exception>
+ /// <remarks>This class is only avaliable for platform level signed applications.</remarks>
+ internal FrameBrokerBase(Window window)
+ {
+ Interop.FrameBroker.ErrorCode err;
+
+ if (window == null)
+ {
+ throw FrameBrokerBaseErrorFactory.GetException(Interop.FrameBroker.ErrorCode.InvalidParameter, "Invalid parameter");
+ }
+
+ _callbacks.OnCreate = new Interop.FrameBroker.FrameContextCreateCallback(OnCreateNative);
+ _callbacks.OnResume = new Interop.FrameBroker.FrameContextResumeCallback(OnResumeNavie);
+ _callbacks.OnPause = new Interop.FrameBroker.FrameContextPauseCallback(OnPauseNative);
+ _callbacks.OnDestroy = new Interop.FrameBroker.FrameContextDestroyCallback(OnDestroyNative);
+ _callbacks.OnError = new Interop.FrameBroker.FrameContextErrorCallback(OnErrorNative);
+ _callbacks.OnUpdate = new Interop.FrameBroker.FrameContextUpdateCallback(OnUpdateNative);
+
+ err = Interop.FrameBroker.Create(window.GetNativeWindowHandler(), ref _callbacks, IntPtr.Zero, out _handle);
+ if (err != Interop.FrameBroker.ErrorCode.None)
+ {
+ throw FrameBrokerBaseErrorFactory.GetException(err, "Failed to create frame broker handle");
+ }
+ }
+
+ /// <summary>
+ /// Sends the launch request asynchronously.
+ /// </summary>
+ /// <remarks>
+ /// The operation is mandatory information for the launch request.
+ /// If the operation is not specified, AppControlOperations.Default is used by default.
+ /// If the operation is AppControlOperations.Default, the application ID is mandatory to explicitly launch the application.<br/>
+ /// Since Tizen 2.4, the launch request of the service application over out of packages is restricted by the platform.
+ /// Also, implicit launch requests are NOT delivered to service applications since 2.4.
+ /// To launch a service application, an explicit launch request with the application ID given by property ApplicationId MUST be sent.
+ /// </remarks>
+ /// <param name="appControl">The AppControl.</param>
+ /// <param name="toProvider"> The flag, if it's true, the launch request is sent to the frame provider application.</param>
+ /// <returns>A task with the result of the launch request.</returns>
+ /// <exception cref="ArgumentException">Thrown when failed because of the argument is invalid.</exception>
+ /// <exception cref="AppNotFoundException">Thrown when the application to run is not found.</exception>
+ /// <exception cref="LaunchRejectedException">Thrown when the launch request is rejected.</exception>
+ /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+ internal Task<FrameBrokerBaseResult> SendLaunchRequest(AppControl appControl, bool toProvider)
+ {
+ if (appControl == null)
+ {
+ throw FrameBrokerBaseErrorFactory.GetException(Interop.FrameBroker.ErrorCode.InvalidParameter, "Invalid parameter");
+ }
+
+ var task = new TaskCompletionSource<FrameBrokerBaseResult>();
+ int requestId = 0;
+
+ lock (_resultCallbackMaps)
+ {
+ requestId = _resultId++;
+ _resultCallbackMaps[requestId] = (handle, result, userData) =>
+ {
+ task.SetResult((FrameBrokerBaseResult)result);
+ lock (_resultCallbackMaps)
+ {
+ _resultCallbackMaps.Remove((int)userData);
+ }
+ };
+ }
+
+ Interop.FrameBroker.ErrorCode err;
+ if (toProvider)
+ err = Interop.FrameBroker.SendLaunchRequestToProvider(_handle, appControl.SafeAppControlHandle, _resultCallbackMaps[requestId], null, (IntPtr)requestId);
+ else
+ err = Interop.FrameBroker.SendLaunchRequest(_handle, appControl.SafeAppControlHandle, _resultCallbackMaps[requestId], null, (IntPtr)requestId);
+
+ if (err != Interop.FrameBroker.ErrorCode.None)
+ {
+ throw FrameBrokerBaseErrorFactory.GetException(err, "Failed to send launch request");
+ }
+
+ return task.Task;
+ }
+
+ /// <summary>
+ /// Notifies that the animation is started.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when failed because of the argument is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when failed because of system error.</exception>
+ internal void StartAnimation()
+ {
+ Interop.FrameBroker.ErrorCode err = Interop.FrameBroker.StartAnimation(_context);
+ if (err != Interop.FrameBroker.ErrorCode.None)
+ {
+ throw FrameBrokerBaseErrorFactory.GetException(err, "Failed to notify that the animation is started");
+ }
+ }
+
+ /// <summary>
+ /// Notifies that the animation is finished.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when failed because of the argument is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when failed because of system error.</exception>
+ internal void FinishAnimation()
+ {
+ Interop.FrameBroker.ErrorCode err = Interop.FrameBroker.FinishAnimation(_context);
+ if (err != Interop.FrameBroker.ErrorCode.None)
+ {
+ throw FrameBrokerBaseErrorFactory.GetException(err, "Failed to notify that the animation is finished");
+ }
+ }
+
+ /// <summary>
+ /// Occurs whenever the frame is created.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void OnFrameCreated()
+ {
+ Log.Warn(LogTag, "The OnFrameCreated() is not implemented");
+ }
+
+ /// <summary>
+ /// Occurs Whenever the frame is resumed.
+ /// </summary>
+ /// <param name="frame">The frame data.</param>
+ /// <remarks>
+ /// When the frame has been prepared, this function is called.
+ /// The caller can start animations, To notify that the animation is started, the caller should call StartAnimation().
+ /// After the animation is finished, the caller should call FinishAnimation() to notify.
+ /// </remarks>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void OnFrameResumed(FrameData frame)
+ {
+ Log.Warn(LogTag, "The OnFrameResumed() is not implemented");
+ }
+
+ /// <summary>
+ /// Occurs Whenever the frame is updated.
+ /// </summary>
+ /// <param name="frame">The frame data.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void OnFrameUpdated(FrameData frame)
+ {
+ Log.Warn(LogTag, "The OnFrameUpdated() is not implemented");
+ }
+
+ /// <summary>
+ /// Occurs Whenever the frame is paused.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void OnFramePaused()
+ {
+ Log.Warn(LogTag, "The OnFramePaused() is not implemented");
+ }
+
+ /// <summary>
+ /// Occurs Whenever the frame is destroyed.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void OnFrameDestroyed()
+ {
+ Log.Warn(LogTag, "The OnFrameDestroyed() is not implemented");
+ }
+
+ /// <summary>
+ /// Occurs Whenever the system error is occurred.
+ /// </summary>
+ /// <param name="error">The frame error.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void OnFrameErred(FrameError error)
+ {
+ Log.Warn(LogTag, "The OnFrameErred() is not implemented");
+ }
+
+ private void OnCreateNative(IntPtr context, IntPtr userData)
+ {
+ _context = context;
+ OnFrameCreated();
+ }
+
+ private void OnResumeNavie(IntPtr context, IntPtr frame, IntPtr userData)
+ {
+ OnFrameResumed(new FrameData(frame));
+ }
+
+ private void OnPauseNative(IntPtr context, IntPtr userData)
+ {
+ OnFramePaused();
+ }
+
+ private void OnDestroyNative(IntPtr context, IntPtr userData)
+ {
+ _context = IntPtr.Zero;
+ OnFrameDestroyed();
+ }
+
+ private void OnErrorNative(IntPtr context, int error, IntPtr userData)
+ {
+ _context = IntPtr.Zero;
+ OnFrameErred((FrameError)error);
+ }
+
+ private void OnUpdateNative(IntPtr context, IntPtr frame, IntPtr userData)
+ {
+ OnFrameUpdated(new FrameData(frame));
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ _handle.Dispose();
+ _disposed = true;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Dispose()
+ {
+ Dispose(true);
+
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.Runtime.CompilerServices;
+using Tizen.Applications.Exceptions;
+
+namespace Tizen.NUI
+{
+ internal static class FrameBrokerBaseErrorFactory
+ {
+ private static string LogTag = "Tizen.NUI";
+
+ internal static Exception GetException(Interop.FrameBroker.ErrorCode err, string message, [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0)
+ {
+ Log.Error(LogTag, memberName + "(" + lineNumber + ") " + message);
+ switch (err)
+ {
+ case Interop.FrameBroker.ErrorCode.InvalidParameter:
+ return new ArgumentException("Invalid Parameter");
+ case Interop.FrameBroker.ErrorCode.OutOfMemory:
+ return new Applications.Exceptions.OutOfMemoryException("Out Of Memory");
+ case Interop.FrameBroker.ErrorCode.AppNotFound:
+ return new AppNotFoundException("App Not Found");
+ case Interop.FrameBroker.ErrorCode.LaunchRejected:
+ return new LaunchRejectedException("Launch Rejected");
+ case Interop.FrameBroker.ErrorCode.IoError:
+ return new InvalidOperationException("IO Error");
+ case Interop.FrameBroker.ErrorCode.PermissionDenied:
+ return new PermissionDeniedException("Permission Denied");
+ default:
+ return new InvalidOperationException(message);
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.ComponentModel;
+
+namespace Tizen.NUI
+{
+ /// <summary>
+ /// Enumeration for the frame broker result.
+ /// </summary>
+ internal enum FrameBrokerBaseResult
+ {
+ /// <summary>
+ /// Successful.
+ /// </summary>
+ None = Interop.FrameBroker.ErrorCode.None,
+
+ /// <summary>
+ /// Invalid parameter.
+ /// </summary>
+ InvalidParameter = Interop.FrameBroker.ErrorCode.InvalidParameter,
+
+ /// <summary>
+ /// The memory is insufficient.
+ /// </summary>
+ OutOfMemory = Interop.FrameBroker.ErrorCode.OutOfMemory,
+
+ /// <summary>
+ /// The application to run the given launch request is not found.
+ /// </summary>
+ AppNotFound = Interop.FrameBroker.ErrorCode.AppNotFound,
+
+ /// <summary>
+ /// The application cannot be launched in current context.
+ /// </summary>
+ LaunchRejected = Interop.FrameBroker.ErrorCode.LaunchRejected,
+
+ /// <summary>
+ /// I/O error.
+ /// </summary>
+ IoError = Interop.FrameBroker.ErrorCode.IoError,
+
+ /// <summary>
+ /// Permission denied.
+ /// </summary>
+ PermissionDenied = Interop.FrameBroker.ErrorCode.PermissionDenied,
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 Tizen.NUI.BaseComponents;
+using Tizen.Applications;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+
+namespace Tizen.NUI
+{
+ /// <summary>
+ /// Represents the Frame Data.
+ /// </summary>
+ internal class FrameData
+ {
+ private const string LogTag = "NUI";
+ private readonly IntPtr _frame;
+ private int _fd = -1;
+ private uint _size = 0;
+ private ImageView _image = null;
+
+ private Renderer renderer;
+ private TextureSet textureSet;
+
+ internal FrameData(IntPtr frame)
+ {
+ _frame = frame;
+ }
+
+ private Shader CreateShader()
+ {
+ string vertex_shader =
+ "attribute mediump vec2 aPosition;\n" +
+ "varying mediump vec2 vTexCoord;\n" +
+ "uniform highp mat4 uMvpMatrix;\n" +
+ "uniform mediump vec3 uSize;\n" +
+ "varying mediump vec2 sTexCoordRect;\n" +
+ "void main()\n" +
+ "{\n" +
+ "gl_Position = uMvpMatrix * vec4(aPosition * uSize.xy, 0.0, 1.0);\n" +
+ "vTexCoord = aPosition + vec2(0.5);\n" +
+ "}\n";
+
+ string fragment_shader =
+ "#extension GL_OES_EGL_image_external:require\n" +
+ "uniform lowp vec4 uColor;\n" +
+ "varying mediump vec2 vTexCoord;\n" +
+ "uniform samplerExternalOES sTexture;\n" +
+ "void main()\n" +
+ "{\n" +
+ "gl_FragColor = texture2D(sTexture, vTexCoord) * uColor;\n" +
+ "}\n";
+
+ return new Shader(vertex_shader, fragment_shader);
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ private struct Vec2
+ {
+ float x;
+ float y;
+ public Vec2(float xIn, float yIn)
+ {
+ x = xIn;
+ y = yIn;
+ }
+ }
+
+ private struct TexturedQuadVertex
+ {
+ public Vec2 position;
+ };
+
+ private IntPtr RectangleDataPtr()
+ {
+ TexturedQuadVertex vertex1 = new TexturedQuadVertex();
+ TexturedQuadVertex vertex2 = new TexturedQuadVertex();
+ TexturedQuadVertex vertex3 = new TexturedQuadVertex();
+ TexturedQuadVertex vertex4 = new TexturedQuadVertex();
+ vertex1.position = new Vec2(-0.5f, -0.5f);
+ vertex2.position = new Vec2(-0.5f, 0.5f);
+ vertex3.position = new Vec2(0.5f, -0.5f);
+ vertex4.position = new Vec2(0.5f, 0.5f);
+
+ TexturedQuadVertex[] texturedQuadVertexData = new TexturedQuadVertex[4] { vertex1, vertex2, vertex3, vertex4 };
+
+ int lenght = Marshal.SizeOf(vertex1);
+ IntPtr pA = Marshal.AllocHGlobal(lenght * 4);
+
+ for (int i = 0; i < 4; i++)
+ {
+ Marshal.StructureToPtr(texturedQuadVertexData[i], pA + i * lenght, true);
+ }
+
+ return pA;
+ }
+
+ private Geometry CreateQuadGeometry()
+ {
+ /* Create Property buffer */
+ PropertyMap vertexFormat = new PropertyMap();
+ vertexFormat.Add("aPosition", new PropertyValue((int)PropertyType.Vector2));
+
+ PropertyBuffer vertexBuffer = new PropertyBuffer(vertexFormat);
+ vertexBuffer.SetData(RectangleDataPtr(), 4);
+
+
+ Geometry geometry = new Geometry();
+ geometry.AddVertexBuffer(vertexBuffer);
+ geometry.SetType(Geometry.Type.TRIANGLE_STRIP);
+
+ return geometry;
+ }
+
+ /// <summary>
+ /// Gets the image view.
+ /// </summary>
+ internal ImageView Image
+ {
+ get
+ {
+ if (_image == null)
+ {
+ _image = new ImageView();
+ renderer = new Renderer(CreateQuadGeometry(), CreateShader());
+ textureSet = new TextureSet();
+ }
+ switch (Type)
+ {
+ case FrameType.RemoteSurfaceTbmSurface:
+ if (TbmSurface == null)
+ {
+ return null;
+ }
+ textureSet.SetTexture(0, new Texture(TbmSurface));
+ renderer.SetTextures(textureSet);
+ _image.AddRenderer(renderer);
+ break;
+ default:
+ break;
+ }
+
+ return _image;
+ }
+ }
+
+ /// <summary>
+ /// Checks whether the direction of the frame is forward or not.
+ /// </summary>
+ internal bool DirectionForward
+ {
+ get
+ {
+ Interop.FrameBroker.FrameDirection direction = Interop.FrameBroker.FrameDirection.Backward + 1;
+ Interop.FrameBroker.ErrorCode err = Interop.FrameBroker.GetDirection(_frame, out direction);
+ if (err != Interop.FrameBroker.ErrorCode.None)
+ {
+ Log.Error(LogTag, "Failed to get direction");
+ }
+ return (direction == Interop.FrameBroker.FrameDirection.Forward);
+ }
+ }
+
+ /// <summary>
+ /// Gets the extra data.
+ /// </summary>
+ internal Bundle Extra
+ {
+ get
+ {
+ SafeBundleHandle safeBundle;
+ Interop.FrameBroker.ErrorCode err = Interop.FrameBroker.GetExtraData(_frame, out safeBundle);
+ if (err != Interop.FrameBroker.ErrorCode.None)
+ {
+ Log.Error(LogTag, "Failed to get extra data");
+ return null;
+ }
+ return new Bundle(safeBundle);
+ }
+ }
+
+ /// <summary>
+ /// Enumeration for the frame type.
+ /// </summary>
+ internal enum FrameType
+ {
+ /// <summary>
+ /// The tbm surface of the remote surface.
+ /// </summary>
+ RemoteSurfaceTbmSurface,
+
+ /// <summary>
+ /// The image file of the remote surface.
+ /// </summary>
+ RemoteSurfaceImageFile,
+
+ /// <summary>
+ /// The image of the splash screen.
+ /// </summary>
+ SplashScreenImage,
+
+ /// <summary>
+ /// The edje of the splash screen.
+ /// </summary>
+ SPlashScreenEdje,
+ }
+
+ /// <summary>
+ /// Enumeration for the direction of the frame.
+ /// </summary>
+ internal enum FrameDirection
+ {
+ /// <summary>
+ /// The direction that is from the caller to the other application.
+ /// </summary>
+ Forward,
+
+ /// <summary>
+ /// The direction that is from the other application to the caller.
+ /// </summary>
+ Backward,
+ }
+
+ /// <summary>
+ /// Gets the tbm surface of the remote surface.
+ /// </summary>
+ /// <value>
+ /// The TbmSurface type is tbm_surface_h.
+ /// </value>
+ internal IntPtr TbmSurface
+ {
+ get
+ {
+ IntPtr tbmSurface = IntPtr.Zero;
+ Interop.FrameBroker.ErrorCode err = Interop.FrameBroker.GetTbmSurface(_frame, out tbmSurface);
+
+ if (err != Interop.FrameBroker.ErrorCode.None)
+ {
+ Log.Error(LogTag, "Failed to get tbm surface");
+ }
+ return tbmSurface;
+ }
+ }
+
+ /// <summary>
+ /// Gets the file descriptor of the image file of the remote surface.
+ /// </summary>
+ internal int Fd
+ {
+ get
+ {
+ if (_fd != -1)
+ return _fd;
+
+ Interop.FrameBroker.ErrorCode err = Interop.FrameBroker.GetImageFile(_frame, out _fd, out _size);
+ if (err != Interop.FrameBroker.ErrorCode.None)
+ {
+ Log.Error(LogTag, "Failed to get fd of image file");
+ }
+ return _fd;
+ }
+ }
+
+ /// <summary>
+ /// Gets the size of the image file of the remote surface.
+ /// </summary>
+ internal uint Size
+ {
+ get
+ {
+ if (_size != 0)
+ return _size;
+
+ Interop.FrameBroker.ErrorCode err = Interop.FrameBroker.GetImageFile(_frame, out _fd, out _size);
+ if (err != Interop.FrameBroker.ErrorCode.None)
+ {
+ Log.Error(LogTag, "Failed to get size of image file");
+ }
+ return _size;
+ }
+ }
+
+ /// <summary>
+ /// Gets the file path.
+ /// </summary>
+ internal string FilePath
+ {
+ get
+ {
+ string filePath = string.Empty;
+ Interop.FrameBroker.ErrorCode err = Interop.FrameBroker.GetFilePath(_frame, out filePath);
+ if (err != Interop.FrameBroker.ErrorCode.None)
+ {
+ Log.Error(LogTag, "Failed to get file path");
+ }
+ return filePath;
+ }
+ }
+
+ /// <summary>
+ /// Gets the file group.
+ /// </summary>
+ internal string FileGroup
+ {
+ get
+ {
+ string fileGroup = string.Empty;
+ Interop.FrameBroker.ErrorCode err = Interop.FrameBroker.GetFileGroup(_frame, out fileGroup);
+ if (err != Interop.FrameBroker.ErrorCode.None)
+ {
+ Log.Error(LogTag, "Failed to get file group");
+ }
+ return fileGroup;
+ }
+ }
+
+ /// <summary>
+ /// Gets the type of the frame.
+ /// </summary>
+ internal FrameType Type
+ {
+ get
+ {
+ Interop.FrameBroker.FrameType type = Interop.FrameBroker.FrameType.SplashScreenImage + 1;
+ Interop.FrameBroker.ErrorCode err = Interop.FrameBroker.GetType(_frame, out type);
+ if (err != Interop.FrameBroker.ErrorCode.None)
+ {
+ Log.Error(LogTag, "Failed to get frame type");
+ }
+ return (FrameType)type;
+ }
+ }
+
+ /// <summary>
+ /// Gets the position X.
+ /// </summary>
+ internal int PositionX
+ {
+ get
+ {
+ int x = -1;
+ Interop.FrameBroker.ErrorCode err = Interop.FrameBroker.GetPositionX(_frame, out x);
+ if (err != Interop.FrameBroker.ErrorCode.None)
+ {
+ Log.Error(LogTag, "Failed to get position X");
+ }
+ return x;
+ }
+ }
+
+ /// <summary>
+ /// Gets the position Y.
+ /// </summary>
+ internal int PositionY
+ {
+ get
+ {
+ int y = -1;
+ Interop.FrameBroker.ErrorCode err = Interop.FrameBroker.GetPositionY(_frame, out y);
+ if (err != Interop.FrameBroker.ErrorCode.None)
+ {
+ Log.Error(LogTag, "Failed to get position Y");
+ }
+ return y;
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.ComponentModel;
+
+namespace Tizen.NUI
+{
+ /// <summary>
+ /// Enumeration for the frame error.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public enum FrameError
+ {
+ /// <summary>
+ /// Succsssful.
+ /// </summary>
+ None = Interop.FrameBroker.FrameContextErrorCode.None,
+
+ /// <summary>
+ /// Disqualified.
+ /// </summary>
+ /// <remarks>After this error is occured, the FrameBroker instance has to be destroyed.</remarks>
+ Disqualified = Interop.FrameBroker.FrameContextErrorCode.Disqualified,
+
+ /// <summary>
+ /// Wrong Request.
+ /// </summary>
+ WrongRequest = Interop.FrameBroker.FrameContextErrorCode.WrongRequest,
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.Runtime.InteropServices;
+
+namespace Tizen.NUI
+{
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public sealed class SafeFrameBrokerHandle : SafeHandle
+ {
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public SafeFrameBrokerHandle() : base(IntPtr.Zero, true)
+ {
+ }
+
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public SafeFrameBrokerHandle(IntPtr existingHandleValue, bool ownsHandle) : base(IntPtr.Zero, ownsHandle)
+ {
+ SetHandle(existingHandleValue);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool IsInvalid
+ {
+ get
+ {
+ return this.handle == IntPtr.Zero;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override bool ReleaseHandle()
+ {
+ Interop.FrameBroker.DangerousDestroy(this.handle);
+ this.SetHandle(IntPtr.Zero);
+ return true;
+ }
+
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 Tizen.Applications;
+
+namespace Tizen.NUI
+{
+ /// <summary>
+ /// Represents the Frame Provider.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal class FrameProvider : IDisposable
+ {
+ private string LogTag = "NUI";
+ private readonly SafeFrameProviderHandle _handle;
+ private Interop.FrameProvider.FrameProviderEventCallbacks _callbacks;
+ private bool _disposed = false;
+
+
+ /// <summary>
+ /// Initializes the FrameProvider class.
+ /// </summary>
+ /// <param name="window">The window instance of Ecore_Wl2_Window pointer.</param>
+ /// <exception cref="ArgumentException">Thrown when failed because of an invalid parameter.</exception>
+ /// <exception cref="Exceptions.OutOfMemoryException">Thrown when the memory is insufficient.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when failed to create the frame broker handle.</exception>
+ /// <remarks>This class is only avaliable for platform level signed applications.</remarks>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal FrameProvider(Window window)
+ {
+ Interop.FrameProvider.ErrorCode err;
+
+ if (window == null)
+ {
+ throw FrameProviderErrorFactory.GetException(Interop.FrameProvider.ErrorCode.InvalidParameter, "Invalid parameter");
+ }
+
+ _callbacks.OnShow = new Interop.FrameProvider.ShowCallback(OnShowNative);
+ _callbacks.OnHide = new Interop.FrameProvider.HideCallback(OnHideNative);
+
+ err = Interop.FrameProvider.Create(window.GetNativeWindowHandler(), ref _callbacks, IntPtr.Zero, out _handle);
+ if (err != Interop.FrameProvider.ErrorCode.None)
+ {
+ throw FrameProviderErrorFactory.GetException(err, "Failed to create frame provider handle");
+ }
+ }
+
+ /// <summary>
+ /// Occurs whenever the window is shown.
+ /// </summary>
+ /// <remarks>You have to call NotifyShowStatus() to notify that the object is prepared to show.</remarks>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal event EventHandler Shown;
+
+ /// <summary>
+ /// Occurs whenever the window is hidden.
+ /// </summary>
+ /// <remarks>You have to call NotifyHideStatus() to notify that the object is prepared to hide.</remarks>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal event EventHandler Hidden;
+
+ private void OnShowNative(IntPtr handle, IntPtr userData)
+ {
+ Log.Debug(LogTag, "OnShowNative()");
+ Shown?.Invoke(this, EventArgs.Empty);
+ }
+
+ private void OnHideNative(IntPtr handle, IntPtr userdata)
+ {
+ Log.Debug(LogTag, "OnHideNative()");
+ Hidden?.Invoke(this, EventArgs.Empty);
+ }
+
+ /// <summary>
+ /// Notifies that the object is prepared to show.
+ /// </summary>
+ /// <param name="extraData">The extra data.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal void NotifyShowStatus(Bundle extraData)
+ {
+ Interop.FrameProvider.ErrorCode err = Interop.FrameProvider.NotifyShowStatus(_handle, extraData.SafeBundleHandle);
+ if (err != Interop.FrameProvider.ErrorCode.None)
+ {
+ throw FrameProviderErrorFactory.GetException(err, "Failed to notify show status");
+ }
+ }
+
+ /// <summary>
+ /// Notifies that the object is prepared to hide.
+ /// </summary>
+ /// <param name="extraData">The extra data.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal void NotifyHideStatus(Bundle extraData)
+ {
+ Interop.FrameProvider.ErrorCode err = Interop.FrameProvider.NotifyHideStatus(_handle, extraData.SafeBundleHandle);
+ if (err != Interop.FrameProvider.ErrorCode.None)
+ {
+ throw FrameProviderErrorFactory.GetException(err, "Failed to notify hide status");
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ _handle.Dispose();
+ _disposed = true;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Dispose()
+ {
+ Dispose(true);
+
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.Runtime.CompilerServices;
+
+namespace Tizen.NUI
+{
+ internal static class FrameProviderErrorFactory
+ {
+ private static string LogTag = "Tizen.NUI";
+
+ internal static Exception GetException(Interop.FrameProvider.ErrorCode err, string message, [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0)
+ {
+ Log.Error(LogTag, memberName + "(" + lineNumber + ") " + message);
+ switch (err)
+ {
+ case Interop.FrameProvider.ErrorCode.InvalidParameter:
+ return new ArgumentException("Invalid Parameter");
+ case Interop.FrameProvider.ErrorCode.OutOfMemory:
+ return new OutOfMemoryException("Out Of Memory");
+ case Interop.FrameProvider.ErrorCode.IoError:
+ return new InvalidOperationException("IO Error");
+ default:
+ return new InvalidOperationException(message);
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.Runtime.InteropServices;
+
+namespace Tizen.NUI
+{
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal sealed class SafeFrameProviderHandle : SafeHandle
+ {
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal SafeFrameProviderHandle() : base(IntPtr.Zero, true)
+ {
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal SafeFrameProviderHandle(IntPtr existingHandleValue, bool ownsHandle) : base(IntPtr.Zero, ownsHandle)
+ {
+ SetHandle(existingHandleValue);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool IsInvalid
+ {
+ get
+ {
+ return this.handle == IntPtr.Zero;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override bool ReleaseHandle()
+ {
+ Interop.FrameProvider.DangerousDestroy(this.handle);
+ this.SetHandle(IntPtr.Zero);
+ return true;
+ }
+
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.Runtime.InteropServices;
+using Tizen.Applications;
+using Tizen.NUI;
+
+namespace Tizen.NUI
+{
+ internal static partial class Interop
+ {
+ internal static partial class FrameBroker
+ {
+ internal enum ErrorCode
+ {
+ None = Tizen.Internals.Errors.ErrorCode.None,
+ InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+ OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+ AppNotFound = AppControlResult.AppNotFound,
+ LaunchRejected = AppControlResult.LaunchRejected,
+ IoError = Tizen.Internals.Errors.ErrorCode.IoError,
+ PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
+ }
+
+ internal enum FrameContextErrorCode
+ {
+ None = 0,
+ Disqualified = 1,
+ WrongRequest = 2,
+ }
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void AppControlResultCallback(IntPtr request, int result, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void AppControlReplyCallback(IntPtr request, IntPtr reply, int result, IntPtr userData);
+
+ internal delegate void FrameContextCreateCallback(IntPtr context, IntPtr userData);
+
+ internal delegate void FrameContextResumeCallback(IntPtr context, IntPtr frame, IntPtr userData);
+
+ internal delegate void FrameContextPauseCallback(IntPtr context, IntPtr userData);
+
+ internal delegate void FrameContextDestroyCallback(IntPtr context, IntPtr userData);
+
+ internal delegate void FrameContextErrorCallback(IntPtr context, int error, IntPtr userData);
+
+ internal delegate void FrameContextUpdateCallback(IntPtr context, IntPtr frame, IntPtr userData);
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct FrameContextLifecycleCallbacks
+ {
+ public FrameContextCreateCallback OnCreate;
+ public FrameContextResumeCallback OnResume;
+ public FrameContextPauseCallback OnPause;
+ public FrameContextDestroyCallback OnDestroy;
+ public FrameContextUpdateCallback OnUpdate;
+ public FrameContextErrorCallback OnError;
+ }
+
+ [DllImport(Libraries.FrameBroker, EntryPoint = "frame_context_start_animation")]
+ internal static extern ErrorCode StartAnimation(IntPtr handle);
+
+ [DllImport(Libraries.FrameBroker, EntryPoint = "frame_context_finish_animation")]
+ internal static extern ErrorCode FinishAnimation(IntPtr handle);
+
+
+ [DllImport(Libraries.FrameBroker, EntryPoint = "frame_broker_create")]
+ internal static extern ErrorCode Create(IntPtr wl2Win, ref FrameContextLifecycleCallbacks callbacks, IntPtr userData, out SafeFrameBrokerHandle handle);
+
+ [DllImport(Libraries.FrameBroker, EntryPoint = "frame_broker_destroy")]
+ internal static extern ErrorCode DangerousDestroy(IntPtr handle);
+
+ [DllImport(Libraries.FrameBroker, EntryPoint = "frame_broker_send_launch_request")]
+ internal static extern ErrorCode SendLaunchRequest(SafeFrameBrokerHandle handle, SafeAppControlHandle safeAppControlHandle, AppControlResultCallback resultCallback, AppControlReplyCallback replyCallback, IntPtr userData);
+
+ [DllImport(Libraries.FrameBroker, EntryPoint = "frame_broker_send_launch_request_to_provider")]
+ internal static extern ErrorCode SendLaunchRequestToProvider(SafeFrameBrokerHandle handle, SafeAppControlHandle safeAppControlHandle, AppControlResultCallback resultCallback, AppControlReplyCallback replyCallback, IntPtr userData);
+
+
+ internal enum FrameType
+ {
+ RemoteSurfaceTbmSurface = 0,
+ RemoteSurfaceImageFile = 1,
+ SplashScreenImage = 2,
+ SplashScreenEdje = 3,
+ }
+
+ internal enum FrameDirection
+ {
+ Forward = 0,
+ Backward = 1,
+ }
+
+ [DllImport(Libraries.FrameBroker, EntryPoint = "frame_get_tbm_surface")]
+ internal static extern ErrorCode GetTbmSurface(IntPtr handle, out IntPtr tbmSurface);
+
+ [DllImport(Libraries.FrameBroker, EntryPoint = "frame_get_image_file")]
+ internal static extern ErrorCode GetImageFile(IntPtr handle, out Int32 fd, out UInt32 size);
+
+ [DllImport(Libraries.FrameBroker, EntryPoint = "frame_get_file_path")]
+ internal static extern ErrorCode GetFilePath(IntPtr handle, out string filePath);
+
+ [DllImport(Libraries.FrameBroker, EntryPoint = "frame_get_file_group")]
+ internal static extern ErrorCode GetFileGroup(IntPtr handle, out string fileGroup);
+
+ [DllImport(Libraries.FrameBroker, EntryPoint = "frame_get_type")]
+ internal static extern ErrorCode GetType(IntPtr handle, out FrameType type);
+
+ [DllImport(Libraries.FrameBroker, EntryPoint = "frame_get_direction")]
+ internal static extern ErrorCode GetDirection(IntPtr handle, out FrameDirection direction);
+
+ [DllImport(Libraries.FrameBroker, EntryPoint = "frame_get_position_x")]
+ internal static extern ErrorCode GetPositionX(IntPtr handle, out Int32 x);
+
+ [DllImport(Libraries.FrameBroker, EntryPoint = "frame_get_position_y")]
+ internal static extern ErrorCode GetPositionY(IntPtr handle, out Int32 y);
+
+ [DllImport(Libraries.FrameBroker, EntryPoint = "frame_get_extra_data")]
+ internal static extern ErrorCode GetExtraData(IntPtr handle, out SafeBundleHandle safeBundleHandle);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.Runtime.InteropServices;
+
+using Tizen.NUI;
+using Tizen.Applications;
+
+namespace Tizen.NUI
+{
+ internal static partial class Interop
+ {
+ internal static partial class FrameProvider
+ {
+ internal enum ErrorCode
+ {
+ None = Tizen.Internals.Errors.ErrorCode.None,
+ InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation,
+ InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+ IoError = Tizen.Internals.Errors.ErrorCode.IoError,
+ OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+ }
+
+ internal delegate void ShowCallback(IntPtr handle, IntPtr userData);
+
+ internal delegate void HideCallback(IntPtr handle, IntPtr userData);
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct FrameProviderEventCallbacks
+ {
+ public ShowCallback OnShow;
+ public HideCallback OnHide;
+ }
+
+ [DllImport(Libraries.FrameProvider, EntryPoint = "frame_provider_create")]
+ internal static extern ErrorCode Create(IntPtr wl2Win, ref FrameProviderEventCallbacks callbacks, IntPtr userData, out SafeFrameProviderHandle handle);
+
+ [DllImport(Libraries.FrameProvider, EntryPoint = "frame_provider_destroy")]
+ internal static extern ErrorCode DangerousDestroy(IntPtr handle);
+
+ [DllImport(Libraries.FrameProvider, EntryPoint = "frame_provider_notify_show_status")]
+ internal static extern ErrorCode NotifyShowStatus(SafeFrameProviderHandle handle, SafeBundleHandle safeBundleHandle);
+
+ [DllImport(Libraries.FrameProvider, EntryPoint = "frame_provider_notify_hide_status")]
+ internal static extern ErrorCode NotifyHideStatus(SafeFrameProviderHandle handle, SafeBundleHandle safeBundleHandle);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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
+{
+ internal static partial class Interop
+ {
+ internal static partial class Libraries
+ {
+ internal const string FrameBroker = "libframe-broker.so.1";
+ internal const string FrameProvider = "libframe-provider.so.1";
+ }
+ }
+}
private static System.Resources.ResourceManager resourceManager = null;
private Size2D _windowSize2D = null;
private Position2D _windowPosition2D = null;
+ private TransitionOptions transitionOptions;
+
/// <summary>
/// The default constructor.
Interop.Application.Application_PreInitialize();
Application.NewApplication("", Application.WindowMode.Opaque);
}
+
+ /// <summary>
+ /// This is used to improve application launch performance.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SendLaunchRequest(AppControl appControl)
+ {
+ transitionOptions.SendLaunchRequest(appControl);
+ }
+
+ /// <summary>
+ /// This is used to improve application launch performance.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public TransitionOptions TransitionOptions
+ {
+ get
+ {
+ return transitionOptions;
+ }
+ set
+ {
+ transitionOptions = value;
+ }
+ }
}
/// <summary>
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Text;
+using Tizen.NUI;
+
+namespace Tizen.NUI
+{
+ /// <summary>
+ /// Transition animation effect
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class TransitionAnimation : Animation
+ {
+ /// <summary>
+ /// Create an instance of Transition.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public TransitionAnimation(int durationMilliSeconds) : base(durationMilliSeconds)
+ {
+
+ }
+ }
+
+ /// <summary>
+ /// Screen slides are transitions between one entire screen to another
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class SlideIn : TransitionAnimation
+ {
+ private int defaultInitValue = 0;
+
+ /// <summary>
+ /// Create an instance of SlideIn.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public SlideIn(int durationMilliSeconds) : base(durationMilliSeconds)
+ {
+ Properties = new string[1];
+ DestValue = new string[1];
+ StartTime = new int[1];
+ EndTime = new int[1];
+
+ StartTime[0] = 0;
+ EndTime[0] = durationMilliSeconds;
+
+ Properties[0] = "PositionX";
+ DestValue[0] = "0";
+
+ defaultInitValue = -Window.Instance.GetWindowSize().Width;
+ }
+
+ internal int GetDefaultInitValue()
+ {
+ return defaultInitValue;
+ }
+ }
+
+
+ /// <summary>
+ /// Screen slides are transitions between one entire screen to another
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class SlideOut : TransitionAnimation
+ {
+ private int defaultInitValue = 0;
+
+ /// <summary>
+ /// Create an instance of SlideOut.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public SlideOut(int durationMilliSeconds) : base(durationMilliSeconds)
+ {
+ Properties = new string[1];
+ DestValue = new string[1];
+ StartTime = new int[1];
+ EndTime = new int[1];
+
+ StartTime[0] = 0;
+ EndTime[0] = durationMilliSeconds;
+
+ Properties[0] = "PositionX";
+
+ DestValue[0] = Window.Instance.GetWindowSize().Width.ToString();
+
+ defaultInitValue = 0;
+ }
+
+ internal int GetDefaultInitValue()
+ {
+ return defaultInitValue;
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.Collections.Generic;
+using System.ComponentModel;
+using System.Text;
+using Tizen.Applications;
+
+namespace Tizen.NUI
+{
+ /// <summary>
+ /// Setting screen transition options.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class TransitionOptions : IDisposable
+ {
+ private FrameProvider frameProvider;
+ private DefaultFrameBroker frameBroker;
+
+ private bool enableTransition = false;
+ private Window mainWindow;
+ private string sharedId;
+
+ /// <summary>
+ /// Initializes the TransitionOptions class.
+ /// </summary>
+ /// <param name="window">The window instance of NUI Window</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public TransitionOptions(Window window)
+ {
+ mainWindow = window;
+ }
+
+ /// <summary>
+ /// Gets or sets transition enable
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool EnableTransition
+ {
+ get
+ {
+ return enableTransition;
+ }
+
+ set
+ {
+ if (value)
+ {
+ frameBroker = new DefaultFrameBroker(mainWindow);
+ frameBroker.AnimationInitialized += FrameBroker_TransitionAnimationInitialized;
+ frameBroker.AnimationFinished += FrameBroker_TransitionAnimationFinished;
+ EnableProvider();
+ }
+ enableTransition = value;
+ }
+ }
+
+ private void EnableProvider()
+ {
+ frameProvider = new FrameProvider(mainWindow);
+ frameProvider.Shown += FrameProvider_Shown;
+ frameProvider.Hidden += FrameProvider_Hidden;
+ }
+
+ /// <summary>
+ /// Gets or sets the Shared object Id
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public String SharedId
+ {
+ set
+ {
+ sharedId = value;
+ }
+ get
+ {
+ return sharedId;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the forward animation of launching
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public TransitionAnimation ForwardAnimation
+ {
+ get
+ {
+ return frameBroker?.ForwardAnimation;
+ }
+ set
+ {
+ if (frameBroker != null)
+ {
+ frameBroker.ForwardAnimation = value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the backward animation of launching
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public TransitionAnimation BackwardAnimation
+
+ {
+ get
+ {
+ return frameBroker?.BackwardAnimation;
+ }
+ set
+ {
+ if (frameBroker != null)
+ {
+ frameBroker.BackwardAnimation = value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Emits the event when the animation is started.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler AnimationInitialized;
+
+ /// <summary>
+ /// Emits the event when the animation is finished.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler AnimationFinished;
+
+
+ /// <summary>
+ /// Dispose for IDisposable pattern
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Dispose()
+ {
+ if (frameBroker != null)
+ {
+ frameBroker.Dispose();
+ }
+
+ if (frameProvider != null)
+ {
+ frameProvider.Dispose();
+ }
+ }
+
+ private void FrameBroker_TransitionAnimationFinished()
+ {
+ AnimationFinished?.Invoke(this, EventArgs.Empty);
+ }
+
+ private void FrameBroker_TransitionAnimationInitialized()
+ {
+ AnimationInitialized?.Invoke(this, EventArgs.Empty);
+ }
+
+ /// <summary>
+ /// Occurs whenever the window is shown on caller application.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler CallerScreenShown;
+
+ /// <summary>
+ /// Occurs whenever the window is hidden on caller application.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler CallerScreenHidden;
+
+ private void FrameProvider_Shown(object sender, EventArgs e)
+ {
+ Bundle bundle = new Bundle();
+ //Set information of shared object
+ frameProvider?.NotifyShowStatus(bundle);
+
+ CallerScreenShown?.Invoke(this, e);
+ }
+
+ private void FrameProvider_Hidden(object sender, EventArgs e)
+ {
+ Bundle bundle = new Bundle();
+ //Set information of shared object
+ frameProvider?.NotifyHideStatus(bundle);
+
+ CallerScreenHidden?.Invoke(this, e);
+ }
+
+ internal void SendLaunchRequest(AppControl appControl)
+ {
+ this.frameBroker.SendLaunchRequest(appControl, false);
+ }
+ }
+}
--- /dev/null
+using System;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+
+namespace NUISimpleCallee
+{
+ class Program : NUIApplication
+ {
+ protected override void OnCreate()
+ {
+ base.OnCreate();
+ Initialize();
+ }
+
+ void Initialize()
+ {
+ Window.Instance.KeyEvent += OnKeyEvent;
+ Window.Instance.TouchEvent += OnTouchEvent;
+
+ TextLabel text = new TextLabel("Callee");
+ text.HorizontalAlignment = HorizontalAlignment.Center;
+ text.VerticalAlignment = VerticalAlignment.Center;
+ text.TextColor = Color.Red;
+ text.PointSize = 12.0f;
+ text.HeightResizePolicy = ResizePolicyType.FillToParent;
+ text.WidthResizePolicy = ResizePolicyType.FillToParent;
+ Window.Instance.GetDefaultLayer().Add(text);
+
+ TransitionOptions = new TransitionOptions(GetDefaultWindow());
+ TransitionOptions.EnableTransition = true;
+ }
+
+ private void OnTouchEvent(object sender, Window.TouchEventArgs e)
+ {
+ if (e.Touch.GetState(0) == PointStateType.Up)
+ {
+ Window.Instance.Iconify(true);
+ }
+ }
+
+ public void OnKeyEvent(object sender, Window.KeyEventArgs e)
+ {
+ if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
+ {
+ Exit();
+ }
+ }
+
+ static void Main(string[] args)
+ {
+ var app = new Program();
+ app.Run(args);
+ }
+ }
+}
--- /dev/null
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFramework>netcoreapp2.0</TargetFramework>
+ </PropertyGroup>
+
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugType>portable</DebugType>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>None</DebugType>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <Folder Include="lib\" />
+ <Folder Include="res\" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\src\Tizen.NUI\Tizen.NUI.csproj" />
+ <PackageReference Include="Tizen.NET.Sdk" Version="1.0.0" />
+ </ItemGroup>
+
+</Project>
+
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="5" package="org.tizen.example.NUISimpleCallee" version="1.0.0">
+ <profile name="common" />
+ <ui-application appid="org.tizen.example.NUISimpleCallee"
+ exec="NUISimpleCallee.dll"
+ type="dotnet"
+ multiple="false"
+ taskmanage="true"
+ nodisplay="false"
+ launch_mode="single">
+ <label>NUISimpleCallee</label>
+ <icon>NUISimpleCallee.png</icon>
+ <metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
+ </ui-application>
+</manifest>
--- /dev/null
+using System;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.Applications;
+
+namespace NUISimpleCaller
+{
+ class Program : NUIApplication
+ {
+ protected override void OnCreate()
+ {
+ base.OnCreate();
+ Initialize();
+ }
+
+ void Initialize()
+ {
+ Window.Instance.KeyEvent += OnKeyEvent;
+ Window.Instance.TouchEvent += OnTouchEvent;
+
+ TextLabel text = new TextLabel("NUI Simple Caller Sample");
+ text.HorizontalAlignment = HorizontalAlignment.Center;
+ text.VerticalAlignment = VerticalAlignment.Center;
+ text.TextColor = Color.Blue;
+ text.PointSize = 12.0f;
+ text.HeightResizePolicy = ResizePolicyType.FillToParent;
+ text.WidthResizePolicy = ResizePolicyType.FillToParent;
+ Window.Instance.GetDefaultLayer().Add(text);
+
+
+ TransitionOptions = new TransitionOptions(GetDefaultWindow());
+ TransitionOptions.EnableTransition = true;
+ TransitionOptions.ForwardAnimation = new SlideIn(300);
+ TransitionOptions.BackwardAnimation = new SlideOut(300);
+
+ ////TransitionOptions.AnimationStart += TransitionOptions_AnimationStart;
+ ////TransitionOptions.AnimationFinished += TransitionOptions_AnimationFinished;
+ }
+
+ private void TransitionOptions_AnimationFinished()
+ {
+ Tizen.Log.Error("MYLOG", "Finish Animation");
+ }
+
+ private void TransitionOptions_AnimationStart()
+ {
+ Tizen.Log.Error("MYLOG", "Start Animation");
+ }
+
+ private void OnTouchEvent(object sender, Window.TouchEventArgs e)
+ {
+ if (e.Touch.GetState(0) == PointStateType.Up)
+ {
+ AppControl appControl = new AppControl();
+ appControl.ApplicationId = "org.tizen.example.NUISimpleCallee";
+ SendLaunchRequest(appControl, false);
+ }
+ }
+
+ public void OnKeyEvent(object sender, Window.KeyEventArgs e)
+ {
+ if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
+ {
+ Exit();
+ }
+ }
+
+ static void Main(string[] args)
+ {
+ var app = new Program();
+ app.Run(args);
+ }
+ }
+}
--- /dev/null
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFramework>netcoreapp2.0</TargetFramework>
+ </PropertyGroup>
+
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugType>portable</DebugType>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>None</DebugType>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <Folder Include="lib\" />
+ <Folder Include="res\" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\src\Tizen.NUI\Tizen.NUI.csproj" />
+ <PackageReference Include="Tizen.NET.Sdk" Version="1.0.0" />
+ </ItemGroup>
+
+</Project>
+
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<manifest package="org.tizen.example.NUISimpleCaller" version="1.0.0" api-version="5" xmlns="http://tizen.org/ns/packages">
+ <profile name="common" />
+ <ui-application appid="org.tizen.example.NUISimpleCaller" exec="NUISimpleCaller.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single">
+ <label>NUISimpleCaller</label>
+ <icon>NUISimpleCaller.png</icon>
+ <metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
+ <splash-screens />
+ </ui-application>
+ <shortcut-list />
+ <privileges>
+ <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+ </privileges>
+ <dependencies />
+ <provides-appdefined-privileges />
+</manifest>