// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2024 Kybernetik //
#if UNITY_EDITOR
using Animancer.TransitionLibraries;
using UnityEditor;
using UnityEngine;
namespace Animancer.Editor.TransitionLibraries
{
/// [Editor-Only]
/// An for configuring .
///
/// https://kybernetik.com.au/animancer/api/Animancer.Editor.TransitionLibraries/TransitionLibraryWindowHighlighter
public class TransitionLibraryWindowHighlighter
{
/************************************************************************************************************************/
private static readonly Color
SelectionHighlightColor = new(0.5f, 0.5f, 1, 0.1f),
HoverHighlightColor = new(0.5f, 1, 0.5f, 0.1f);
/************************************************************************************************************************/
/// The current .
public EventType EventType { get; private set; }
/// The the mouse currently over the highlighter area.
public bool IsMouseOver { get; private set; }
/// The the hover highlight currently visible.
public bool DidHoverHighlight { get; private set; }
/************************************************************************************************************************/
/// Gathers the details of the .
public void BeginGUI(Rect area)
{
var currentEvent = Event.current;
EventType = currentEvent.type;
IsMouseOver = area.Contains(currentEvent.mousePosition);
DidHoverHighlight = false;
}
/************************************************************************************************************************/
/// Repaints the `window` if necessary.
public void EndGUI(TransitionLibraryWindow window)
{
if (DidHoverHighlight && window != EditorWindow.mouseOverWindow)
{
DidHoverHighlight = false;
window.Repaint();
}
else if (EventType == EventType.MouseMove)
{
window.Repaint();
}
}
/************************************************************************************************************************/
/// Draws highlights for the `area`.
public void DrawHighlightGUI(Rect area, bool selected, bool hover)
{
if (selected)
{
EditorGUI.DrawRect(area, SelectionHighlightColor);
}
if (hover)
{
DidHoverHighlight = true;
EditorGUI.DrawRect(area, HoverHighlightColor);
}
}
/************************************************************************************************************************/
}
}
#endif