Fix showing shader source code window over a calling window
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 />
|
||||
|
||||
Reference in New Issue
Block a user