/* * Copyright(c) 2020 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. * */ extern alias TizenSystemInformation; using TizenSystemInformation.Tizen.System; using global::System; using System.ComponentModel; using System.Collections.Generic; using global::System.Runtime.InteropServices; using Tizen.NUI.BaseComponents; namespace Tizen.NUI { /// /// The GLWindow class is to draw with native GLES.
/// This class is the special window. It is for native GLES application.
/// So, some special funtions and type are supported.
/// In addition, basic window's functions are supported, too.
///
[EditorBrowsable(EditorBrowsableState.Never)] public partial class GLWindow : BaseHandle { internal GLWindow(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.GLWindow.GlWindow_SWIGUpcast(cPtr), cMemoryOwn) { } /// /// Creates an initialized handle to a new GLWindow.
/// This creates an GLWindow with default options.!--
///
/// A new GLWindow. [EditorBrowsable(EditorBrowsableState.Never)] public GLWindow() : this(Interop.GLWindow.GlWindow_New__SWIG_0(), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Creates an initialized handle to a new GLWindow.
/// This API can create GLWindow with specifc option.
///
/// The name for GL window. /// The position and size of the Window. /// Whether Window is translucent. /// A new Window. [EditorBrowsable(EditorBrowsableState.Never)] public GLWindow(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.GLWindow.GlWindow_New__SWIG_1( Rectangle.getCPtr(windowPosition), name, "", isTranslucent), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing. /// [EditorBrowsable(EditorBrowsableState.Never)] public enum GLWindowOrientation { /// /// Portrait orientation. The height of the display area is greater than the width. /// [EditorBrowsable(EditorBrowsableState.Never)] Portrait = 0, /// /// Landscape orientation. A wide view area is needed. /// [EditorBrowsable(EditorBrowsableState.Never)] Landscape = 1, /// /// Portrait inverse orientation. /// [EditorBrowsable(EditorBrowsableState.Never)] PortraitInverse = 2, /// /// Landscape inverse orientation. /// [EditorBrowsable(EditorBrowsableState.Never)] LandscapeInverse = 3, /// /// No orientation. It is for the preferred orientation /// Especially, NoOrientationPreference only has the effect for the preferred orientation. /// It is used to unset the preferred orientation with SetPreferredOrientation. /// [EditorBrowsable(EditorBrowsableState.Never)] NoOrientationPreference = -1 } /// /// Gets or sets a size of the window. /// [EditorBrowsable(EditorBrowsableState.Never)] public Size2D WindowSize { get { var val = new Rectangle(Interop.GLWindow.GlWindow_GetPositionSize(swigCPtr), true); Size2D ret = new Size2D(val.Width, val.Height); return ret; } set { var val = new Rectangle(Interop.GLWindow.GlWindow_GetPositionSize(swigCPtr), true); Rectangle ret = new Rectangle(val.X, val.Y, value.Width, value.Height ); Interop.GLWindow.GlWindow_SetPositionSize(swigCPtr, Rectangle.getCPtr(ret)); } } /// /// This Enumeration is used the GLES version for EGL configuration.
/// If the device can not support GLES version 3.0 over, the version will be chosen with GLES version 2.0
///
[EditorBrowsable(EditorBrowsableState.Never)] public enum GLESVersion { /// /// GLES version 2.0 /// [EditorBrowsable(EditorBrowsableState.Never)] Version_2_0 = 0, /// /// GLES version 3.0 /// [EditorBrowsable(EditorBrowsableState.Never)] Version_3_0 } /// /// Sets egl configuration for GLWindow /// /// The flag of depth buffer. If true is set, 24bit depth buffer is enabled. /// The flag of stencil. it true is set, 8bit stencil buffer is enabled. /// The bit of msaa. /// The GLES version. [EditorBrowsable(EditorBrowsableState.Never)] public void SetEglConfig( bool depth, bool stencil, int msaa, GLESVersion version ) { Interop.GLWindow.GlWindow_SetEglConfig(swigCPtr, depth, stencil, msaa, (int)version); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Shows the GLWindow if it is hidden. /// [EditorBrowsable(EditorBrowsableState.Never)] public void Show() { Interop.GLWindow.GlWindow_Show(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Hides the GLWindow if it is showing. /// [EditorBrowsable(EditorBrowsableState.Never)] public void Hide() { Interop.GLWindow.GlWindow_Hide(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Raises the window to the top of the window stack. /// [EditorBrowsable(EditorBrowsableState.Never)] public void Raise() { Interop.GLWindow.GlWindow_Raise(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Lowers the window to the bottom of the window stack. /// [EditorBrowsable(EditorBrowsableState.Never)] public void Lower() { Interop.GLWindow.GlWindow_Lower(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Activates the window to the top of the window stack even it is iconified. /// [EditorBrowsable(EditorBrowsableState.Never)] public void Activate() { Interop.GLWindow.GlWindow_Activate(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Sets position and size of the window. This API guarantees that /// both moving and resizing of window will appear on the screen at once. /// [EditorBrowsable(EditorBrowsableState.Never)] public Rectangle WindowPositionSize { get { Rectangle val = new Rectangle(Interop.GLWindow.GlWindow_GetPositionSize(swigCPtr), true); Rectangle ret = new Rectangle(val.X, val.Y, val.Width, val.Height ); return ret; } set { Interop.GLWindow.GlWindow_SetPositionSize(swigCPtr, Rectangle.getCPtr(value)); } } /// /// Gets the count of supported auxiliary hints of the GLWindow. /// /// The number of supported auxiliary hints. [EditorBrowsable(EditorBrowsableState.Never)] public uint GetSupportedAuxiliaryHintCount() { uint ret = Interop.GLWindow.GlWindow_GetSupportedAuxiliaryHintCount(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Gets the supported auxiliary hint string of the GLWindow. /// /// The index of the supported auxiliary hint lists. /// The auxiliary hint string of the index. [EditorBrowsable(EditorBrowsableState.Never)] public string GetSupportedAuxiliaryHint(uint index) { string ret = Interop.GLWindow.GlWindow_GetSupportedAuxiliaryHint(swigCPtr, index); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Creates an auxiliary hint of the GLWindow. /// /// The auxiliary hint string. /// The value string. /// The ID of created auxiliary hint, or 0 on failure. [EditorBrowsable(EditorBrowsableState.Never)] public uint AddAuxiliaryHint(string hint, string value) { uint ret = Interop.GLWindow.GlWindow_AddAuxiliaryHint(swigCPtr, hint, value); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Removes an auxiliary hint of the GLWindow. /// /// The ID of the auxiliary hint. /// True if no error occurred, false otherwise. [EditorBrowsable(EditorBrowsableState.Never)] public bool RemoveAuxiliaryHint(uint id) { bool ret = Interop.GLWindow.GlWindow_RemoveAuxiliaryHint(swigCPtr, id); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Changes a value of the auxiliary hint. /// /// The auxiliary hint ID. /// The value string to be set. /// True if no error occurred, false otherwise. [EditorBrowsable(EditorBrowsableState.Never)] public bool SetAuxiliaryHintValue(uint id, string value) { bool ret = Interop.GLWindow.GlWindow_SetAuxiliaryHintValue(swigCPtr, id, value); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Gets a value of the auxiliary hint. /// /// The auxiliary hint ID. /// The string value of the auxiliary hint ID, or an empty string if none exists. [EditorBrowsable(EditorBrowsableState.Never)] public string GetAuxiliaryHintValue(uint id) { string ret = Interop.GLWindow.GlWindow_GetAuxiliaryHintValue(swigCPtr, id); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Gets an ID of the auxiliary hint string. /// /// The auxiliary hint string. /// The ID of auxiliary hint string, or 0 on failure. [EditorBrowsable(EditorBrowsableState.Never)] public uint GetAuxiliaryHintId(string hint) { uint ret = Interop.GLWindow.GlWindow_GetAuxiliaryHintId(swigCPtr, hint); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Sets a region to accept input events. /// /// The region to accept input events. [EditorBrowsable(EditorBrowsableState.Never)] public void SetInputRegion(Rectangle inputRegion) { Interop.GLWindow.GlWindow_SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Sets a transparent window's visual state to opaque.
/// If a visual state of a transparent window is opaque,
/// then the window manager could handle it as an opaque window when calculating visibility. ///
/// Whether the window's visual state is opaque. /// This will have no effect on an opaque window.
/// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window. ///
[EditorBrowsable(EditorBrowsableState.Never)] public void SetOpaqueState(bool opaque) { Interop.GLWindow.GlWindow_SetOpaqueState(swigCPtr, opaque); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Returns whether a transparent window's visual state is opaque or not. /// /// True if the window's visual state is opaque, false otherwise. /// The return value has no meaning on an opaque window. [EditorBrowsable(EditorBrowsableState.Never)] public bool IsOpaqueState() { bool ret = Interop.GLWindow.GlWindow_IsOpaqueState(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Sets a preferred orientation. /// /// The preferred orientation. [EditorBrowsable(EditorBrowsableState.Never)] public void SetPreferredOrientation(GLWindow.GLWindowOrientation orientation) { Interop.GLWindow.GlWindow_SetPreferredOrientation(swigCPtr, (int)orientation); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Gets current orientation of the window. /// /// The current window orientation if previously set, or none. [EditorBrowsable(EditorBrowsableState.Never)] public GLWindow.GLWindowOrientation GetCurrentOrientation() { GLWindow.GLWindowOrientation ret = (GLWindow.GLWindowOrientation)Interop.GLWindow.GlWindow_GetCurrentOrientation(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Sets available orientations of the window. /// This API is for setting several orientations one time. /// /// The list of orientations. [EditorBrowsable(EditorBrowsableState.Never)] public void SetAvailableOrientations(List orientations) { PropertyArray orientationArray = new PropertyArray(); for (int i = 0; i < orientations.Count; i++) { orientationArray.PushBack(new PropertyValue((int)orientations[i])); } Interop.GLWindow.GlWindow_SetAvailableOrientations(swigCPtr, PropertyArray.getCPtr(orientationArray), orientations.Count); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Allows at least one more render, even when paused. /// The window should be shown, not minimised. /// [EditorBrowsable(EditorBrowsableState.Never)] public void RenderOnce() { Interop.GLWindow.GlWindow_RenderOnce(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Type of callback to initialize native GL code. /// [EditorBrowsable(EditorBrowsableState.Never)] public delegate void GLInitializeCallbackType(); GLInitializeCallbackType GLInitializeCallback; HandleRef InitHandleRef; /// /// Type of callback to render to frame to use native GL code. /// [EditorBrowsable(EditorBrowsableState.Never)] public delegate void GLRenderFrameCallbackType(); GLRenderFrameCallbackType GLRenderFrameCallback; HandleRef RenderHandlerRef; /// /// Type of callback to cleanup native GL resource. /// [EditorBrowsable(EditorBrowsableState.Never)] public delegate void GLTerminateCallbackType(); GLTerminateCallbackType GLTerminateCallback; HandleRef TerminateHandlerRef; /// /// Registers a GL callback function for application. /// /// The callback function for application initialize /// The callback function to render to the frame /// The callback function to clean-up application GL resource [EditorBrowsable(EditorBrowsableState.Never)] public void RegisterGlCallback( GLInitializeCallbackType glInit, GLRenderFrameCallbackType glRenderFrame, GLTerminateCallbackType glTerminate ) { GLInitializeCallback = glInit; InitHandleRef = new HandleRef(this, Marshal.GetFunctionPointerForDelegate(GLInitializeCallback)); GLRenderFrameCallback = glRenderFrame; RenderHandlerRef = new HandleRef(this, Marshal.GetFunctionPointerForDelegate(GLRenderFrameCallback)); GLTerminateCallback = glTerminate; TerminateHandlerRef = new HandleRef(this, Marshal.GetFunctionPointerForDelegate(GLTerminateCallback)); Interop.GLWindow.GlWindow_RegisterGlCallback(swigCPtr, InitHandleRef, RenderHandlerRef, TerminateHandlerRef); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Destroy the window immediately. /// [EditorBrowsable(EditorBrowsableState.Never)] public void Destroy() { this.Dispose(); } /// /// Dispose for Window /// protected override void Dispose(DisposeTypes type) { if (disposed) { return; } this.DisconnectNativeSignals(); base.Dispose(type); } /// This will not be public opened. protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) { Interop.Window.delete_Window(swigCPtr); } } }