Add CreateSearchPopup to editor utils
This commit is contained in:
@@ -113,32 +113,8 @@ namespace FlaxEditor.CustomEditors.Editors
|
|||||||
|
|
||||||
internal static ContextMenuBase CreatePicker(CultureInfo value, Action<CultureInfo> changed)
|
internal static ContextMenuBase CreatePicker(CultureInfo value, Action<CultureInfo> changed)
|
||||||
{
|
{
|
||||||
var menu = new ContextMenuBase
|
var menu = Utilities.Utils.CreateSearchPopup(out var searchBox, out var tree);
|
||||||
{
|
tree.Margin = new Margin(-16.0f, 0.0f, -16.0f, -0.0f); // Hide root node
|
||||||
Size = new Vector2(320, 220),
|
|
||||||
};
|
|
||||||
var searchBox = new TextBox(false, 1, 1)
|
|
||||||
{
|
|
||||||
Width = menu.Width - 3,
|
|
||||||
WatermarkText = "Search...",
|
|
||||||
Parent = menu
|
|
||||||
};
|
|
||||||
var panel1 = new Panel(ScrollBars.Vertical)
|
|
||||||
{
|
|
||||||
Bounds = new Rectangle(0, searchBox.Bottom + 1, menu.Width, menu.Height - searchBox.Bottom - 2),
|
|
||||||
Parent = menu
|
|
||||||
};
|
|
||||||
var panel2 = new VerticalPanel
|
|
||||||
{
|
|
||||||
Parent = panel1,
|
|
||||||
AnchorPreset = AnchorPresets.HorizontalStretchTop,
|
|
||||||
IsScrollable = true,
|
|
||||||
};
|
|
||||||
var tree = new Tree(false)
|
|
||||||
{
|
|
||||||
Parent = panel2,
|
|
||||||
Margin = new Margin(-16.0f, 0.0f, -16.0f, -0.0f), // Hide root node
|
|
||||||
};
|
|
||||||
var root = tree.AddChild<TreeNode>();
|
var root = tree.AddChild<TreeNode>();
|
||||||
var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
|
var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
|
||||||
Array.Sort(cultures, 1, cultures.Length - 2, new CultureInfoComparer()); // at 0 there is Invariant Culture
|
Array.Sort(cultures, 1, cultures.Length - 2, new CultureInfoComparer()); // at 0 there is Invariant Culture
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using FlaxEditor.GUI.ContextMenu;
|
||||||
|
using FlaxEditor.GUI.Tree;
|
||||||
using FlaxEditor.SceneGraph;
|
using FlaxEditor.SceneGraph;
|
||||||
using FlaxEditor.Scripting;
|
using FlaxEditor.Scripting;
|
||||||
using FlaxEngine;
|
using FlaxEngine;
|
||||||
@@ -1880,5 +1882,41 @@ namespace FlaxEditor.Utilities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the search popup with a tree.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="searchBox">The search box.</param>
|
||||||
|
/// <param name="tree">The tree control.</param>
|
||||||
|
/// <returns>The created menu to setup and show.</returns>
|
||||||
|
public static ContextMenuBase CreateSearchPopup(out TextBox searchBox, out Tree tree)
|
||||||
|
{
|
||||||
|
var menu = new ContextMenuBase
|
||||||
|
{
|
||||||
|
Size = new Vector2(320, 220),
|
||||||
|
};
|
||||||
|
searchBox = new TextBox(false, 1, 1)
|
||||||
|
{
|
||||||
|
Width = menu.Width - 3,
|
||||||
|
WatermarkText = "Search...",
|
||||||
|
Parent = menu,
|
||||||
|
};
|
||||||
|
var panel1 = new Panel(ScrollBars.Vertical)
|
||||||
|
{
|
||||||
|
Bounds = new Rectangle(0, searchBox.Bottom + 1, menu.Width, menu.Height - searchBox.Bottom - 2),
|
||||||
|
Parent = menu
|
||||||
|
};
|
||||||
|
var panel2 = new VerticalPanel
|
||||||
|
{
|
||||||
|
Parent = panel1,
|
||||||
|
AnchorPreset = AnchorPresets.HorizontalStretchTop,
|
||||||
|
IsScrollable = true,
|
||||||
|
};
|
||||||
|
tree = new Tree(false)
|
||||||
|
{
|
||||||
|
Parent = panel2,
|
||||||
|
};
|
||||||
|
return menu;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user