/*
* Copyright(c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
extern alias TizenSystemInformation;
using TizenSystemInformation.Tizen.System;
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 HandleRef stageCPtr;
private Layer rootLayer;
private Layer overlayLayer;
private Layer borderLayer;
private string windowTitle;
private List childLayers = new List();
private LayoutController localController;
private Key internalLastKeyEvent;
private Touch internalLastTouchEvent;
private Timer internalHoverTimer;
static internal bool IsSupportedMultiWindow()
{
bool isSupported = false;
try
{
Information.TryGetValue("http://tizen.org/feature/opengles.surfaceless_context", out isSupported);
}
catch (DllNotFoundException e)
{
Tizen.Log.Fatal("NUI", $"{e}\n");
}
return isSupported;
}
internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
{
if (Interop.Stage.IsInstalled())
{
stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.GetCurrent());
localController = new LayoutController(this);
NUILog.Debug("layoutController id:" + localController.GetId());
}
}
///
/// A helper method to get the current window where the view is added
///
/// The View added to the window
/// A Window.
[EditorBrowsable(EditorBrowsableState.Never)]
static public Window Get(View view)
{
if (view == null)
{
NUILog.Error("if there is no view, it can not get a window");
return null;
}
//to fix memory leak issue, match the handle count with native side.
Window ret = view.GetInstanceSafely(Interop.Window.Get(View.getCPtr(view)));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// 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
/// http://tizen.org/feature/opengles.surfaceless_context
/// The required feature is not supported.
public Window(Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
{
if (IsSupportedMultiWindow() == false)
{
NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
}
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
/// http://tizen.org/feature/opengles.surfaceless_context
/// The required feature is not supported.
public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
{
if (IsSupportedMultiWindow() == false)
{
NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
}
this.windowTitle = name;
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.
/// If borderInterface is null, defaultBorder is enabled.
/// The position and size of the Window.
/// Whether Window is translucent.
/// A new Window.
/// http://tizen.org/feature/opengles.surfaceless_context
/// The required feature is not supported.
[EditorBrowsable(EditorBrowsableState.Never)]
public Window(string name, IBorderInterface borderInterface, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
{
if (IsSupportedMultiWindow() == false)
{
NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
}
this.windowTitle = name;
this.EnableBorder(borderInterface);
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.
///
[Obsolete("Do not use this, that will be removed. Use Window.EffectState instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
// This is already deprecated, so suppress warning here.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "")]
public enum EffectStates
{
///
/// None state.
///
[Obsolete("Do not use this, that will be removed. Use Window.EffectState.None instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
None = 0,
///
/// Transition effect is started.
///
[Obsolete("Do not use this, that will be removed. Use Window.EffectState.Start instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
Start,
///
/// Transition effect is ended.
///
[Obsolete("Do not use this, that will be removed. Use Window.EffectState.End instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
End,
}
///
/// Enumeration for transition effect's state.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public enum EffectState
{
///
/// 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.
///
[Obsolete("Do not use this, that will be removed. Use Window.EffectType instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
// This is already deprecated, so suppress warning here.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "")]
public enum EffectTypes
{
///
/// None type.
///
[Obsolete("Do not use this, that will be removed. Use Window.EffectType.None instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
None = 0,
///
/// Window show effect.
///
[Obsolete("Do not use this, that will be removed. Use Window.EffectType.Show instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
Show,
///
/// Window hide effect.
///
[Obsolete("Do not use this, that will be removed. Use Window.EffectType.Hide instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
Hide,
}
///
/// Enumeration for transition effect's type.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public enum EffectType
{
///
/// None type.
///
[EditorBrowsable(EditorBrowsableState.Never)]
None = 0,
///
/// Window show effect.
///
[EditorBrowsable(EditorBrowsableState.Never)]
Show,
///
/// Window hide effect.
///
[EditorBrowsable(EditorBrowsableState.Never)]
Hide,
}
///
/// Enumeration for result of window operation.
///
internal enum OperationResult
{
///
/// Failed for unknown reason
///
UnknownError = 0,
///
/// Succeed
///
Succeed,
///
/// Permission denied
///
PermissionDenied,
///
/// The operation is not supported.
///
NotSupported,
}
///
/// Enumeration for window resized mode by display server.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public enum ResizeDirection
{
///
/// None type.
///
[EditorBrowsable(EditorBrowsableState.Never)]
None = 0,
///
/// Start resizing window to the top-left edge.
///
[EditorBrowsable(EditorBrowsableState.Never)]
TopLeft = 1,
///
/// Start resizing window to the top side.
///
[EditorBrowsable(EditorBrowsableState.Never)]
Top = 2,
///
/// Start resizing window to the top-right edge.
///
[EditorBrowsable(EditorBrowsableState.Never)]
TopRight = 3,
///
/// Start resizing window to the left side.
///
[EditorBrowsable(EditorBrowsableState.Never)]
Left = 4,
///
/// Start resizing window to the right side.
///
[EditorBrowsable(EditorBrowsableState.Never)]
Right = 5,
///
/// Start resizing window to the bottom-left edge.
///
[EditorBrowsable(EditorBrowsableState.Never)]
BottomLeft = 6,
///
/// Start resizing window to the bottom side.
///
[EditorBrowsable(EditorBrowsableState.Never)]
Bottom = 7,
///
/// Start resizing window to the bottom-right edge.
///
[EditorBrowsable(EditorBrowsableState.Never)]
BottomRight = 8,
}
///
/// The stage instance property (read-only).
/// Gets the current window.
///
/// 3
public static Window Instance { get; internal set; }
///
/// Gets or sets a window type.
/// Most of window type can be set to use WindowType, except for IME type.
/// IME type can be set to use one of NUIApplication's constrcutors.
///
/// 3
public WindowType Type
{
get
{
WindowType ret = (WindowType)Interop.Window.GetType(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", 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.
///
/// Thrown when value is null.
/// 4
public Size2D WindowSize
{
get
{
return GetWindowSize();
}
set
{
SetWindowSize(value);
}
}
///
/// Gets or sets a position of the window.
///
/// Thrown when value is null.
/// 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 ?? 0, position?.Y ?? 0, size?.Width ?? 0, size?.Height ?? 0);
position.Dispose();
return ret;
}
set
{
SetPositionSize(value);
}
}
///
/// Gets or sets whether the window will update partial area or full area.
/// If this value is true, window will update and render partial area.
/// If false, full area updated.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public bool PartialUpdate
{
get
{
return IsPartialUpdate();
}
set
{
SetPartialUpdate(value);
}
}
internal static Vector4 DEFAULT_BACKGROUND_COLOR
{
get
{
global::System.IntPtr cPtr = Interop.Stage.DefaultBackgroundColorGet();
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.DebugBackgroundColorGet();
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("Do not use this, that will be deprecated. Use FeedKey(Key keyEvent) instead.")]
public static void FeedKeyEvent(Key keyEvent)
{
Interop.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)
{
var ret = (OperationResult)Interop.Window.SetNotificationLevel(SwigCPtr, (int)level);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret == OperationResult.Succeed;
}
///
/// 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)
{
var ret = (OperationResult)Interop.Window.SetScreenOffMode(SwigCPtr, (int)screenOffMode);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret == OperationResult.Succeed;
}
///
/// 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)
{
var ret = (OperationResult)Interop.Window.SetBrightness(SwigCPtr, brightness);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret == OperationResult.Succeed;
}
///
/// 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.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.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.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.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();
}
///
/// Gets the overlay layer.
///
/// The overlay layer.
[EditorBrowsable(EditorBrowsableState.Never)]
public Layer GetOverlayLayer()
{
// Window.IsInstalled() is actually true only when called from event thread and
// Core has been initialized, not when Stage is ready.
if (overlayLayer == null && Window.IsInstalled())
{
overlayLayer = new Layer(Interop.Window.GetOverlayLayer(SwigCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
LayersChildren?.Add(overlayLayer);
overlayLayer.SetWindow(this);
}
return overlayLayer;
}
///
/// Add a child view to window.
///
/// the child should be added to the window.
/// 3
public void Add(View view)
{
this.GetRootLayer().Add(view);
}
///
/// Remove a child view from window.
///
/// the child to be removed.
/// 3
public void Remove(View view)
{
this.GetRootLayer().Remove(view);
}
///
/// 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.Window.KeepRendering(SwigCPtr, 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.
/// Thrown when layer is null.
/// 3
public void AddLayer(Layer layer)
{
Add(layer);
}
///
/// Removes a layer from the stage.
///
/// Layer to remove.
/// Thrown when layer is null.
/// 3
public void RemoveLayer(Layer layer)
{
Remove(layer);
}
///
/// Feeds a key event into the window.
///
/// The key event to feed.
/// 5
public void FeedKey(Key keyEvent)
{
Interop.Window.FeedKeyEvent(SwigCPtr, Key.getCPtr(keyEvent));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Feeds a hover event into the window.
/// This is feed after a default time of 48 ms. You can also set this time.
///
/// The time of how much later it will be feed (default is 48ms)
/// If you want to do FeedHover after the UI is updated, it is recommended to set the time to at least 16ms. This will be a good time waiting for the UI to update.
/// and LazyFeedHover called within the set time are ignored. Only the last request becomes a FeedHover.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public void LazyFeedHover(uint time = 48)
{
if (internalHoverTimer == null)
{
internalHoverTimer = new Timer(time);
internalHoverTimer.Tick += (s, e) =>
{
using Touch touch = GetLastTouchEvent();
if(touch != null && touch.GetPointCount() > 0)
{
using Vector2 screenPosition = touch.GetScreenPosition(0);
using TouchPoint touchPoint = new TouchPoint(touch.GetDeviceId(0), TouchPoint.StateType.Motion, screenPosition.X, screenPosition.Y);
FeedHover(touchPoint);
}
internalHoverTimer?.Stop();
internalHoverTimer?.Dispose();
internalHoverTimer = null;
return false;
};
internalHoverTimer.Start();
}
else
{
internalHoverTimer.Start();
}
}
///
/// Feeds a touch point into the window.
///
/// The touch point to feed.
/// The timeStamp.
internal void FeedTouch(TouchPoint touchPoint, int timeStamp)
{
Interop.Window.FeedTouchPoint(SwigCPtr, TouchPoint.getCPtr(touchPoint), timeStamp);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Feeds a wheel event into the window.
///
/// The wheel event to feed.
internal void FeedWheel(Wheel wheelEvent)
{
Interop.Window.FeedWheelEvent(SwigCPtr, Wheel.getCPtr(wheelEvent));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Feeds a hover event into the window.
///
/// The touch point to feed hover event.
[EditorBrowsable(EditorBrowsableState.Never)]
internal void FeedHover(TouchPoint touchPoint)
{
Interop.Window.FeedHoverEvent(SwigCPtr, TouchPoint.getCPtr(touchPoint));
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.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
/// http://tizen.org/feature/opengles.surfaceless_context
/// The required feature is not supported.
public void SetParent(Window parent)
{
if (IsSupportedMultiWindow() == false)
{
NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
}
Interop.Window.SetParent(SwigCPtr, Window.getCPtr(parent));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Sets parent window of the window.
/// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
/// This function has the additional flag whether the child is located above or below of the parent.
///
/// The parent window.
/// The flag is whether the child is located above or below of the parent.
/// http://tizen.org/feature/opengles.surfaceless_context
/// The required feature is not supported.
[EditorBrowsable(EditorBrowsableState.Never)]
public void SetParent(Window parent, bool belowParent)
{
if (IsSupportedMultiWindow() == false)
{
NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
}
Interop.Window.SetParentWithStack(SwigCPtr, Window.getCPtr(parent), belowParent);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Unsets parent window of the window.
/// After unsetting, the window is disconnected his parent window.
///
/// 6
/// http://tizen.org/feature/opengles.surfaceless_context
/// The required feature is not supported.
public void Unparent()
{
if (IsSupportedMultiWindow() == false)
{
NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
}
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
/// http://tizen.org/feature/opengles.surfaceless_context
/// The required feature is not supported.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
public Window GetParent()
{
if (IsSupportedMultiWindow() == false)
{
NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
}
Window ret = this.GetInstanceSafely(Interop.Window.GetParent(SwigCPtr));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
/// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void ObjectDump()
{
Layer rootLayer = GetRootLayer();
foreach (View view in rootLayer.Children)
{
view.ObjectDump();
}
}
internal static bool IsInstalled()
{
bool ret = Interop.Stage.IsInstalled();
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Adds an orientation to the list of available orientations.
///
/// The available orientation to add
/// 6
public void AddAvailableOrientation(Window.WindowOrientation orientation)
{
Interop.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.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.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.GetPreferredOrientation(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Gets current orientation of the window.
///
/// 6
/// The current window orientation if previously set, or none.
[EditorBrowsable(EditorBrowsableState.Never)]
public Window.WindowOrientation GetCurrentOrientation()
{
Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.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.
/// 6
[EditorBrowsable(EditorBrowsableState.Never)]
public void SetAvailableOrientations(List orientations)
{
if (null == orientations)
{
throw new ArgumentNullException(nameof(orientations));
}
PropertyArray orientationArray = new PropertyArray();
for (int i = 0; i < orientations.Count; i++)
{
PropertyValue value = new PropertyValue((int)orientations[i]);
orientationArray.PushBack(value);
value.Dispose();
}
Interop.Window.SetAvailableOrientations(SwigCPtr, PropertyArray.getCPtr(orientationArray), orientations.Count);
orientationArray.Dispose();
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Get native window ID
///
/// native window ID
[EditorBrowsable(EditorBrowsableState.Never)]
public int GetNativeId()
{
int ret = Interop.Window.GetNativeId(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal Any GetNativeHandle()
{
Any ret = new Any(Interop.WindowInternal.WindowGetNativeHandle(SwigCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal void Add(Layer layer)
{
if (null == layer)
{
throw new ArgumentNullException(nameof(layer));
}
if (isBorderWindow)
{
Interop.Actor.Add(GetRootLayer().SwigCPtr, layer.SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); }
}
else
{
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)
{
if (null == layer)
{
throw new ArgumentNullException(nameof(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), true);
convertRealWindowSizeToBorderWindowSize(val);
Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
val.Dispose();
return ret;
}
/// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public RenderTaskList GetRenderTaskList()
{
RenderTaskList ret = new RenderTaskList(Interop.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()
{
if (isBorderWindow)
{
if (borderLayer == null)
{
borderLayer = GetBorderWindowRootLayer();
LayersChildren?.Add(borderLayer);
borderLayer.SetWindow(this);
}
return borderLayer;
}
else
{
// 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.GetDpi(stageCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal ObjectRegistry GetObjectRegistry()
{
ObjectRegistry ret = new ObjectRegistry(Interop.Stage.GetObjectRegistry(stageCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
{
Interop.Stage.SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal RenderingBehaviorType GetRenderingBehavior()
{
RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.GetRenderingBehavior(stageCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending)
throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal void SetWindowSize(Size2D size)
{
if (null == size)
{
throw new ArgumentNullException(nameof(size));
}
var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
convertBorderWindowSizeToRealWindowSize(val);
Interop.Window.SetSize(SwigCPtr, Uint16Pair.getCPtr(val));
val.Dispose();
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), true);
convertRealWindowSizeToBorderWindowSize(val);
Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
val.Dispose();
return ret;
}
internal void SetPosition(Position2D position)
{
if (null == position)
{
throw new ArgumentNullException(nameof(position));
}
var val = new Int32Pair(position.X, position.Y);
Interop.Window.SetPosition(SwigCPtr, Int32Pair.getCPtr(val));
val.Dispose();
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 Int32Pair(Interop.Window.GetPosition(SwigCPtr), true);
Position2D ret = new Position2D((int)val.GetX(), (int)val.GetY());
val.Dispose();
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal void SetPositionSize(Rectangle positionSize)
{
if (positionSize == null)
{
throw new ArgumentNullException(nameof(positionSize));
}
var val = new Uint16Pair((uint)positionSize.Width, (uint)positionSize.Height);
convertBorderWindowSizeToRealWindowSize(val);
positionSize.Width = val.GetX();
positionSize.Height = val.GetY();
Interop.Window.SetPositionSize(SwigCPtr, Rectangle.getCPtr(positionSize));
val.Dispose();
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
// Setting Position of the window should request a relayout of the tree.
}
///
/// Set the window use partial update or not.
///
/// If window enable partial update or disable.
internal void SetPartialUpdate(bool enabled)
{
Interop.Window.SetPartialUpdateEnabled(SwigCPtr, enabled);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Returns whether the window is enabled partial update or not.
///
/// True if the window is enabled partial update, false otherwise.
internal bool IsPartialUpdate()
{
bool ret = Interop.Window.IsPartialUpdateEnabled(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Enables the floating mode of window.
/// The floating mode is to support window is moved or resized by display server.
/// For example, if the video-player window sets the floating mode,
/// then display server changes its geometry and handles it like a popup.
/// The way of handling floating mode window is decided by display server.
/// A special display server(as a Tizen display server) supports this mode.
///
/// Enable floating mode or not.
[EditorBrowsable(EditorBrowsableState.Never)]
public void EnableFloatingMode(bool enable)
{
Interop.Window.EnableFloatingMode(SwigCPtr, enable);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Returns whether the window is floating mode or not.
///
/// True if the window is enabled floating mode, false otherwise.
[EditorBrowsable(EditorBrowsableState.Never)]
public bool IsFloatingModeEnabled()
{
bool ret = Interop.Window.IsFloatingModeEnabled(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Requests to display server for the window is moved by display server.
/// It can be work with setting window floating mode.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public void RequestMoveToServer()
{
Interop.Window.RequestMoveToServer(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Requests to display server for the window is resized by display server.
/// It can be work with setting window floating mode.
///
/// It is indicated the window's side or edge for starting point.
[EditorBrowsable(EditorBrowsableState.Never)]
public void RequestResizeToServer(ResizeDirection direction)
{
Interop.Window.RequestResizeToServer(SwigCPtr, (int)direction);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Includes input region.
/// This function inlcudes input regions.
/// It can be used multiple times and supports multiple regions.
/// It means input region will be extended.
/// This input is related to mouse and touch event.
/// If device has touch screen, this function is useful.
/// Otherwise device does not have that, we can use it after connecting mouse to the device.
///
/// The included region to accept input events.
[EditorBrowsable(EditorBrowsableState.Never)]
public void IncludeInputRegion(Rectangle inputRegion)
{
Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// This function excludes input regions.
/// It can be used multiple times and supports multiple regions.
/// It means input region will be reduced.
/// Nofice, should be set input area by IncludeInputRegion() before this function is used.
/// This input is related to mouse and touch event.
/// If device has touch screen, this function is useful.
/// Otherwise device does not have that, we can use it after connecting mouse to the device.
///
/// The excluded region to except input events.
[EditorBrowsable(EditorBrowsableState.Never)]
public void ExcludeInputRegion(Rectangle inputRegion)
{
Interop.Window.ExcludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Maximizes window's size.
/// If this function is called with true, window will be resized with screen size.
/// Otherwise window will be resized with previous size.
/// It is for the window's MAX button in window's border.
/// If window border is supported by display server, it is not necessary.
///
/// If window is maximized or unmaximized.
[EditorBrowsable(EditorBrowsableState.Never)]
public void Maximize(bool max)
{
Interop.Window.Maximize(SwigCPtr, max);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Returns whether the window is maximized or not.
///
/// True if the window is maximized, false otherwise.
[EditorBrowsable(EditorBrowsableState.Never)]
public bool IsMaximized()
{
bool ret = Interop.Window.IsMaximized(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Sets window's maximum size.
///
/// It is to set the maximized size when window is maximized or the window's size is increased by RequestResizeToServer().
/// Although the size is set by this function, window's size can be increased over the limitation by SetPositionSize() or SetSize().
///
/// After setting, if Maximize() is called, window is resized with the setting size and move the center.
///
///
/// the maximum size.
[EditorBrowsable(EditorBrowsableState.Never)]
public void SetMaximumSize(Size2D size)
{
if (null == size)
{
throw new ArgumentNullException(nameof(size));
}
var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
Interop.Window.SetMaximumSize(SwigCPtr, Uint16Pair.getCPtr(val));
val.Dispose();
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Minimizes window's size.
/// If this function is called with true, window will be iconified.
/// Otherwise window will be activated.
/// It is for the window's MIN button in window border.
/// If window border is supported by display server, it is not necessary.
///
/// If window is minimized or unminimized.
[EditorBrowsable(EditorBrowsableState.Never)]
public void Minimize(bool min)
{
Interop.Window.Minimize(SwigCPtr, min);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Returns whether the window is minimized or not.
///
/// True if the window is minimized, false otherwise.
[EditorBrowsable(EditorBrowsableState.Never)]
public bool IsMinimized()
{
bool ret = Interop.Window.IsMinimized(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Sets window's minimum size.
/// It is to set the minimum size when window's size is decreased by RequestResizeToServer().
/// Although the size is set by this function, window's size can be decreased over the limitation by SetPositionSize() or SetSize().
///
/// the minimum size.
[EditorBrowsable(EditorBrowsableState.Never)]
public void SetMimimumSize(Size2D size)
{
if (null == size)
{
throw new ArgumentNullException(nameof(size));
}
var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
Interop.Window.SetMimimumSize(SwigCPtr, Uint16Pair.getCPtr(val));
val.Dispose();
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Sets the layout of the window.
///
/// The number of columns in the layout.
/// The number of rows in the layout.
/// The column number of the window within the layout.
/// The row number of the window within the layout.
/// The number of columns the window should span within the layout.
/// The number of rows the window should span within the layout.
[EditorBrowsable(EditorBrowsableState.Never)]
public void SetLayout(uint numCols, uint numRows, uint column, uint row, uint colSpan, uint rowSpan)
{
Interop.Window.SetLayout(SwigCPtr, numCols, numRows, column, row, colSpan, rowSpan);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Sets the layout of the window.
///
/// The type of layout to set for the window.
[EditorBrowsable(EditorBrowsableState.Never)]
public void SetLayout(WindowLayoutType layoutType)
{
switch (layoutType)
{
case WindowLayoutType.LeftHalf:
Interop.Window.SetLayout(SwigCPtr, 2, 1, 0, 0, 1, 1);
break;
case WindowLayoutType.RightHalf:
Interop.Window.SetLayout(SwigCPtr, 2, 1, 1, 0, 1, 1);
break;
case WindowLayoutType.TopHalf:
Interop.Window.SetLayout(SwigCPtr, 1, 2, 0, 0, 1, 1);
break;
case WindowLayoutType.BottomHalf:
Interop.Window.SetLayout(SwigCPtr, 1, 2, 0, 1, 1, 1);
break;
case WindowLayoutType.UpperLeftQuarter:
Interop.Window.SetLayout(SwigCPtr, 2, 2, 0, 0, 1, 1);
break;
case WindowLayoutType.UpperRightQuarter:
Interop.Window.SetLayout(SwigCPtr, 2, 2, 1, 0, 1, 1);
break;
case WindowLayoutType.LowerLeftQuarter:
Interop.Window.SetLayout(SwigCPtr, 2, 2, 0, 1, 1, 1);
break;
case WindowLayoutType.LowerRightQuarter:
Interop.Window.SetLayout(SwigCPtr, 2, 2, 1, 1, 1, 1);
break;
case WindowLayoutType.LeftThird:
Interop.Window.SetLayout(SwigCPtr, 3, 1, 0, 0, 1, 1);
break;
case WindowLayoutType.CenterThird:
Interop.Window.SetLayout(SwigCPtr, 3, 1, 1, 0, 1, 1);
break;
case WindowLayoutType.RightThird:
Interop.Window.SetLayout(SwigCPtr, 3, 1, 2, 0, 1, 1);
break;
case WindowLayoutType.TopThird:
Interop.Window.SetLayout(SwigCPtr, 1, 3, 0, 0, 1, 1);
break;
case WindowLayoutType.MiddleThird:
Interop.Window.SetLayout(SwigCPtr, 1, 3, 0, 1, 1, 1);
break;
case WindowLayoutType.BottomThird:
Interop.Window.SetLayout(SwigCPtr, 1, 3, 0, 2, 1, 1);
break;
}
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Query whether window is rotating or not.
///
/// True if window is rotating, false otherwise.
[EditorBrowsable(EditorBrowsableState.Never)]
public bool IsWindowRotating()
{
bool ret = Interop.Window.IsWindowRotating(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Gets the last key event the window gets.
///
/// The last key event the window gets.
[EditorBrowsable(EditorBrowsableState.Never)]
public Key GetLastKeyEvent()
{
if(internalLastKeyEvent == null)
{
internalLastKeyEvent = new Key();
}
Interop.Window.InternalRetrievingLastKeyEvent(SwigCPtr, internalLastKeyEvent.SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return internalLastKeyEvent;
}
///
/// Gets the last touch event the window gets.
///
/// The last touch event the window gets.
[EditorBrowsable(EditorBrowsableState.Never)]
public Touch GetLastTouchEvent()
{
if(internalLastTouchEvent == null)
{
internalLastTouchEvent = new Touch();
}
Interop.Window.InternalRetrievingLastTouchEvent(SwigCPtr, internalLastTouchEvent.SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return internalLastTouchEvent;
}
///
/// Sets the necessary for window rotation Acknowledgement.
/// After this function called, SendRotationCompletedAcknowledgement() should be called to complete window rotation.
///
/// This function is supprot that application has the window rotation acknowledgement's control.
/// It means display server waits when application's rotation work is finished.
/// It is useful application has the other rendering engine which works asynchronous.
/// For instance, GlView.
///
/// the flag is true if window rotation acknowledge is sent.
[EditorBrowsable(EditorBrowsableState.Never)]
public void SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
{
Interop.Window.SetNeedsRotationCompletedAcknowledgement(SwigCPtr, needAcknowledgement);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// send the Acknowledgement to complete window rotation.
/// For this function, SetNeedsRotationCompletedAcknowledgement should be already called with true.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public void SendRotationCompletedAcknowledgement()
{
Interop.Window.SendRotationCompletedAcknowledgement(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Add FrameUpdateCallback
///
[EditorBrowsable(EditorBrowsableState.Never)]
public void AddFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
{
frameUpdateCallback?.AddFrameUpdateCallback(stageCPtr, Layer.getCPtr(GetRootLayer()));
}
///
/// Remove FrameUpdateCallback
///
[EditorBrowsable(EditorBrowsableState.Never)]
public void RemoveFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
{
frameUpdateCallback?.RemoveFrameUpdateCallback(stageCPtr);
}
///
/// Dispose for Window
///
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void Dispose(DisposeTypes type)
{
if (disposed)
{
return;
}
this.DisconnectNativeSignals();
if (type == DisposeTypes.Explicit)
{
//Called by User
//Release your own managed resources here.
//You should release all of your own disposable objects here.
if (IsBorderEnabled)
{
DisposeBorder();
}
foreach (var layer in childLayers)
{
if (layer != null)
{
layer.Dispose();
}
}
childLayers.Clear();
localController?.Dispose();
internalLastKeyEvent?.Dispose();
internalLastKeyEvent = null;
internalLastTouchEvent?.Dispose();
internalLastTouchEvent = null;
internalHoverTimer?.Stop();
internalHoverTimer?.Dispose();
internalHoverTimer = null;
}
base.Dispose(type);
}
/// This will not be public opened.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
{
Interop.Window.DeleteWindow(swigCPtr);
}
private static Dictionary frameCallbackList = new Dictionary();
private static readonly object locker = new object();
private static int key = 0;
private static FrameCallbackType internalHookFrameCallback = OnInternalHookFrameCallback;
private struct internalHookCallbackType
{
public FrameCallbackType userCallback;
public int frameId;
}
private static void OnInternalHookFrameCallback(int id)
{
lock (locker)
{
if (frameCallbackList.ContainsKey(id))
{
if (frameCallbackList[id].userCallback != null)
{
frameCallbackList[id].userCallback.Invoke(frameCallbackList[id].frameId);
frameCallbackList.Remove(id);
}
else
{
NUILog.Error($"found userCallback is NULL");
frameCallbackList.Remove(id);
}
}
}
}
private int AddInterHookCallback(FrameCallbackType callback, int frameId)
{
if (null == callback)
{
throw new ArgumentNullException(nameof(callback), "FrameCallbackType should not be null");
}
var assignedKey = 0;
lock (locker)
{
key++;
assignedKey = key;
frameCallbackList.Add(assignedKey, new internalHookCallbackType()
{
userCallback = callback,
frameId = frameId,
});
}
return assignedKey;
}
///
/// Type of callback which is called when the frame rendering is done by graphics driver or when the frame is displayed on display.
///
/// The Id to specify the frame. It will be passed when the callback is called.
[EditorBrowsable(EditorBrowsableState.Never)]
public delegate void FrameCallbackType(int frameId);
///
/// Adds a callback that is called when the frame rendering is done by the graphics driver.
/// A callback of the following type may be used:
///
/// void MyFunction( int frameId )
///
/// This callback will be deleted once it is called.
///
/// Ownership of the callback is passed onto this class
///
///
/// The function to call
/// The Id to specify the frame. It will be passed when the callback is called.
/// This exception can occur by the callback is null.
[EditorBrowsable(EditorBrowsableState.Never)]
public void AddFrameRenderedCallback(FrameCallbackType callback, int frameId)
{
var assignedKey = AddInterHookCallback(callback, frameId);
Interop.WindowInternal.AddFrameRenderedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate(internalHookFrameCallback)), assignedKey);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Adds a callback that is called when the frame is displayed on the display.
/// A callback of the following type may be used:
///
/// void MyFunction( int frameId )
///
/// This callback will be deleted once it is called.
///
/// Ownership of the callback is passed onto this class
///
///
/// The function to call
/// The Id to specify the frame. It will be passed when the callback is called.
/// This exception can occur by the callback is null.
[EditorBrowsable(EditorBrowsableState.Never)]
public void AddFramePresentedCallback(FrameCallbackType callback, int frameId)
{
var assignedKey = AddInterHookCallback(callback, frameId);
Interop.WindowInternal.AddFramePresentedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate(internalHookFrameCallback)), assignedKey);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Search through this Window for a Layer with the given unique ID.
///
/// The ID of the Layer to find.
/// Hidden-API
/// A handle to the Layer if found, or an empty handle if not.
[EditorBrowsable(EditorBrowsableState.Never)]
public Layer FindLayerByID(uint id)
{
Layer defaultLayer = this.GetDefaultLayer();
IntPtr cPtr = Interop.Actor.FindChildById(defaultLayer.SwigCPtr, id);
Layer ret = this.GetInstanceSafely(cPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Get Native Window handle.
///
/// How to get Native Window handle
///
/// Window window = NUIApplication.GetDefaultWindow();
/// var handle = window.NativeHandle;
/// if(handle.IsInvalid == false)
/// {
/// IntPtr nativeHandle = handle.DangerousGetHandle();
/// // do something with nativeHandle
/// }
///
///
///
/// 9
public SafeHandle NativeHandle
{
get
{
return new NUI.SafeNativeWindowHandle(this);
}
}
}
}