//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
//**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************//
using System;
using System.Runtime.CompilerServices;
using bs;
namespace bs.Editor
{
/** @addtogroup Scene-Editor
* @{
*/
///
/// Handles rendering and interaction with scene handles for the specified camera.
///
internal sealed class SceneHandles : ScriptObject
{
///
/// Creates a new scene handle manager.
///
/// Editor window in which the scene handles are displayed.
/// Camera through which the scene handles are displayed.
internal SceneHandles(EditorWindow parent, Camera sceneCamera)
{
Internal_Create(this, parent.GetCachedPtr(), sceneCamera.GetCachedPtr());
}
///
/// Triggers handle pre-input callbacks. Must be called before all calls and followed by
/// . This should be called only once per frame.
///
internal static void BeginInput()
{
Internal_BeginInput();
}
///
/// Triggers handle post-input callbacks. Must be called after all calls and after
/// . This should be called only once per frame.
///
internal static void EndInput()
{
Internal_EndInput();
}
///
/// Updates active handles by moving them as a result of any input. Make sure to call before
/// this method, followed by when done.
///
/// Position of the pointer relative to the scene camera viewport.
/// Movement of the pointer since last frame.
internal void UpdateInput(Vector2I pointerPos, Vector2I inputDelta)
{
Internal_UpdateInput(mCachedPtr, ref pointerPos, ref inputDelta);
}
///
/// Draws the handles onto the target camera.
///
internal void Draw()
{
Internal_Draw(mCachedPtr);
}
///
/// Selects a handle under the pointer position.
///
/// Position of the pointer relative to the target camera's viewport.
internal void TrySelect(Vector2I pointerPos)
{
Internal_TrySelect(mCachedPtr, ref pointerPos);
}
///
/// Checks is any handle currently active.
///
/// True if a handle is active.
internal bool IsActive()
{
return Internal_IsActive(mCachedPtr);
}
///
/// Deselects any currently active handles.
///
internal void ClearSelection()
{
Internal_ClearSelection(mCachedPtr);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_Create(SceneHandles managedInstance, IntPtr parentWindow, IntPtr camera);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_BeginInput();
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_EndInput();
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_UpdateInput(IntPtr thisPtr, ref Vector2I pointerPos, ref Vector2I inputDelta);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_Draw(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_TrySelect(IntPtr thisPtr, ref Vector2I pointerPos);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_IsActive(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_ClearSelection(IntPtr thisPtr);
}
/** @} */
}