Reuse text for UI tooltip
Remove `IconButton` and use simple button instead
Cleanup code style
This commit is contained in:
Wojtek Figat
2023-05-16 12:13:23 +02:00
parent 73ee5676c6
commit 4482fc0bcf
2 changed files with 9 additions and 12 deletions

View File

@@ -87,23 +87,20 @@ namespace FlaxEditor.CustomEditors.Editors
LinkValues = Editor.Instance.Windows.PropertiesWin.ScaleLinked;
// Add button with the link icon.
//Editor.Instance.Icons.Link32
_linkButton = new IconButton(Editor.Instance.Icons.Link32)
// Add button with the link icon
_linkButton = new Button
{
BackgroundBrush = new SpriteBrush(Editor.Instance.Icons.Link32),
Parent = LinkedLabel,
Width = 18,
Height = 18,
AnchorPreset = AnchorPresets.TopLeft
AnchorPreset = AnchorPresets.TopLeft,
};
_linkButton.Clicked += ToggleLink;
SetLinkStyle();
var x = LinkedLabel.Text.Value.Length * 7 + 5;
_linkButton.LocalX += x;
_linkButton.LocalY += 1;
LinkedLabel.SetupContextMenu += (label, menu, editor) =>
{
menu.AddSeparator();
@@ -136,9 +133,11 @@ namespace FlaxEditor.CustomEditors.Editors
private void SetLinkStyle()
{
Color backgroundColor = LinkValues ? FlaxEngine.GUI.Style.Current.BackgroundSelected : FlaxEngine.GUI.Style.Current.ForegroundDisabled;
var style = FlaxEngine.GUI.Style.Current;
var backgroundColor = LinkValues ? style.Foreground : style.ForegroundDisabled;
_linkButton.SetColors(backgroundColor);
_linkButton.TooltipText = (LinkValues ? "Unlink" : "Link") + " values for uniform scaling.";
_linkButton.BorderColor = _linkButton.BorderColorSelected = _linkButton.BorderColorHighlighted = Color.Transparent;
_linkButton.TooltipText = LinkValues ? "Unlinks scale components from uniform scaling" : "Links scale components for uniform scaling";
}
}
}

View File

@@ -1037,9 +1037,7 @@ namespace FlaxEditor.Utilities
/// <returns>The processed name path.</returns>
public static string GetAssetNamePath(string path)
{
var projectFolder = Globals.ProjectFolder;
if (path.StartsWith(projectFolder))
path = path.Substring(projectFolder.Length + 1);
path = GetAssetNamePathWithExt(path);
return StringUtils.GetPathWithoutExtension(path);
}