Merge commit '997baa3b774ac4dea739e15a55070519b0863afc' into dotnet7

This commit is contained in:
Wojtek Figat
2023-01-25 20:13:34 +01:00
28 changed files with 69 additions and 44 deletions

View File

@@ -94,7 +94,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
{
if (actor != null)
group.Panel.TooltipText = Surface.SurfaceUtils.GetVisualScriptTypeDescription(TypeUtils.GetObjectType(actor));
const float settingsButtonSize = 14;
float settingsButtonSize = group.Panel.HeaderHeight;
var settingsButton = new Image
{
TooltipText = "Settings",

View File

@@ -635,22 +635,22 @@ namespace FlaxEditor.CustomEditors.Dedicated
group.Panel.HeaderTextColor = FlaxEngine.GUI.Style.Current.ProgressNormal;
// Add toggle button to the group
var headerHeight = group.Panel.HeaderHeight;
var scriptToggle = new CheckBox
{
TooltipText = "If checked, script will be enabled.",
IsScrollable = false,
Checked = script.Enabled,
Parent = group.Panel,
Size = new Float2(14, 14),
Bounds = new Rectangle(2, 0, 14, 14),
BoxSize = 12.0f,
Size = new Float2(headerHeight),
Bounds = new Rectangle(headerHeight, 0, headerHeight, headerHeight),
BoxSize = headerHeight - 4.0f,
Tag = script,
};
scriptToggle.StateChanged += OnScriptToggleCheckChanged;
_scriptToggles[i] = scriptToggle;
// Add drag button to the group
const float dragIconSize = 14;
var scriptDrag = new ScriptDragIcon(this, script)
{
TooltipText = "Script reference",
@@ -658,21 +658,20 @@ namespace FlaxEditor.CustomEditors.Dedicated
IsScrollable = false,
Color = FlaxEngine.GUI.Style.Current.ForegroundGrey,
Parent = group.Panel,
Bounds = new Rectangle(scriptToggle.Right, 0.5f, dragIconSize, dragIconSize),
Bounds = new Rectangle(scriptToggle.Right, 0.5f, headerHeight, headerHeight),
Margin = new Margin(1),
Brush = new SpriteBrush(Editor.Instance.Icons.DragBar12),
Tag = script,
};
// Add settings button to the group
const float settingsButtonSize = 14;
var settingsButton = new Image
{
TooltipText = "Settings",
AutoFocus = true,
AnchorPreset = AnchorPresets.TopRight,
Parent = group.Panel,
Bounds = new Rectangle(group.Panel.Width - settingsButtonSize, 0, settingsButtonSize, settingsButtonSize),
Bounds = new Rectangle(group.Panel.Width - headerHeight, 0, headerHeight, headerHeight),
IsScrollable = false,
Color = FlaxEngine.GUI.Style.Current.ForegroundGrey,
Margin = new Margin(1),
@@ -681,7 +680,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
};
settingsButton.Clicked += OnSettingsButtonClicked;
group.Panel.HeaderTextMargin = new Margin(scriptDrag.Right, 15, 2, 2);
group.Panel.HeaderTextMargin = new Margin(scriptDrag.Right - 12, 15, 2, 2);
group.Object(values, editor);
// Scripts arrange bar

View File

@@ -13,7 +13,15 @@ namespace FlaxEditor.CustomEditors.Elements
/// <summary>
/// The drop panel.
/// </summary>
public readonly DropPanel Panel = new DropPanel();
public readonly DropPanel Panel = new DropPanel
{
ArrowImageClosed = new SpriteBrush(Style.Current.ArrowRight),
ArrowImageOpened = new SpriteBrush(Style.Current.ArrowDown),
EnableDropDownIcon = true,
ItemsMargin = new Margin(7, 7, 3, 3),
HeaderHeight = 18.0f,
EnableContainmentLines = true,
};
/// <inheritdoc />
public override ContainerControl ContainerControl => Panel;

View File

@@ -96,6 +96,7 @@ namespace FlaxEditor.CustomEditors
if (useTransparentHeader)
{
element.Panel.EnableDropDownIcon = true;
element.Panel.EnableContainmentLines = false;
element.Panel.HeaderColor = element.Panel.HeaderColorMouseOver = Color.Transparent;
}
OnAddElement(element);

View File

@@ -177,6 +177,7 @@ namespace FlaxEditor.GUI
/// <inheritdoc />
protected override void OnShow()
{
_inputField.EndEditOnClick = false; // Ending edit is handled through popup
_inputField.Focus();
_inputField.SelectAll();

View File

@@ -15,7 +15,7 @@ namespace FlaxEditor.Utilities
/// <summary>
/// The minimum text match length.
/// </summary>
public const int MinLength = 2;
public const int MinLength = 1;
/// <summary>
/// Matches the specified text with the filter.

View File

@@ -253,7 +253,7 @@ namespace FlaxEditor.Windows.Assets
if (actorType.IsAbstract)
continue;
ActorContextMenuAttribute attribute = null;
foreach (var e in actorType.GetAttributes(true))
foreach (var e in actorType.GetAttributes(false))
{
if (e is ActorContextMenuAttribute actorContextMenuAttribute)
{

View File

@@ -162,7 +162,7 @@ namespace FlaxEditor.Windows
// Get attribute
ContentContextMenuAttribute attribute = null;
foreach (var typeAttribute in type.GetAttributes(true))
foreach (var typeAttribute in type.GetAttributes(false))
{
if (typeAttribute is ContentContextMenuAttribute contentContextMenuAttribute)
{

View File

@@ -66,7 +66,7 @@ namespace FlaxEditor.Windows
if (actorType.IsAbstract)
continue;
ActorContextMenuAttribute attribute = null;
foreach (var e in actorType.GetAttributes(true))
foreach (var e in actorType.GetAttributes(false))
{
if (e is ActorContextMenuAttribute actorContextMenuAttribute)
{
@@ -152,11 +152,11 @@ namespace FlaxEditor.Windows
// go through each actor and add it to the context menu if it has the ActorContextMenu attribute
foreach (var actorType in Editor.CodeEditing.Actors.Get())
{
if (actorType.IsAbstract || !actorType.HasAttribute(typeof(ActorContextMenuAttribute), true))
if (actorType.IsAbstract || !actorType.HasAttribute(typeof(ActorContextMenuAttribute), false))
continue;
ActorContextMenuAttribute attribute = null;
foreach (var actorAttribute in actorType.GetAttributes(true))
foreach (var actorAttribute in actorType.GetAttributes(false))
{
if (actorAttribute is ActorContextMenuAttribute actorContextMenuAttribute)
{

View File

@@ -250,7 +250,7 @@ namespace FlaxEditor.Windows
foreach (var actorType in Editor.CodeEditing.Actors.Get())
{
ActorToolboxAttribute attribute = null;
foreach (var e in actorType.GetAttributes(true))
foreach (var e in actorType.GetAttributes(false))
{
if (e is ActorToolboxAttribute actorToolboxAttribute)
{

View File

@@ -10,7 +10,7 @@
/// Representation of the car vehicle that uses wheels. Built on top of the RigidBody with collider representing its chassis shape and wheels.
/// </summary>
/// <seealso cref="RigidBody" />
API_CLASS() class FLAXENGINE_API WheeledVehicle : public RigidBody
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Wheeled Vehicle\"), ActorToolbox(\"Physics\")") class FLAXENGINE_API WheeledVehicle : public RigidBody
{
friend class PhysicsBackend;
DECLARE_SCENE_OBJECT(WheeledVehicle);

View File

@@ -9,7 +9,7 @@
/// A box-shaped primitive collider.
/// </summary>
/// <seealso cref="Collider" />
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Box Collider\"), ActorToolbox(\"Physics\")")
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Colliders/Box Collider\"), ActorToolbox(\"Physics\")")
class FLAXENGINE_API BoxCollider : public Collider
{
DECLARE_SCENE_OBJECT(BoxCollider);

View File

@@ -10,7 +10,7 @@
/// </summary>
/// <remarks>Capsules are cylinders with a half-sphere at each end centered at the origin and extending along the X axis, and two hemispherical ends.</remarks>
/// <seealso cref="Collider" />
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Capsule Collider\"), ActorToolbox(\"Physics\")")
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Colliders/Capsule Collider\"), ActorToolbox(\"Physics\")")
class FLAXENGINE_API CapsuleCollider : public Collider
{
DECLARE_SCENE_OBJECT(CapsuleCollider);

View File

@@ -10,7 +10,7 @@
/// A collider represented by an arbitrary mesh.
/// </summary>
/// <seealso cref="Collider" />
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Mesh Collider\"), ActorToolbox(\"Physics\")")
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Colliders/Mesh Collider\"), ActorToolbox(\"Physics\")")
class FLAXENGINE_API MeshCollider : public Collider
{
DECLARE_SCENE_OBJECT(MeshCollider);

View File

@@ -8,7 +8,7 @@
/// A sphere-shaped primitive collider.
/// </summary>
/// <seealso cref="Collider" />
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Sphere Collider\"), ActorToolbox(\"Physics\")")
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Colliders/Sphere Collider\"), ActorToolbox(\"Physics\")")
class FLAXENGINE_API SphereCollider : public Collider
{
DECLARE_SCENE_OBJECT(SphereCollider);

View File

@@ -160,7 +160,7 @@ public:
/// It also allows you to constrain limits to only specific axes or completely lock specific axes.
/// </summary>
/// <seealso cref="Joint" />
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/D6 Joint\"), ActorToolbox(\"Physics\")")
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Joints/D6 Joint\"), ActorToolbox(\"Physics\")")
class FLAXENGINE_API D6Joint : public Joint
{
DECLARE_SCENE_OBJECT(D6Joint);

View File

@@ -37,7 +37,7 @@ DECLARE_ENUM_OPERATORS(DistanceJointFlag);
/// Physics joint that maintains an upper or lower (or both) bound on the distance between two bodies.
/// </summary>
/// <seealso cref="Joint" />
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Distance Joint\"), ActorToolbox(\"Physics\")")
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Joints/Distance Joint\"), ActorToolbox(\"Physics\")")
class FLAXENGINE_API DistanceJoint : public Joint
{
DECLARE_SCENE_OBJECT(DistanceJoint);

View File

@@ -8,7 +8,7 @@
/// Physics joint that maintains a fixed distance and orientation between its two attached bodies.
/// </summary>
/// <seealso cref="Joint" />
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Fixed Joint\"), ActorToolbox(\"Physics\")")
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Joints/Fixed Joint\"), ActorToolbox(\"Physics\")")
class FLAXENGINE_API FixedJoint : public Joint
{
DECLARE_SCENE_OBJECT(FixedJoint);

View File

@@ -67,7 +67,7 @@ public:
/// Physics joint that removes all but a single rotation degree of freedom from its two attached bodies (for example a door hinge).
/// </summary>
/// <seealso cref="Joint" />
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Hinge Joint\"), ActorToolbox(\"Physics\")")
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Joints/Hinge Joint\"), ActorToolbox(\"Physics\")")
class FLAXENGINE_API HingeJoint : public Joint
{
DECLARE_SCENE_OBJECT(HingeJoint);

View File

@@ -27,7 +27,7 @@ DECLARE_ENUM_OPERATORS(SliderJointFlag);
/// Physics joint that removes all but a single translational degree of freedom. Bodies are allowed to move along a single axis.
/// </summary>
/// <seealso cref="Joint" />
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Slider Joint\"), ActorToolbox(\"Physics\")")
API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Joints/Slider Joint\"), ActorToolbox(\"Physics\")")
class FLAXENGINE_API SliderJoint : public Joint
{
DECLARE_SCENE_OBJECT(SliderJoint);

View File

@@ -29,7 +29,7 @@ DECLARE_ENUM_OPERATORS(SphericalJointFlag);
/// rotate around the anchor points, and their rotation can be limited by an elliptical cone.
/// </summary>
/// <seealso cref="Joint" />
API_CLASS(Attributes = "ActorContextMenu(\"New/Physics/Spherical Joint\"), ActorToolbox(\"Physics\")")
API_CLASS(Attributes = "ActorContextMenu(\"New/Physics/Joints/Spherical Joint\"), ActorToolbox(\"Physics\")")
class FLAXENGINE_API SphericalJoint : public Joint
{
DECLARE_SCENE_OBJECT(SphericalJoint);

View File

@@ -131,6 +131,12 @@ namespace FlaxEngine.GUI
[EditorDisplay("Style"), EditorOrder(2000)]
public bool EnableDropDownIcon { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to enable containment line drawing,
/// </summary>
[EditorDisplay("Style"), EditorOrder(2000)]
public bool EnableContainmentLines { get; set; } = false;
/// <summary>
/// Occurs when mouse right-clicks over the header.
/// </summary>
@@ -370,6 +376,16 @@ namespace FlaxEngine.GUI
Render2D.DrawText(HeaderTextFont.GetFont(), HeaderTextMaterial, HeaderText, textRect, textColor, TextAlignment.Near, TextAlignment.Center);
if (!_isClosed && EnableContainmentLines)
{
Color lineColor = Style.Current.ForegroundGrey - new Color(0, 0, 0, 100);
float lineThickness = 0.05f;
Render2D.DrawLine(new Float2(1, HeaderHeight), new Float2(1, Height), lineColor, lineThickness);
Render2D.DrawLine(new Float2(1, Height), new Float2(Width, Height), lineColor, lineThickness);
Render2D.DrawLine(new Float2(Width, HeaderHeight), new Float2(Width, Height), lineColor, lineThickness);
}
// Children
DrawChildren();
}

View File

@@ -17,8 +17,8 @@ MMethod* UICanvas_Serialize = nullptr;
MMethod* UICanvas_SerializeDiff = nullptr;
MMethod* UICanvas_Deserialize = nullptr;
MMethod* UICanvas_PostDeserialize = nullptr;
MMethod* UICanvas_OnEnable = nullptr;
MMethod* UICanvas_OnDisable = nullptr;
MMethod* UICanvas_Enable = nullptr;
MMethod* UICanvas_Disable = nullptr;
#if USE_EDITOR
MMethod* UICanvas_OnActiveInTreeChanged = nullptr;
#endif
@@ -51,8 +51,8 @@ UICanvas::UICanvas(const SpawnParams& params)
UICanvas_SerializeDiff = mclass->GetMethod("SerializeDiff", 1);
UICanvas_Deserialize = mclass->GetMethod("Deserialize", 1);
UICanvas_PostDeserialize = mclass->GetMethod("PostDeserialize");
UICanvas_OnEnable = mclass->GetMethod("OnEnable");
UICanvas_OnDisable = mclass->GetMethod("OnDisable");
UICanvas_Enable = mclass->GetMethod("Enable");
UICanvas_Disable = mclass->GetMethod("Disable");
#if USE_EDITOR
UICanvas_OnActiveInTreeChanged = mclass->GetMethod("OnActiveInTreeChanged");
#endif
@@ -163,7 +163,7 @@ void UICanvas::OnParentChanged()
void UICanvas::OnEnable()
{
UICANVAS_INVOKE(OnEnable);
UICANVAS_INVOKE(Enable);
// Base
Actor::OnEnable();
@@ -174,7 +174,7 @@ void UICanvas::OnDisable()
// Base
Actor::OnDisable();
UICANVAS_INVOKE(OnDisable);
UICANVAS_INVOKE(Disable);
}
void UICanvas::OnTransformChanged()

View File

@@ -763,7 +763,7 @@ namespace FlaxEngine
#endif
}
internal void OnEnable()
internal void Enable()
{
#if FLAX_EDITOR
if (_editorRoot != null)
@@ -792,7 +792,7 @@ namespace FlaxEngine
}
}
internal void OnDisable()
internal void Disable()
{
_guiRoot.Parent = null;