using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using BansheeEngine;
namespace BansheeEditor
{
///
/// Handles scene view handle interactions, object picking and gizmos.
///
internal sealed class SceneViewHandler : ScriptObject
{
///
/// Creates a new scene view handler.
///
/// Editor window in which the scene view is displayed.
/// Camera through which the scene view is displayed.
internal SceneViewHandler(EditorWindow parent, Camera sceneCamera)
{
Internal_Create(this, parent.GetCachedPtr(), sceneCamera.Native.GetCachedPtr());
}
///
/// Called every frame. Updates gizmos and scene grid.
///
internal void Update()
{
Internal_Update(mCachedPtr);
}
///
/// Updates currently active handles.
///
/// Position of the pointer relative to the scene camera viewport.
/// Movement of the pointer since last frame.
internal void UpdateHandle(Vector2I pointerPos, Vector2I inputDelta)
{
Internal_UpdateHandle(mCachedPtr, pointerPos, inputDelta);
}
///
/// Updates the selection overlay for currently selected object(s).
///
internal void UpdateSelection()
{
Internal_UpdateSelection(mCachedPtr);
}
///
/// Selects a handle under the pointer position.
///
/// Position of the pointer relative to the scene camera viewport.
internal void TrySelectHandle(Vector2I pointerPos)
{
Internal_TrySelectHandle(mCachedPtr, pointerPos);
}
///
/// Checks is any handle currently active.
///
/// True if a handle is active.
internal bool IsHandleActive()
{
return Internal_IsHandleActive(mCachedPtr);
}
///
/// Deselects any currently active handles.
///
internal void ClearHandleSelection()
{
Internal_ClearHandleSelection(mCachedPtr);
}
///
/// Attempts to select a scene object under the pointer position.
///
/// Position of the pointer relative to the scene camera viewport.
/// Should this selection add to the existing selection, or replace it.
internal void PickObject(Vector2I pointerPos, bool controlHeld)
{
Internal_PickObject(mCachedPtr, pointerPos, controlHeld);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_Create(SceneViewHandler managedInstance, IntPtr parentWindow, IntPtr camera);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_Update(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_UpdateHandle(IntPtr thisPtr, Vector2I pointerPos, Vector2I inputDelta);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_UpdateSelection(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_TrySelectHandle(IntPtr thisPtr, Vector2I pointerPos);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_IsHandleActive(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_ClearHandleSelection(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_PickObject(IntPtr thisPtr, Vector2I pointerPos, bool controlHeld);
}
}