diff --git a/Source/Editor/CustomEditors/Editors/CollectionEditor.cs b/Source/Editor/CustomEditors/Editors/CollectionEditor.cs
index 2e5aeade7..141330aea 100644
--- a/Source/Editor/CustomEditors/Editors/CollectionEditor.cs
+++ b/Source/Editor/CustomEditors/Editors/CollectionEditor.cs
@@ -154,9 +154,20 @@ namespace FlaxEditor.CustomEditors.Editors
if (i != 0 && spacing > 0f)
{
if (layout.Children.Count > 0 && layout.Children[layout.Children.Count - 1] is PropertiesListElement propertiesListElement)
+ {
+ if (propertiesListElement.Labels.Count > 0)
+ {
+ var label = propertiesListElement.Labels[propertiesListElement.Labels.Count - 1];
+ var margin = label.Margin;
+ margin.Bottom += spacing;
+ label.Margin = margin;
+ }
propertiesListElement.Space(spacing);
+ }
else
+ {
layout.Space(spacing);
+ }
}
var overrideEditor = overrideEditorType != null ? (CustomEditor)Activator.CreateInstance(overrideEditorType) : null;
diff --git a/Source/Editor/CustomEditors/Editors/DictionaryEditor.cs b/Source/Editor/CustomEditors/Editors/DictionaryEditor.cs
index 4e4048dba..4a94136db 100644
--- a/Source/Editor/CustomEditors/Editors/DictionaryEditor.cs
+++ b/Source/Editor/CustomEditors/Editors/DictionaryEditor.cs
@@ -61,7 +61,7 @@ namespace FlaxEditor.CustomEditors.Editors
var keyType = _editor.Values.Type.GetGenericArguments()[0];
if (keyType == typeof(string) || keyType.IsPrimitive)
{
- var popup = RenamePopup.Show(Parent, Bounds, Text, false);
+ var popup = RenamePopup.Show(Parent, Rectangle.Margin(Bounds, Margin), Text, false);
popup.Validate += (renamePopup, value) =>
{
object newKey;
@@ -86,7 +86,7 @@ namespace FlaxEditor.CustomEditors.Editors
}
else if (keyType.IsEnum)
{
- var popup = RenamePopup.Show(Parent, Bounds, Text, false);
+ var popup = RenamePopup.Show(Parent, Rectangle.Margin(Bounds, Margin), Text, false);
var picker = new EnumComboBox(keyType)
{
AnchorPreset = AnchorPresets.StretchAll,
@@ -220,9 +220,20 @@ namespace FlaxEditor.CustomEditors.Editors
if (i != 0 && spacing > 0f)
{
if (layout.Children.Count > 0 && layout.Children[layout.Children.Count - 1] is PropertiesListElement propertiesListElement)
+ {
+ if (propertiesListElement.Labels.Count > 0)
+ {
+ var label = propertiesListElement.Labels[propertiesListElement.Labels.Count - 1];
+ var margin = label.Margin;
+ margin.Bottom += spacing;
+ label.Margin = margin;
+ }
propertiesListElement.Space(spacing);
+ }
else
+ {
layout.Space(spacing);
+ }
}
var key = keys.ElementAt(i);
diff --git a/Source/Editor/CustomEditors/LayoutElementsContainer.cs b/Source/Editor/CustomEditors/LayoutElementsContainer.cs
index ae33599c1..6f645789a 100644
--- a/Source/Editor/CustomEditors/LayoutElementsContainer.cs
+++ b/Source/Editor/CustomEditors/LayoutElementsContainer.cs
@@ -112,7 +112,7 @@ namespace FlaxEditor.CustomEditors
OnAddElement(element);
return element;
}
-
+
///
/// Adds new horizontal panel element.
///
@@ -690,6 +690,17 @@ namespace FlaxEditor.CustomEditors
return element;
}
+ ///
+ /// Adds custom element to the layout.
+ ///
+ /// The element.
+ public void AddElement(LayoutElement element)
+ {
+ if (element == null)
+ throw new ArgumentNullException();
+ OnAddElement(element);
+ }
+
///
/// Called when element is added to the layout.
///
diff --git a/Source/Engine/Core/Math/Rectangle.cs b/Source/Engine/Core/Math/Rectangle.cs
index 50f9adce4..d1fb16abc 100644
--- a/Source/Engine/Core/Math/Rectangle.cs
+++ b/Source/Engine/Core/Math/Rectangle.cs
@@ -285,6 +285,19 @@ namespace FlaxEngine
return new Rectangle(Location - toExpand * 0.5f, Size + toExpand);
}
+ ///
+ /// Calculates a rectangle that includes the margins (inside).
+ ///
+ /// The rectangle.
+ /// The margin to apply to the rectangle.
+ /// Rectangle inside the given rectangle after applying margins inside it.
+ public static Rectangle Margin(Rectangle value, GUI.Margin margin)
+ {
+ value.Location += margin.Location;
+ value.Size -= margin.Size;
+ return value;
+ }
+
///
/// Calculates a rectangle that contains the union of a and b rectangles
///