Merge remote-tracking branch 'origin/master' into 1.9
# Conflicts: # Source/Editor/Modules/ContentDatabaseModule.cs # Source/Editor/Surface/SurfaceUtils.cs # Source/Editor/Windows/Assets/MaterialInstanceWindow.cs # Source/Engine/Foliage/Foliage.cpp # Source/Engine/Graphics/Models/MeshBase.h # Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Textures.cpp
This commit is contained in:
@@ -123,10 +123,10 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
_linkButton.Clicked += ToggleLink;
|
||||
ToggleEnabled();
|
||||
SetLinkStyle();
|
||||
var textSize = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText(LinkedLabel.Text.Value);
|
||||
_linkButton.LocalX += textSize.X + 10;
|
||||
if (LinkedLabel != null)
|
||||
{
|
||||
var textSize = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText(LinkedLabel.Text.Value);
|
||||
_linkButton.LocalX += textSize.X + 10;
|
||||
LinkedLabel.SetupContextMenu += (label, menu, editor) =>
|
||||
{
|
||||
menu.AddSeparator();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using FlaxEditor.CustomEditors.Elements;
|
||||
using FlaxEditor.GUI;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.GUI;
|
||||
@@ -39,20 +40,27 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
public override void Initialize(LayoutElementsContainer layout)
|
||||
{
|
||||
Window = layout.Control.RootWindow.Window;
|
||||
var panelElement = layout.CustomContainer<Panel>();
|
||||
var panel = panelElement.ContainerControl as Panel;
|
||||
|
||||
var panel = layout.CustomContainer<UniformGridPanel>();
|
||||
panel.CustomControl.SlotsHorizontally = 2;
|
||||
panel.CustomControl.SlotsVertically = 1;
|
||||
|
||||
var button = panel.Button("Listen", "Press to listen for input events");
|
||||
var button = panelElement.Button("Listen", "Press to listen for input events");
|
||||
_button = button.Button;
|
||||
_button.Width = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText("Listening...").X + 8;
|
||||
_button.Height = ComboBox.DefaultHeight;
|
||||
_button.Clicked += OnButtonClicked;
|
||||
ResetButton();
|
||||
|
||||
var padding = panel.CustomControl.SlotPadding;
|
||||
panel.CustomControl.Height = ComboBox.DefaultHeight + padding.Height;
|
||||
panel.Height = ComboBox.DefaultHeight;
|
||||
|
||||
base.Initialize(panel);
|
||||
base.Initialize(panelElement);
|
||||
|
||||
if (panelElement.Children.Find(x => x is EnumElement) is EnumElement comboBoxElement)
|
||||
{
|
||||
var comboBox = comboBoxElement.ComboBox;
|
||||
comboBox.AnchorPreset = AnchorPresets.StretchAll;
|
||||
comboBox.Offsets = new Margin(0, _button.Width + 2, 0, 0);
|
||||
comboBox.LocalX += _button.Width + 2;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -2,14 +2,18 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FlaxEditor.CustomEditors.GUI;
|
||||
using FlaxEditor.GUI.Input;
|
||||
using FlaxEditor.Content;
|
||||
using FlaxEditor.CustomEditors.Elements;
|
||||
using FlaxEditor.GUI.ContextMenu;
|
||||
using FlaxEditor.GUI.Drag;
|
||||
using FlaxEditor.SceneGraph;
|
||||
using FlaxEditor.Scripting;
|
||||
using FlaxEditor.Windows;
|
||||
using FlaxEditor.Windows.Assets;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.GUI;
|
||||
using FlaxEngine.Utilities;
|
||||
@@ -53,7 +57,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
Index = index;
|
||||
|
||||
SetupContextMenu += OnSetupContextMenu;
|
||||
_arrangeButtonRect = new Rectangle(2, 3, 12, 12);
|
||||
_arrangeButtonRect = new Rectangle(2, 4, 12, 12);
|
||||
|
||||
// Extend margin of the label to support a dragging handle.
|
||||
Margin m = Margin;
|
||||
@@ -75,7 +79,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
|
||||
b = menu.AddButton("Move down", OnMoveDownClicked);
|
||||
b.Enabled = Index + 1 < Editor.Count && !Editor._readOnly;
|
||||
|
||||
|
||||
b = menu.AddButton("Remove", OnRemoveClicked);
|
||||
b.Enabled = !Editor._readOnly;
|
||||
}
|
||||
@@ -88,13 +92,12 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
_arrangeButtonInUse = false;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Draw()
|
||||
{
|
||||
base.Draw();
|
||||
var style = FlaxEngine.GUI.Style.Current;
|
||||
|
||||
var style = FlaxEngine.GUI.Style.Current;
|
||||
var mousePosition = PointFromScreen(Input.MouseScreenPosition);
|
||||
var dragBarColor = _arrangeButtonRect.Contains(mousePosition) ? style.Foreground : style.ForegroundGrey;
|
||||
Render2D.DrawSprite(FlaxEditor.Editor.Instance.Icons.DragBar12, _arrangeButtonRect, _arrangeButtonInUse ? Color.Orange : dragBarColor);
|
||||
@@ -104,6 +107,14 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnSizeChanged()
|
||||
{
|
||||
base.OnSizeChanged();
|
||||
|
||||
_arrangeButtonRect.Y = (Height - _arrangeButtonRect.Height) * 0.5f;
|
||||
}
|
||||
|
||||
private bool ArrangeAreaCheck(out int index, out Rectangle rect)
|
||||
{
|
||||
var child = Editor.ChildrenEditors[0];
|
||||
@@ -228,7 +239,38 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
ArrowImageClosed = new SpriteBrush(icons.ArrowRight12);
|
||||
ArrowImageOpened = new SpriteBrush(icons.ArrowDown12);
|
||||
HeaderText = $"Element {index}";
|
||||
IsClosed = false;
|
||||
|
||||
string saveName = string.Empty;
|
||||
if (editor.Presenter?.Owner is PropertiesWindow propertiesWindow)
|
||||
{
|
||||
var selection = FlaxEditor.Editor.Instance.SceneEditing.Selection[0];
|
||||
if (selection != null)
|
||||
{
|
||||
saveName += $"{selection.ID},";
|
||||
}
|
||||
}
|
||||
else if (editor.Presenter?.Owner is PrefabWindow prefabWindow)
|
||||
{
|
||||
var selection = prefabWindow.Selection[0];
|
||||
if (selection != null)
|
||||
{
|
||||
saveName += $"{selection.ID},";
|
||||
}
|
||||
}
|
||||
if (editor.ParentEditor?.Layout.ContainerControl is DropPanel pdp)
|
||||
{
|
||||
saveName += $"{pdp.HeaderText},";
|
||||
}
|
||||
if (editor.Layout.ContainerControl is DropPanel mainGroup)
|
||||
{
|
||||
saveName += $"{mainGroup.HeaderText}";
|
||||
IsClosed = FlaxEditor.Editor.Instance.ProjectCache.IsGroupToggled($"{saveName}:{index}");
|
||||
}
|
||||
else
|
||||
{
|
||||
IsClosed = false;
|
||||
}
|
||||
|
||||
Editor = editor;
|
||||
Index = index;
|
||||
Offsets = new Margin(7, 7, 0, 0);
|
||||
@@ -239,6 +281,37 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
HeaderTextMargin = new Margin(18, 0, 0, 0);
|
||||
_arrangeButtonRect = new Rectangle(16, 3, 12, 12);
|
||||
}
|
||||
IsClosedChanged += OnIsClosedChanged;
|
||||
}
|
||||
|
||||
private void OnIsClosedChanged(DropPanel panel)
|
||||
{
|
||||
string saveName = string.Empty;
|
||||
if (Editor.Presenter?.Owner is PropertiesWindow pw)
|
||||
{
|
||||
var selection = FlaxEditor.Editor.Instance.SceneEditing.Selection[0];
|
||||
if (selection != null)
|
||||
{
|
||||
saveName += $"{selection.ID},";
|
||||
}
|
||||
}
|
||||
else if (Editor.Presenter?.Owner is PrefabWindow prefabWindow)
|
||||
{
|
||||
var selection = prefabWindow.Selection[0];
|
||||
if (selection != null)
|
||||
{
|
||||
saveName += $"{selection.ID},";
|
||||
}
|
||||
}
|
||||
if (Editor.ParentEditor?.Layout.ContainerControl is DropPanel pdp)
|
||||
{
|
||||
saveName += $"{pdp.HeaderText},";
|
||||
}
|
||||
if (Editor.Layout.ContainerControl is DropPanel mainGroup)
|
||||
{
|
||||
saveName += $"{mainGroup.HeaderText}";
|
||||
FlaxEditor.Editor.Instance.ProjectCache.SetGroupToggle($"{saveName}:{Index}", panel.IsClosed);
|
||||
}
|
||||
}
|
||||
|
||||
private bool ArrangeAreaCheck(out int index, out Rectangle rect)
|
||||
@@ -278,10 +351,10 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
public override void Draw()
|
||||
{
|
||||
base.Draw();
|
||||
|
||||
if (_canReorder)
|
||||
{
|
||||
var style = FlaxEngine.GUI.Style.Current;
|
||||
|
||||
var mousePosition = PointFromScreen(Input.MouseScreenPosition);
|
||||
var dragBarColor = _arrangeButtonRect.Contains(mousePosition) ? style.Foreground : style.ForegroundGrey;
|
||||
Render2D.DrawSprite(FlaxEditor.Editor.Instance.Icons.DragBar12, _arrangeButtonRect, _arrangeButtonInUse ? Color.Orange : dragBarColor);
|
||||
@@ -377,6 +450,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
private bool _canResize;
|
||||
private bool _canReorderItems;
|
||||
private CollectionAttribute.DisplayType _displayType;
|
||||
private List<CollectionDropPanel> _cachedDropPanels = new List<CollectionDropPanel>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the length of the collection.
|
||||
@@ -519,6 +593,10 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
(elementType.GetProperties().Length == 1 && elementType.GetFields().Length == 0) ||
|
||||
elementType.Equals(new ScriptType(typeof(JsonAsset))) ||
|
||||
elementType.Equals(new ScriptType(typeof(SettingsBase)));
|
||||
if (_cachedDropPanels == null)
|
||||
_cachedDropPanels = new List<CollectionDropPanel>();
|
||||
else
|
||||
_cachedDropPanels.Clear();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
// Apply spacing
|
||||
@@ -542,6 +620,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
else if (_displayType == CollectionAttribute.DisplayType.Header || (_displayType == CollectionAttribute.DisplayType.Default && !single))
|
||||
{
|
||||
var cdp = panel.CustomContainer<CollectionDropPanel>();
|
||||
_cachedDropPanels.Add(cdp.CustomControl);
|
||||
cdp.CustomControl.Setup(this, i, _canReorderItems);
|
||||
var itemLayout = cdp.VerticalPanel();
|
||||
cdp.CustomControl.LinkedEditor = itemLayout.Object(new ListValueContainer(elementType, i, Values, attributes), overrideEditor);
|
||||
@@ -549,6 +628,12 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
GenericEditor.OnReadOnlyProperty(itemLayout);
|
||||
}
|
||||
}
|
||||
|
||||
if (_displayType == CollectionAttribute.DisplayType.Header || (_displayType == CollectionAttribute.DisplayType.Default && !single))
|
||||
{
|
||||
if (Layout is GroupElement g)
|
||||
g.SetupContextMenu += OnSetupContextMenu;
|
||||
}
|
||||
}
|
||||
_elementsCount = size;
|
||||
|
||||
@@ -583,6 +668,28 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSetupContextMenu(ContextMenu menu, DropPanel panel)
|
||||
{
|
||||
if (menu.Items.Any(x => x is ContextMenuButton b && b.Text.Equals("Open All", StringComparison.Ordinal)))
|
||||
return;
|
||||
|
||||
menu.AddSeparator();
|
||||
menu.AddButton("Open All", () =>
|
||||
{
|
||||
foreach (var cachedPanel in _cachedDropPanels)
|
||||
{
|
||||
cachedPanel.IsClosed = false;
|
||||
}
|
||||
});
|
||||
menu.AddButton("Close All", () =>
|
||||
{
|
||||
foreach (var cachedPanel in _cachedDropPanels)
|
||||
{
|
||||
cachedPanel.IsClosed = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Deinitialize()
|
||||
{
|
||||
@@ -663,7 +770,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
cloned[i] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SetValue(cloned);
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +208,9 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
else
|
||||
{
|
||||
// Draw info
|
||||
Render2D.PushClip(nameRect);
|
||||
Render2D.DrawText(style.FontMedium, Type != null ? $"None ({Utilities.Utils.GetPropertyNameUI(Type.ToString())})" : "-", nameRect, isEnabled ? style.ForegroundGrey : style.ForegroundGrey.AlphaMultiplied(0.75f), TextAlignment.Near, TextAlignment.Center);
|
||||
Render2D.PopClip();
|
||||
}
|
||||
|
||||
// Draw picker button
|
||||
|
||||
@@ -569,19 +569,19 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
|
||||
internal static void OnReadOnlyProperty(LayoutElementsContainer itemLayout, int labelIndex = -1)
|
||||
{
|
||||
PropertiesListElement list = null;
|
||||
PropertiesList list = null;
|
||||
int firstChildControlIndex = 0;
|
||||
bool disableSingle = true;
|
||||
var control = itemLayout.Children[itemLayout.Children.Count - 1];
|
||||
if (control is GroupElement group && group.Children.Count > 0)
|
||||
{
|
||||
list = group.Children[0] as PropertiesListElement;
|
||||
list = (group.Children[0] as PropertiesListElement)?.Properties;
|
||||
disableSingle = false; // Disable all nested editors
|
||||
}
|
||||
else if (control is PropertiesListElement list1 && labelIndex != -1)
|
||||
{
|
||||
list = list1;
|
||||
firstChildControlIndex = list.Labels[labelIndex].FirstChildControlIndex;
|
||||
list = list1.Labels[labelIndex].FirstChildControlContainer ?? list1.Properties;
|
||||
firstChildControlIndex = list1.Labels[labelIndex].FirstChildControlIndex;
|
||||
}
|
||||
else if (control?.Control != null)
|
||||
{
|
||||
@@ -591,10 +591,10 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
if (list != null)
|
||||
{
|
||||
// Disable controls added to the editor
|
||||
var count = list.Properties.Children.Count;
|
||||
var count = list.Children.Count;
|
||||
for (int j = firstChildControlIndex; j < count; j++)
|
||||
{
|
||||
var child = list.Properties.Children[j];
|
||||
var child = list.Children[j];
|
||||
if (disableSingle && child is PropertyNameLabel)
|
||||
break;
|
||||
|
||||
|
||||
@@ -50,7 +50,6 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (_element == null)
|
||||
{
|
||||
// Use int value editor
|
||||
var element = layout.IntegerValue();
|
||||
|
||||
@@ -33,10 +33,10 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
if (layout.Children.Count == 0)
|
||||
return;
|
||||
var propList = layout.Children[layout.Children.Count - 1] as PropertiesListElement;
|
||||
if (propList == null || propList.Children.Count != 2)
|
||||
if (propList == null || propList.Children.Count < 2)
|
||||
return;
|
||||
var idElement = propList.Children[0] as TextBoxElement;
|
||||
var valueElement = propList.Children[1] as TextBoxElement;
|
||||
var idElement = propList.Children[propList.Children.Count - 2] as TextBoxElement;
|
||||
var valueElement = propList.Children[propList.Children.Count - 1] as TextBoxElement;
|
||||
if (idElement == null || valueElement == null)
|
||||
return;
|
||||
_idElement = idElement;
|
||||
|
||||
Reference in New Issue
Block a user