From: Seungho Baek Date: Fri, 16 Aug 2024 12:55:59 +0000 (+0900) Subject: [NUI.Scene3D] Add Panel in Scene3D X-Git-Tag: submit/tizen/20240821.061804~1^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=445f8957904ce5e8f6db3bdd6ed1d3f1f2317cb9;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI.Scene3D] Add Panel in Scene3D Signed-off-by: Seungho Baek --- diff --git a/src/Tizen.NUI.Scene3D/src/internal/Interop/Interop.Model.cs b/src/Tizen.NUI.Scene3D/src/internal/Interop/Interop.Model.cs index 9786dda33..f336d3412 100755 --- a/src/Tizen.NUI.Scene3D/src/internal/Interop/Interop.Model.cs +++ b/src/Tizen.NUI.Scene3D/src/internal/Interop/Interop.Model.cs @@ -35,9 +35,6 @@ namespace Tizen.NUI.Scene3D [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_delete_Model")] public static extern void DeleteModel(global::System.Runtime.InteropServices.HandleRef model); - [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Model_Assign")] - public static extern global::System.IntPtr ModelAssign(global::System.Runtime.InteropServices.HandleRef model, global::System.Runtime.InteropServices.HandleRef sourceModel); - [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Model_GetModelRoot")] public static extern global::System.IntPtr GetModelRoot(global::System.Runtime.InteropServices.HandleRef model); diff --git a/src/Tizen.NUI.Scene3D/src/internal/Interop/Interop.Panel.cs b/src/Tizen.NUI.Scene3D/src/internal/Interop/Interop.Panel.cs new file mode 100755 index 000000000..f10313781 --- /dev/null +++ b/src/Tizen.NUI.Scene3D/src/internal/Interop/Interop.Panel.cs @@ -0,0 +1,73 @@ +/* + * Copyright(c) 2024 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.Collections.Generic; +using System.Runtime.InteropServices; +namespace Tizen.NUI.Scene3D +{ + internal static partial class Interop + { + internal static partial class Panel + { + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Panel_New_SWIG_0")] + public static extern global::System.IntPtr PanelNew(); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_delete_Panel")] + public static extern void DeletePanel(global::System.Runtime.InteropServices.HandleRef panel); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Panel_SetPanelResolution")] + public static extern void SetPanelResolution(global::System.Runtime.InteropServices.HandleRef panel, global::System.Runtime.InteropServices.HandleRef resolution); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Panel_GetPanelResolution")] + public static extern global::System.IntPtr GetPanelResolution(global::System.Runtime.InteropServices.HandleRef panel); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Panel_SetContent")] + public static extern void SetContent(global::System.Runtime.InteropServices.HandleRef panel, global::System.Runtime.InteropServices.HandleRef resolution); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Panel_GetContent")] + public static extern global::System.IntPtr GetContent(global::System.Runtime.InteropServices.HandleRef panel); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Panel_CastShadow")] + public static extern void CastShadow(global::System.Runtime.InteropServices.HandleRef panel, bool castShadow); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Panel_IsShadowCasting")] + [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)] + public static extern bool IsShadowCasting(global::System.Runtime.InteropServices.HandleRef panel); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Panel_ReceiveShadow")] + public static extern void ReceiveShadow(global::System.Runtime.InteropServices.HandleRef panel, bool receiveShadow); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Panel_IsShadowReceiving")] + [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)] + public static extern bool IsShadowReceiving(global::System.Runtime.InteropServices.HandleRef panel); + + + // For Property index + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Panel_property_TRANSPARENT_get")] + public static extern int PropertyTransparentIndexGet(); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Panel_property_DOUBLE_SIDED_get")] + public static extern int PropertyDoubleSidedIndexGet(); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Panel_property_USE_BACK_FACE_PLANE_get")] + public static extern int PropertyUseBackFacePlaneIndexGet(); + + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Panel_property_BACK_FACE_PLANE_COLOR_get")] + public static extern int PropertyBackFacePlaneColorIndexGet(); + } + } +} diff --git a/src/Tizen.NUI.Scene3D/src/public/Controls/Model.cs b/src/Tizen.NUI.Scene3D/src/public/Controls/Model.cs index 18cbf0524..e5e845c42 100755 --- a/src/Tizen.NUI.Scene3D/src/public/Controls/Model.cs +++ b/src/Tizen.NUI.Scene3D/src/public/Controls/Model.cs @@ -128,19 +128,6 @@ namespace Tizen.NUI.Scene3D this.PositionUsesPivotPoint = model.PositionUsesPivotPoint; } - /// - /// Assignment operator. - /// - /// Source object to be assigned. - /// Reference to this. - internal Model Assign(Model model) - { - Model ret = new Model(Interop.Model.ModelAssign(SwigCPtr, Model.getCPtr(model)), false); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - ret.PositionUsesPivotPoint = model.PositionUsesPivotPoint; - return ret; - } - /// /// Get The original pivot point of the model /// @@ -188,6 +175,44 @@ namespace Tizen.NUI.Scene3D } } + /// + /// Whether this Model casts shadow or not by directional light. + /// If it is true, this Model is drawn on Shadow Map. + /// Default value is true. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public bool ShadowCast + { + get + { + return IsShadowCasting(); + } + set + { + CastShadow(value); + } + } + + /// + /// Whether this Model receives shadow or not by directional light. + /// If it is true, shadows are drawn on this Model. + /// Default value is true. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public bool ShadowReceive + { + get + { + return IsShadowReceiving(); + } + set + { + ReceiveShadow(value); + } + } + /// /// Adds modelNode to this Model. /// @@ -601,9 +626,7 @@ namespace Tizen.NUI.Scene3D /// However, same property of each child ModelNode can be changed respectively and it not changes parent's property. /// /// Whether this Model casts shadow or not. - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - public void CastShadow(bool castShadow) + private void CastShadow(bool castShadow) { Interop.Model.CastShadow(SwigCPtr, castShadow); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); @@ -614,9 +637,7 @@ namespace Tizen.NUI.Scene3D /// Note: IBL does not cast any shadow. /// /// True if this model casts shadow. - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - public bool IsShadowCasting() + private bool IsShadowCasting() { var isShadowCasting = Interop.Model.IsShadowCasting(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); @@ -630,9 +651,7 @@ namespace Tizen.NUI.Scene3D /// However, same property of each child ModelNode can be changed respectively and it not changes parent's property. /// /// Whether this Model receives shadow or not. - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - public void ReceiveShadow(bool receiveShadow) + private void ReceiveShadow(bool receiveShadow) { Interop.Model.ReceiveShadow(SwigCPtr, receiveShadow); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); @@ -643,9 +662,7 @@ namespace Tizen.NUI.Scene3D /// If it is true, this model is drawn on Shadow Map. /// /// True if this model receives shadow. - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - public bool IsShadowReceiving() + private bool IsShadowReceiving() { var isShadowReceiving = Interop.Model.IsShadowReceiving(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); @@ -656,8 +673,6 @@ namespace Tizen.NUI.Scene3D /// Retrieves model root Actor. /// /// Root View of the model. - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] private ModelNode GetModelRoot() { global::System.IntPtr cPtr = Interop.Model.GetModelRoot(SwigCPtr); diff --git a/src/Tizen.NUI.Scene3D/src/public/Controls/Panel.cs b/src/Tizen.NUI.Scene3D/src/public/Controls/Panel.cs new file mode 100755 index 000000000..36059df18 --- /dev/null +++ b/src/Tizen.NUI.Scene3D/src/public/Controls/Panel.cs @@ -0,0 +1,379 @@ +/* + * Copyright(c) 2024 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.Collections.Generic; +using System.Runtime.InteropServices; +using System.ComponentModel; +using Tizen.NUI; +using Tizen.NUI.Binding; +using Tizen.NUI.BaseComponents; + +namespace Tizen.NUI.Scene3D +{ + /// + /// Panel is a control to show 2D UI on 3D Scene. + /// 2D UI contents set on this Panel are rendered on a screen panel that is placed on 3D scene. + /// Each Panel has a single plane with defined resolution. + /// The plane is always placed at center to fit within the boundaries of the panel while maintaining the aspect ratio of the resolution. + /// + /// + /// + /// 2D UI Content can be added on Panel, but the result that another 3D SceneView is added on Panel is not guaranteed. + /// + /// + /// + /// + /// View contentRoot = CreateUIContent(); // Create 2D UI Scene + /// Panel panel = new Panel() + /// { + /// Size = new Size(width, height), + /// }; + /// panel.PanelResolution = new Vector2(resolutionWidth, resolutionHeight)); + /// panel.Content = contentRoot; + /// + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public partial class Panel : View + { + internal Panel(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn) + { + } + + internal Panel(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, true, cRegister) + { + } + + /// + /// Create an initialized Panel. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public Panel() : this(Interop.Panel.PanelNew(), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + this.PositionUsesPivotPoint = true; + } + + /// + /// Resolution of the Panel. + /// The resolution is independent from the Panel size property. + /// The resolution defines a plane that the 2D UI scene will be rendered. + /// And the shape of the panel plane is defined by aspect ratio of the input resolution. + /// The plane is cleared by white color. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public Vector2 PanelResolution + { + get + { + return GetPanelResolution(); + } + set + { + SetPanelResolution(value); + } + } + + /// + /// Root View of 2D UI content. + /// The content is rendered on the plane of the Panel by using off screen rendering. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public View Content + { + get + { + return GetContent(); + } + set + { + SetContent(value); + } + } + + /// + /// Whether Transparent background is used or not. Default value is false + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Transparent + { + get + { + bool transparent = false; + using var pValue = GetProperty(Interop.Panel.PropertyTransparentIndexGet()); + pValue?.Get(out transparent); + pValue?.Dispose(); + return transparent; + } + set + { + using var transparent = new Tizen.NUI.PropertyValue(value); + SetProperty(Interop.Panel.PropertyTransparentIndexGet(), transparent); + transparent.Dispose(); + } + } + + /// + /// Whether the content is rendered as double sided or not. + /// Default value is false. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public bool DoubleSided + { + get + { + bool doubleSided = false; + using var pValue = GetProperty(Interop.Panel.PropertyDoubleSidedIndexGet()); + pValue?.Get(out doubleSided); + pValue?.Dispose(); + return doubleSided; + } + set + { + using var doubleSided = new Tizen.NUI.PropertyValue(value); + SetProperty(Interop.Panel.PropertyDoubleSidedIndexGet(), doubleSided); + doubleSided.Dispose(); + } + } + + /// + /// Whether to use back face plane or not. + /// If this property is true, an opaque plane will be displayed when viewed from behind the Panel. + /// Default value is true. + /// Default back face plane color is white. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public bool UsingBackFacePlane + { + get + { + bool isUsingBackFacePlane = true; + using var pValue = GetProperty(Interop.Panel.PropertyUseBackFacePlaneIndexGet()); + pValue?.Get(out isUsingBackFacePlane); + pValue?.Dispose(); + return isUsingBackFacePlane; + } + set + { + using var isUsingBackFacePlane = new Tizen.NUI.PropertyValue(value); + SetProperty(Interop.Panel.PropertyUseBackFacePlaneIndexGet(), isUsingBackFacePlane); + isUsingBackFacePlane.Dispose(); + } + } + + /// + /// Color of back face plane. + /// Default color is white. + /// + /// + /// Because back face plane is always opaque, alpha channel is ignored. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public Color BackFacePlaneColor + { + get + { + Vector3 backFacePlaneColorVector3 = new Vector3(1.0f, 1.0f, 1.0f); + using var pValue = GetProperty(Interop.Panel.PropertyBackFacePlaneColorIndexGet()); + pValue?.Get(backFacePlaneColorVector3); + pValue?.Dispose(); + Color backFacePlaneColor = new Vector4(backFacePlaneColorVector3); + backFacePlaneColor.A = 1.0f; + return backFacePlaneColor; + } + set + { + Vector3 backFacePlaneColorVector3 = new Vector3(value.R, value.G, value.B); + using var backFacePlaneColor = new Tizen.NUI.PropertyValue(backFacePlaneColorVector3); + SetProperty(Interop.Panel.PropertyBackFacePlaneColorIndexGet(), backFacePlaneColor); + backFacePlaneColor.Dispose(); + } + } + + /// + /// Whether this Panel casts shadow or not by directional light. + /// If it is true, this panel is drawn on Shadow Map. + /// Default value is true. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public bool ShadowCast + { + get + { + return IsShadowCasting(); + } + set + { + CastShadow(value); + } + } + + /// + /// Whether this Panel receives shadow or not by directional light. + /// If it is true, shadows are drawn on this panel. + /// Default value is true. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public bool ShadowReceive + { + get + { + return IsShadowReceiving(); + } + set + { + ReceiveShadow(value); + } + } + + /// + /// Sets whether this Panel casts shadow or not. + /// If it is true, this panels is drawn on Shadow Map. + /// + /// Whether this Panel casts shadow or not. + private void CastShadow(bool castShadow) + { + Interop.Panel.CastShadow(SwigCPtr, castShadow); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Retrieves whether the Panel casts shadow or not for Light. + /// Note: IBL does not cast any shadow. + /// + /// True if this model casts shadow. + private bool IsShadowCasting() + { + var isShadowCasting = Interop.Panel.IsShadowCasting(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return isShadowCasting; + } + + /// + /// Sets whether this Panel receives shadow or not. + /// If it is true, shadows are drawn on this panel. + /// + /// Whether this Panel receives shadow or not. + private void ReceiveShadow(bool receiveShadow) + { + Interop.Panel.ReceiveShadow(SwigCPtr, receiveShadow); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Retrieves whether the Panel receives shadow or not for Light + /// If it is true, this model is drawn on Shadow Map. + /// + /// True if this model receives shadow. + private bool IsShadowReceiving() + { + var isShadowReceiving = Interop.Panel.IsShadowReceiving(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return isShadowReceiving; + } + + /// + /// Sets defined resolution to the Panel. + /// The resolution is independent from the Panel size property. + /// The resolution defines a plane that the 2D UI scene will be rendered. + /// And the shape of the panel plane is defined by aspect ratio of the input resolution. + /// + /// The resolution defines panel plane. + /// True if this model receives shadow. + private void SetPanelResolution(Vector2 resolution) + { + Interop.Panel.SetPanelResolution(SwigCPtr, Vector2.getCPtr(resolution)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Retrieves panel resolution. + /// + /// Resolution of the panel plane. + private Vector2 GetPanelResolution() + { + Vector2 resolution = new Vector2(Interop.Panel.GetPanelResolution(SwigCPtr), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return resolution; + } + + /// + /// Sets root Actor of 2D UI content. + /// The content is rendered on the plane of the Panel by using off screen rendering. + /// + /// Root View of 2D UI content. + private void SetContent(View content) + { + Interop.Panel.SetContent(SwigCPtr, content.SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Retrieves root View of 2D UI content. + /// + /// Root View of 2D UI content. + private View GetContent() + { + IntPtr cPtr = Interop.Panel.GetContent(SwigCPtr); + View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View; + if (ret != null) + { + NUI.Interop.BaseHandle.DeleteBaseHandle(new HandleRef(this, cPtr)); + } + else + { + ret = new View(cPtr, true); + } + NDalicPINVOKE.ThrowExceptionIfExists(); + return ret; + } + + /// + /// To make transitionSet instance be disposed. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void Dispose(DisposeTypes type) + { + if (disposed) + { + return; + } + base.Dispose(type); + } + + /// + /// Release swigCPtr. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void ReleaseSwigCPtr(global::System.Runtime.InteropServices.HandleRef swigCPtr) + { + Interop.Panel.DeletePanel(swigCPtr); + } + } +} diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/Scene3DPanelTest.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/Scene3DPanelTest.cs new file mode 100755 index 000000000..ce7bb8b58 --- /dev/null +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/Scene3DPanelTest.cs @@ -0,0 +1,138 @@ +using System.Numerics; +using System.Reflection.Metadata.Ecma335; +using global::System; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Scene3D; + +namespace Tizen.NUI.Samples +{ + using log = Tizen.Log; + public class Scene3DPanelTest : IExample + { + private Window window; + private SceneView sceneView; + private static readonly string resourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource; + private Color[] backFaceColors; + private int colorIndex; + private Animation animation; + private Panel panel; + private TextLabel guideText; + public void Activate() + { + window = NUIApplication.GetDefaultWindow(); + window.BackgroundColor = Color.White; + Size2D windowSize = window.Size; + + backFaceColors = new Color[3]; + backFaceColors[0] = Color.Red; + backFaceColors[1] = Color.Green; + backFaceColors[2] = Color.Blue; + + colorIndex = 0; + + sceneView = new SceneView() + { + Size = new Size(windowSize.Width, windowSize.Height), + PivotPoint = PivotPoint.Center, + ParentOrigin = ParentOrigin.Center, + PositionUsesPivotPoint = true, + BackgroundColor = Color.Beige, + UseFramebuffer = true, + }; + window.Add(sceneView); + + View parent = new View() + { + BackgroundColor = Color.Blue, + PivotPoint = PivotPoint.Center, + ParentOrigin = ParentOrigin.Center, + PositionUsesPivotPoint = true, + Size = new Size(100, 100), + }; + + View child = new View() + { + BackgroundColor = Color.Red, + PivotPoint = PivotPoint.Center, + ParentOrigin = ParentOrigin.Center, + PositionUsesPivotPoint = true, + Size = new Size(100, 100), + Position = new Position(25, 100), + }; + parent.Add(child); + + panel = new Panel() + { + Position = new Position(0.0f, 0.0f, 0.5f), + Size = new Size(2.0f, 1.0f), + PanelResolution = new Vector2(400, 500), + Content = parent, + BackFacePlaneColor = backFaceColors[colorIndex], + }; + sceneView.Add(panel); + + SetGuide(); + + animation = new Animation(15000); + animation.AnimateTo(panel, "orientation", new Rotation(new Radian(new Degree(180.0f)), Vector3.YAxis)); + animation.AnimateTo(panel, "size", new Vector3(1.0f, 2.0f, 0.0f)); + animation.Looping = true; + animation.LoopingMode = Animation.LoopingModes.AutoReverse; + animation.Play(); + + window.KeyEvent += WindowKeyEvent; + } + + void SetGuide() + { + if(guideText == null) + { + guideText = new TextLabel() + { + PositionUsesPivotPoint = true, + PivotPoint = PivotPoint.BottomLeft, + ParentOrigin = ParentOrigin.BottomLeft, + PointSize = 30.0f, + MultiLine = true, + }; + } + window.Add(guideText); + + string backFaceColor = string.Format($"({panel.BackFacePlaneColor.R}, {panel.BackFacePlaneColor.G}, {panel.BackFacePlaneColor.B})"); + string guide = string.Format($"Press 1 to convert transparency - Current value : {panel.Transparent}\nPress 2 to convert double sided - Current value : {panel.DoubleSided}\nPress 3 to convert back face - Current value : {panel.UsingBackFacePlane}\nPress 4 to convert back face color - Current value : {backFaceColor}\n"); + guideText.Text = guide; + } + + private void WindowKeyEvent(object sender, Window.KeyEventArgs e) + { + if (e.Key.State == Key.StateType.Down) + { + if (e.Key.KeyPressedName == "1") + { + panel.Transparent = !panel.Transparent; + } + else if (e.Key.KeyPressedName == "2") + { + panel.DoubleSided = !panel.DoubleSided; + } + else if (e.Key.KeyPressedName == "3") + { + panel.UsingBackFacePlane = !panel.UsingBackFacePlane; + } + else if (e.Key.KeyPressedName == "4") + { + colorIndex = ((colorIndex + 1) % 3); + panel.BackFacePlaneColor = backFaceColors[colorIndex]; + } + SetGuide(); + } + } + + public void Deactivate() + { + window.KeyEvent -= WindowKeyEvent; + sceneView?.DisposeRecursively(); + } + } +}