Fix showing shader source code window over a calling window

This commit is contained in:
Wojtek Figat
2021-02-15 12:02:25 +01:00
parent cd2a02a5c8
commit b6557cb15c
3 changed files with 12 additions and 18 deletions

View File

@@ -1646,7 +1646,8 @@ namespace FlaxEditor.Utilities
/// </summary>
/// <param name="source">The source code.</param>
/// <param name="title">The window title.</param>
public static void ShowSourceCodeWindow(string source, string title)
/// <param name="control">The context control used to show source code window popup in a proper location.</param>
public static void ShowSourceCodeWindow(string source, string title, Control control = null)
{
if (string.IsNullOrEmpty(source))
{
@@ -1659,8 +1660,9 @@ namespace FlaxEditor.Utilities
settings.AllowMaximize = false;
settings.AllowMinimize = false;
settings.HasSizingFrame = false;
settings.StartPosition = WindowStartPosition.CenterScreen;
settings.StartPosition = WindowStartPosition.CenterParent;
settings.Size = new Vector2(500, 600) * Platform.DpiScale;
settings.Parent = control?.RootWindow?.Window ?? Editor.Instance.Windows.MainWindow;
settings.Title = title;
var dialog = Platform.CreateWindow(ref settings);

View File

@@ -233,18 +233,14 @@ namespace FlaxEditor.Windows.Assets
// Toolstrip
_toolstrip.AddSeparator();
_toolstrip.AddButton(editor.Icons.BracketsSlash32, () => ShowSourceCode(_asset)).LinkTooltip("Show generated shader source code");
_toolstrip.AddButton(editor.Icons.BracketsSlash32, ShowSourceCode).LinkTooltip("Show generated shader source code");
_toolstrip.AddButton(editor.Icons.Docs32, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/graphics/materials/index.html")).LinkTooltip("See documentation to learn more");
}
/// <summary>
/// Shows the material source code window.
/// </summary>
/// <param name="material">The material asset.</param>
public static void ShowSourceCode(Material material)
private void ShowSourceCode()
{
var source = Editor.GetShaderSourceCode(material);
Utilities.Utils.ShowSourceCodeWindow(source, "Material Source");
var source = Editor.GetShaderSourceCode(_asset);
Utilities.Utils.ShowSourceCodeWindow(source, "Material Source", this);
}
/// <summary>

View File

@@ -139,18 +139,14 @@ namespace FlaxEditor.Windows.Assets
// Toolstrip
_toolstrip.AddSeparator();
_toolstrip.AddButton(editor.Icons.BracketsSlash32, () => ShowSourceCode(_asset)).LinkTooltip("Show generated shader source code");
_toolstrip.AddButton(editor.Icons.BracketsSlash32, ShowSourceCode).LinkTooltip("Show generated shader source code");
_toolstrip.AddButton(editor.Icons.Docs32, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/particles/index.html")).LinkTooltip("See documentation to learn more");
}
/// <summary>
/// Shows the ParticleEmitter source code window.
/// </summary>
/// <param name="particleEmitter">The ParticleEmitter asset.</param>
public static void ShowSourceCode(ParticleEmitter particleEmitter)
private void ShowSourceCode()
{
var source = Editor.GetShaderSourceCode(particleEmitter);
Utilities.Utils.ShowSourceCodeWindow(source, "Particle Emitter GPU Simulation Source");
var source = Editor.GetShaderSourceCode(_asset);
Utilities.Utils.ShowSourceCodeWindow(source, "Particle Emitter GPU Simulation Source", this);
}
/// <inheritdoc />