//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
//**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************//
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using bs;
namespace bs.Editor
{
/** @addtogroup Window
* @{
*/
///
/// Base implementation of a window that when open doesn't allow you to interact with other windows. Modal windows
/// are similar to editor windows but cannot be docked, and are meant to be used for temporary operations like dialog
/// boxes and progress bars.
///
public class ModalWindow : ScriptObject
{
///
/// Width of the window in pixels.
///
public int Width
{
get { return Internal_GetWidth(mCachedPtr); }
set { Internal_SetWidth(mCachedPtr, value); }
}
///
/// Height of the window in pixels.
///
public int Height
{
get { return Internal_GetHeight(mCachedPtr); }
set { Internal_SetHeight(mCachedPtr, value); }
}
///
/// Width of the content area of the window, in pixels. The content area represents the area of the window not
/// including the title bar and the border.
///
public int ContentWidth
{
get { return Internal_GetContentWidth(mCachedPtr); }
set { Internal_SetContentWidth(mCachedPtr, value); }
}
///
/// Height of the content area of the window, in pixels. The content area represents the area of the window not
/// including the title bar and the border.
///
public int ContentHeight
{
get { return Internal_GetContentHeight(mCachedPtr); }
set { Internal_SetContentHeight(mCachedPtr, value); }
}
protected GUIPanel GUI;
///
/// Constructor for internal use by the runtime.
///
protected ModalWindow()
{
Internal_CreateInstance(this, false);
}
///
/// Creates a new modal window.
///
/// Should the close button be displayed.
protected ModalWindow(bool allowCloseButton)
{
Internal_CreateInstance(this, allowCloseButton);
}
///
/// Converts coordinates in screen space to coordinates relative to the window.
///
/// Coordinates in screen space.
/// Coordinates relative to the window.
protected Vector2I ScreenToWindowPos(Vector2I screenPos)
{
Vector2I windowPos;
Internal_ScreenToWindowPos(mCachedPtr, ref screenPos, out windowPos);
return windowPos;
}
///
/// Converts coordinates relative to the window to screen space to coordinates.
///
/// Coordinates relative to the window.
/// Coordinates in screen space.
protected Vector2I WindowToScreenPos(Vector2I windowPos)
{
Vector2I screenPos;
Internal_WindowToScreenPos(mCachedPtr, ref windowPos, out screenPos);
return screenPos;
}
///
/// Triggered whenever the window size ranges.
///
/// New width of the window in pixels.
/// New height of the window in pixels.
protected virtual void OnWindowResized(int width, int height)
{
}
///
/// Closes the modal window.
///
protected void Close()
{
Internal_Close(mCachedPtr);
}
///
/// Allows you to set the mame of the window to display in the title bar.
///
public LocString Title
{
set { Internal_SetTitle(mCachedPtr, value); }
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_CreateInstance(ModalWindow instance, bool allowCloseButton);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_Close(IntPtr nativeInstance);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetTitle(IntPtr nativeInstance, LocString title);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern int Internal_GetWidth(IntPtr nativeInstance);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern int Internal_SetWidth(IntPtr nativeInstance, int value);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern int Internal_GetHeight(IntPtr nativeInstance);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern int Internal_SetHeight(IntPtr nativeInstance, int value);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern int Internal_GetContentWidth(IntPtr nativeInstance);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern int Internal_SetContentWidth(IntPtr nativeInstance, int value);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern int Internal_GetContentHeight(IntPtr nativeInstance);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern int Internal_SetContentHeight(IntPtr nativeInstance, int value);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_ScreenToWindowPos(IntPtr nativeInstance, ref Vector2I position, out Vector2I windowPos);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_WindowToScreenPos(IntPtr nativeInstance, ref Vector2I position, out Vector2I screenPos);
}
/** @} */
}