/*
* Copyright(c) 2019 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.ComponentModel;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Tizen.NUI.BaseComponents;
namespace Tizen.NUI
{
///
/// The window class is used internally for drawing.
/// The window has an orientation and indicator properties.
///
/// 3
public partial class Window : BaseHandle
{
private static readonly Window instance = Application.Instance?.GetWindow();
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
private global::System.Runtime.InteropServices.HandleRef stageCPtr;
private Layer _rootLayer;
private string _windowTitle;
private List _childLayers = new List();
private LayoutController localController;
internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Window.Window_SWIGUpcast(cPtr), cMemoryOwn)
{
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
if (Interop.Stage.Stage_IsInstalled())
{
stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.Stage_GetCurrent());
localController = new LayoutController(this);
NUILog.Debug("layoutController id:" + localController.GetId() );
}
}
///
/// Creates a new Window.
/// This creates an extra window in addition to the default main window
///
/// The position and size of the Window.
/// Whether Window is translucent.
/// A new Window.
/// 6
public Window(Rectangle windowPosition = null , bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates a new Window with a specific name.
/// This creates an extra window in addition to the default main window
///
/// The name for extra window.
/// The position and size of the Window.
/// Whether Window is translucent.
/// A new Window.
/// 6
public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
{
this._windowTitle = name;
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.
///
/// 3
public enum WindowOrientation
{
///
/// Portrait orientation. The height of the display area is greater than the width.
///
/// 3
Portrait = 0,
///
/// Landscape orientation. A wide view area is needed.
///
/// 3
Landscape = 90,
///
/// Portrait inverse orientation.
///
/// 3
PortraitInverse = 180,
///
/// Landscape inverse orientation.
///
/// 3
LandscapeInverse = 270,
///
/// 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
}
///
/// Enumeration for the key grab mode for platform-level APIs.
///
/// 3
public enum KeyGrabMode
{
///
/// Grabs a key only when on the top of the grabbing-window stack mode.
///
Topmost = 0,
///
/// Grabs a key together with the other client window(s) mode.
///
Shared,
///
/// Grabs a key exclusively regardless of the grabbing-window's position on the window stack with the possibility of overriding the grab by the other client window mode.
///
OverrideExclusive,
///
/// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
///
Exclusive
};
///
/// Enumeration for transition effect's state.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public enum EffectStates
{
///
/// None state.
///
[EditorBrowsable(EditorBrowsableState.Never)]
None = 0,
///
/// Transition effect is started.
///
[EditorBrowsable(EditorBrowsableState.Never)]
Start,
///
/// Transition effect is ended.
///
[EditorBrowsable(EditorBrowsableState.Never)]
End,
}
///
/// Enumeration for transition effect's type.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public enum EffectTypes
{
///
/// None type.
///
[EditorBrowsable(EditorBrowsableState.Never)]
None = 0,
///
/// Window show effect.
///
[EditorBrowsable(EditorBrowsableState.Never)]
Show,
///
/// Window hide effect.
///
[EditorBrowsable(EditorBrowsableState.Never)]
Hide,
}
///
/// Enumeration for opacity of the indicator.
///
internal enum IndicatorBackgroundOpacity
{
Opaque = 100,
Translucent = 50,
Transparent = 0
}
///
/// Enumeration for visible mode of the indicator.
///
internal enum IndicatorVisibleMode
{
Invisible = 0,
Visible = 1,
Auto = 2
}
///
/// The stage instance property (read-only).
/// Gets the current window.
///
/// 3
public static Window Instance
{
get
{
return instance;
}
}
///
/// Get Resource ID of window
///
internal int ResourceID
{
get
{
int ret = Interop.Window.GetResouceID(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// Gets or sets a window type.
///
/// 3
public WindowType Type
{
get
{
WindowType ret = (WindowType)Interop.Window.GetType(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
set
{
Interop.Window.SetType(swigCPtr, (int)value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
}
///
/// Gets/Sets a window title.
///
/// 4
public string Title
{
get
{
return _windowTitle;
}
set
{
_windowTitle = value;
SetClass(_windowTitle, "");
}
}
///
/// The rendering behavior of a Window.
///
/// 5
public RenderingBehaviorType RenderingBehavior
{
get
{
return GetRenderingBehavior();
}
set
{
SetRenderingBehavior(value);
}
}
///
/// The window size property (read-only).
///
/// 3
public Size2D Size
{
get
{
Size2D ret = GetSize();
return ret;
}
}
///
/// The background color property.
///
/// 3
public Color BackgroundColor
{
set
{
SetBackgroundColor(value);
}
get
{
Color ret = GetBackgroundColor();
return ret;
}
}
///
/// The DPI property (read-only).
/// Retrieves the DPI of the display device to which the Window is connected.
///
/// 3
public Vector2 Dpi
{
get
{
return GetDpi();
}
}
///
/// The layer count property (read-only).
/// Queries the number of on-Window layers.
///
/// 3
public uint LayerCount
{
get
{
return GetLayerCount();
}
}
///
/// Gets or sets a size of the window.
///
/// 4
public Size2D WindowSize
{
get
{
return GetWindowSize();
}
set
{
SetWindowSize(value);
}
}
///
/// Gets or sets a position of the window.
///
/// 4
public Position2D WindowPosition
{
get
{
return GetPosition();
}
set
{
SetPosition(value);
}
}
///
/// 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
{
Position2D position = GetPosition();
Size2D size = GetSize();
Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
return ret;
}
set
{
SetPositionSize(value);
}
}
internal static Vector4 DEFAULT_BACKGROUND_COLOR
{
get
{
global::System.IntPtr cPtr = Interop.Stage.Stage_DEFAULT_BACKGROUND_COLOR_get();
Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
internal static Vector4 DEBUG_BACKGROUND_COLOR
{
get
{
global::System.IntPtr cPtr = Interop.Stage.Stage_DEBUG_BACKGROUND_COLOR_get();
Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
internal List LayersChildren
{
get
{
return _childLayers;
}
}
///
/// Get the LayoutController for this Window.
///
internal LayoutController LayoutController
{
get
{
return localController;
}
}
///
/// Feed a key-event into the window.
///
/// The key event to feed.
/// 4
[Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
public static void FeedKeyEvent(Key keyEvent)
{
Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Sets whether the window accepts a focus or not.
///
/// If a focus is accepted or not. The default is true.
/// 3
public void SetAcceptFocus(bool accept)
{
Interop.Window.SetAcceptFocus(swigCPtr, accept);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Returns whether the window accepts a focus or not.
///
/// True if the window accepts a focus, false otherwise.
/// 3
public bool IsFocusAcceptable()
{
bool ret = Interop.Window.IsFocusAcceptable(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Shows the window if it is hidden.
///
/// 3
public void Show()
{
Interop.Window.Show(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Hides the window if it is showing.
///
/// 3
public void Hide()
{
Interop.Window.Hide(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Retrieves whether the window is visible or not.
///
/// True if the window is visible.
/// 3
public bool IsVisible()
{
bool temp = Interop.Window.IsVisible(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return temp;
}
///
/// Gets the count of supported auxiliary hints of the window.
///
/// The number of supported auxiliary hints.
/// 3
public uint GetSupportedAuxiliaryHintCount()
{
uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Gets the supported auxiliary hint string of the window.
///
/// The index of the supported auxiliary hint lists.
/// The auxiliary hint string of the index.
/// 3
public string GetSupportedAuxiliaryHint(uint index)
{
string ret = Interop.Window.GetSupportedAuxiliaryHint(swigCPtr, index);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Creates an auxiliary hint of the window.
///
/// The auxiliary hint string.
/// The value string.
/// The ID of created auxiliary hint, or 0 on failure.
/// 3
public uint AddAuxiliaryHint(string hint, string value)
{
uint ret = Interop.Window.AddAuxiliaryHint(swigCPtr, hint, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Removes an auxiliary hint of the window.
///
/// The ID of the auxiliary hint.
/// True if no error occurred, false otherwise.
/// 3
public bool RemoveAuxiliaryHint(uint id)
{
bool ret = Interop.Window.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.
/// 3
public bool SetAuxiliaryHintValue(uint id, string value)
{
bool ret = Interop.Window.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.
/// 3
public string GetAuxiliaryHintValue(uint id)
{
string ret = Interop.Window.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.
/// 3
public uint GetAuxiliaryHintId(string hint)
{
uint ret = Interop.Window.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.
/// 3
public void SetInputRegion(Rectangle inputRegion)
{
Interop.Window.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Sets a priority level for the specified notification window.
///
/// The notification window level.
/// True if no error occurred, false otherwise.
/// 3
public bool SetNotificationLevel(NotificationLevel level)
{
bool ret = Interop.Window.SetNotificationLevel(swigCPtr, (int)level);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Gets a priority level for the specified notification window.
///
/// The notification window level.
/// 3
public NotificationLevel GetNotificationLevel()
{
NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// 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.
///
/// 3
public void SetOpaqueState(bool opaque)
{
Interop.Window.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.
/// 3
public bool IsOpaqueState()
{
bool ret = Interop.Window.IsOpaqueState(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Sets a window's screen off mode.
///
/// The screen mode.
/// True if no error occurred, false otherwise.
/// 4
public bool SetScreenOffMode(ScreenOffMode screenOffMode)
{
bool ret = Interop.Window.SetScreenOffMode(swigCPtr, (int)screenOffMode);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Gets the screen mode of the window.
///
/// The screen off mode.
/// 4
public ScreenOffMode GetScreenOffMode()
{
ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Sets preferred brightness of the window.
///
/// The preferred brightness (0 to 100).
/// True if no error occurred, false otherwise.
/// 3
public bool SetBrightness(int brightness)
{
bool ret = Interop.Window.SetBrightness(swigCPtr, brightness);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Gets the preferred brightness of the window.
///
/// The preferred brightness.
/// 3
public int GetBrightness()
{
int ret = Interop.Window.GetBrightness(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Sets the window name and the class string.
///
/// The name of the window.
/// The class of the window.
/// 4
public void SetClass(string name, string klass)
{
Interop.Window.Window_SetClass(swigCPtr, name, klass);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Raises the window to the top of the window stack.
///
/// 3
public void Raise()
{
Interop.Window.Window_Raise(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Lowers the window to the bottom of the window stack.
///
/// 3
public void Lower()
{
Interop.Window.Window_Lower(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Activates the window to the top of the window stack even it is iconified.
///
/// 3
public void Activate()
{
Interop.Window.Window_Activate(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Gets the default ( root ) layer.
///
/// The root layer.
/// 3
public Layer GetDefaultLayer()
{
return this.GetRootLayer();
}
///
/// Add a child view to window.
///
/// the child should be added to the window.
/// 3
public void Add(View view)
{
Interop.Actor.Actor_Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
view.InternalParent = this.GetRootLayer();
}
///
/// Remove a child view from window.
///
/// the child to be removed.
/// 3
public void Remove(View view)
{
Interop.Actor.Actor_Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
view.InternalParent = null;
}
///
/// Retrieves the layer at a specified depth.
///
/// The layer's depth index.
/// The layer found at the given depth.
/// 3
public Layer GetLayer(uint depth)
{
if (depth < LayersChildren?.Count)
{
Layer ret = LayersChildren?[Convert.ToInt32(depth)];
return ret;
}
else
{
return null;
}
}
///
/// Destroy the window immediately.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public void Destroy()
{
this.Dispose();
}
///
/// Keep rendering for at least the given amount of time.
///
/// Time to keep rendering, 0 means render at least one more frame.
/// 3
public void KeepRendering(float durationSeconds)
{
Interop.Stage.Stage_KeepRendering(stageCPtr, durationSeconds);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Grabs the key specified by a key for a window only when a window is the topmost window.
/// This function can be used for following example scenarios:
/// - Mobile - Using volume up or down as zoom up or down in camera apps.
///
/// The key code to grab.
/// True if the grab succeeds.
/// 3
public bool GrabKeyTopmost(int DaliKey)
{
bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Ungrabs the key specified by a key for the window.
/// Note: If this function is called between key down and up events of a grabbed key, an application doesn't receive the key up event.
///
/// The key code to ungrab.
/// True if the ungrab succeeds.
/// 3
public bool UngrabKeyTopmost(int DaliKey)
{
bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Grabs the key specified by a key for a window in a GrabMode.
/// Details: This function can be used for following example scenarios:
/// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app.
/// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app.
/// - Mobile - Using the volume up or down as zoom up or down in camera apps.
///
/// The key code to grab.
/// The grab mode for the key.
/// True if the grab succeeds.
/// 3
public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
{
bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Ungrabs the key specified by a key for a window.
/// Note: If this function is called between key down and up events of a grabbed key, an application doesn't receive the key up event.
///
/// The key code to ungrab.
/// True if the ungrab succeeds.
/// 3
public bool UngrabKey(int DaliKey)
{
bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Sets the keyboard repeat information.
///
/// The key repeat rate value in seconds.
/// The key repeat delay value in seconds.
/// True if setting the keyboard repeat succeeds.
/// 5
public bool SetKeyboardRepeatInfo(float rate, float delay)
{
bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Gets the keyboard repeat information.
///
/// The key repeat rate value in seconds.
/// The key repeat delay value in seconds.
/// True if setting the keyboard repeat succeeds.
/// 5
public bool GetKeyboardRepeatInfo(out float rate, out float delay)
{
bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Adds a layer to the stage.
///
/// Layer to add.
/// 3
public void AddLayer(Layer layer)
{
Interop.Window.Add(swigCPtr, Layer.getCPtr(layer));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
LayersChildren?.Add(layer);
layer.SetWindow(this);
}
///
/// Removes a layer from the stage.
///
/// Layer to remove.
/// 3
public void RemoveLayer(Layer layer)
{
Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
LayersChildren?.Remove(layer);
layer.SetWindow(null);
}
///
/// Feeds a key event into the window.
///
/// The key event to feed.
/// 5
public void FeedKey(Key keyEvent)
{
Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Allows at least one more render, even when paused.
/// The window should be shown, not minimised.
///
/// 4
public void RenderOnce()
{
Interop.Window.Window_RenderOnce(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Sets whether the window is transparent or not.
///
/// Whether the window is transparent or not.
/// 5
public void SetTransparency(bool transparent)
{
Interop.Window.SetTransparency(swigCPtr, transparent);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
// Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
}
///
/// Sets parent window of the window.
/// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
/// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
/// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
///
/// The parent window.
/// 6
public void SetParent(Window parent)
{
Interop.Window.SetParent(swigCPtr, Window.getCPtr(parent));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Unsets parent window of the window.
/// After unsetting, the window is disconnected his parent window.
///
/// 6
public void Unparent()
{
Interop.Window.Unparent(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Gets parent window of the window.
///
/// The parent window of the window.
/// 6
public Window GetParent()
{
Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.GetParent(swigCPtr)) as Window;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
{
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
internal static Window GetCurrent()
{
Window ret = new Window(Interop.Stage.Stage_GetCurrent(), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal static bool IsInstalled()
{
bool ret = Interop.Stage.Stage_IsInstalled();
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
{
Interop.WindowInternal.Window_ShowIndicator(swigCPtr, (int)visibleMode);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
{
Interop.WindowInternal.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal void RotateIndicator(Window.WindowOrientation orientation)
{
Interop.WindowInternal.Window_RotateIndicator(swigCPtr, (int)orientation);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Adds an orientation to the list of available orientations.
///
/// The available orientation to add
/// 6
public void AddAvailableOrientation(Window.WindowOrientation orientation)
{
Interop.Window.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Removes an orientation from the list of available orientations.
///
/// The available orientation to remove.
/// 6
public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
{
Interop.Window.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Sets a preferred orientation.
///
/// The preferred orientation.
/// 6
public void SetPreferredOrientation(Window.WindowOrientation orientation)
{
Interop.Window.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Gets the preferred orientation.
///
/// 6
/// The preferred orientation if previously set, or none.
public Window.WindowOrientation GetPreferredOrientation()
{
Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.Window_GetPreferredOrientation(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal Any GetNativeHandle()
{
Any ret = new Any(Interop.WindowInternal.Window_GetNativeHandle(swigCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal void Add(Layer layer)
{
Interop.Window.Add(swigCPtr, Layer.getCPtr(layer));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
LayersChildren?.Add(layer);
layer.SetWindow(this);
}
internal void Remove(Layer layer)
{
Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
LayersChildren?.Remove(layer);
layer.SetWindow(null);
}
internal Vector2 GetSize()
{
var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal RenderTaskList GetRenderTaskList()
{
RenderTaskList ret = new RenderTaskList(Interop.Stage.Stage_GetRenderTaskList(stageCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Queries the number of on-window layers.
///
/// The number of layers.
/// Note that a default layer is always provided (count >= 1).
internal uint GetLayerCount()
{
if (LayersChildren == null || LayersChildren.Count < 0)
return 0;
return (uint) LayersChildren.Count;
}
internal Layer GetRootLayer()
{
// Window.IsInstalled() is actually true only when called from event thread and
// Core has been initialized, not when Stage is ready.
if (_rootLayer == null && Window.IsInstalled())
{
_rootLayer = new Layer(Interop.Window.GetRootLayer(swigCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
LayersChildren?.Add(_rootLayer);
_rootLayer.SetWindow(this);
}
return _rootLayer;
}
internal void SetBackgroundColor(Vector4 color)
{
Interop.Window.SetBackgroundColor(swigCPtr, Vector4.getCPtr(color));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal Vector4 GetBackgroundColor()
{
Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(swigCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal Vector2 GetDpi()
{
Vector2 ret = new Vector2(Interop.Stage.Stage_GetDpi(stageCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal ObjectRegistry GetObjectRegistry()
{
ObjectRegistry ret = new ObjectRegistry(Interop.Stage.Stage_GetObjectRegistry(stageCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
{
Interop.Stage.Stage_SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal RenderingBehaviorType GetRenderingBehavior()
{
RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.Stage_GetRenderingBehavior(stageCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending)
throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal void SetWindowSize(Size2D size)
{
var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
Interop.Window.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
// Resetting Window size should request a relayout of the tree.
}
internal Size2D GetWindowSize()
{
var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal void SetPosition(Position2D position)
{
var val = new Uint16Pair((uint)position.X, (uint)position.Y);
Interop.Window.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
// Setting Position of the window should request a relayout of the tree.
}
internal Position2D GetPosition()
{
var val = new Uint16Pair(Interop.Window.GetPosition(swigCPtr), true);
Position2D ret = new Position2D(val.GetX(), val.GetY());
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal void SetPositionSize(Rectangle positionSize)
{
Interop.Window.Window_SetPositionSize(swigCPtr, Rectangle.getCPtr(positionSize));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
// Setting Position of the window should request a relayout of the tree.
}
///
/// Dispose for Window
///
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void Dispose(DisposeTypes type)
{
if (disposed)
{
return;
}
if (type == DisposeTypes.Explicit)
{
//Called by User
//Release your own managed resources here.
//You should release all of your own disposable objects here.
_rootLayer.Dispose();
localController.Dispose();
foreach(var layer in _childLayers)
{
layer.Dispose();
}
_childLayers.Clear();
}
this.DisconnectNativeSignals();
//Release your own unmanaged resources here.
//You should not access any managed member here except static instance.
//because the execution order of Finalizes is non-deterministic.
if (swigCPtr.Handle != global::System.IntPtr.Zero)
{
if (swigCMemOwn)
{
swigCMemOwn = false;
Interop.Window.delete_Window(swigCPtr);
}
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
base.Dispose(type);
}
}
}