Files
FlaxEngine/Source/Editor/CustomEditors/Elements/Container/GroupElement.cs
Saas 48100cf9fc fix group element text clipping
fixes group element header text clipping outside of the header and into the settings icon (if there is one).
Also some extra code to handle script editor, as that displays some extra icons in the header.
2025-10-13 11:16:07 +02:00

63 lines
2.2 KiB
C#

// Copyright (c) Wojciech Figat. All rights reserved.
using System;
using FlaxEditor.GUI.ContextMenu;
using FlaxEngine;
using FlaxEngine.GUI;
namespace FlaxEditor.CustomEditors.Elements
{
/// <summary>
/// The layout group element.
/// </summary>
/// <seealso cref="FlaxEditor.CustomEditors.LayoutElement" />
public class GroupElement : LayoutElementsContainer
{
/// <summary>
/// The drop panel.
/// </summary>
public readonly DropPanel Panel = new DropPanel
{
Pivot = Float2.Zero,
ArrowImageClosed = new SpriteBrush(Style.Current.ArrowRight),
ArrowImageOpened = new SpriteBrush(Style.Current.ArrowDown),
EnableDropDownIcon = true,
ItemsMargin = new Margin(Utilities.Constants.UIMargin),
ItemsSpacing = Utilities.Constants.UIMargin,
HeaderHeight = 18.0f,
EnableContainmentLines = true,
};
/// <summary>
/// Event is fired if the group can setup a context menu and the context menu is being setup.
/// </summary>
public Action<ContextMenu, DropPanel> SetupContextMenu;
/// <inheritdoc />
public override ContainerControl ContainerControl => Panel;
/// <summary>
/// Adds utility settings button to the group header.
/// </summary>
/// <returns>The created control.</returns>
public Image AddSettingsButton()
{
var style = Style.Current;
var settingsButtonSize = Panel.HeaderHeight;
Panel.HeaderTextMargin = Panel.HeaderTextMargin with { Right = settingsButtonSize + Utilities.Constants.UIMargin };
; return new Image
{
TooltipText = "Settings",
AutoFocus = true,
AnchorPreset = AnchorPresets.TopRight,
Parent = Panel,
Bounds = new Rectangle(Panel.Width - settingsButtonSize, 0, settingsButtonSize, settingsButtonSize),
IsScrollable = false,
Color = style.ForegroundGrey,
Margin = new Margin(1),
Brush = new SpriteBrush(style.Settings),
};
}
}
}