// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
using FlaxEngine;
using FlaxEngine.GUI;
namespace FlaxEditor.GUI.ContextMenu
{
///
/// Context Menu child control.
///
///
[HideInEditor]
public abstract class ContextMenuItem : ContainerControl
{
///
/// Gets the parent context menu.
///
public ContextMenu ParentContextMenu { get; }
///
/// Gets the minimum width of this item.
///
public virtual float MinimumWidth
{
get
{
float width = 0;
for (int i = 0; i < _children.Count; i++)
{
var c = _children[i];
if (c.Visible)
{
width = Mathf.Max(width, c.Right + 4.0f);
}
}
return width;
}
}
///
/// Initializes a new instance of the class.
///
/// The parent context menu.
/// The initial width.
/// The initial height.
protected ContextMenuItem(ContextMenu parent, float width, float height)
: base(0, 0, width, height)
{
AutoFocus = false;
ParentContextMenu = parent;
}
///
public override void OnMouseEnter(Vector2 location)
{
ParentContextMenu?.HideChild();
base.OnMouseEnter(location);
}
}
}