Begin working on an IconButton class, and demoing the IconButton idea using the scale link icon.
This commit is contained in:
@@ -78,7 +78,8 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
/// <seealso cref="FlaxEditor.CustomEditors.Editors.Float3Editor" />
|
||||
public class ScaleEditor : Float3Editor
|
||||
{
|
||||
private Image _linkImage;
|
||||
private Button _linkButton;
|
||||
private SpriteBrush _linkBrush;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Initialize(LayoutElementsContainer layout)
|
||||
@@ -87,18 +88,26 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
|
||||
LinkValues = Editor.Instance.Windows.PropertiesWin.ScaleLinked;
|
||||
|
||||
_linkImage = new Image
|
||||
// Add button with the link icon.
|
||||
_linkBrush = new SpriteBrush(Editor.Instance.Icons.Link32);
|
||||
_linkButton = new Button
|
||||
{
|
||||
Parent = LinkedLabel,
|
||||
Width = 18,
|
||||
Height = 18,
|
||||
Brush = LinkValues ? new SpriteBrush(Editor.Instance.Icons.Link32) : new SpriteBrush(),
|
||||
BackgroundBrush = _linkBrush,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
TooltipText = "Scale values are linked together.",
|
||||
};
|
||||
|
||||
_linkButton.Clicked += ToggleLink;
|
||||
_linkButton.BorderColor = Color.Transparent;
|
||||
_linkButton.BorderColorSelected = Color.Transparent;
|
||||
_linkButton.BorderColorHighlighted = Color.Transparent;
|
||||
SetLinkStyle();
|
||||
|
||||
var x = LinkedLabel.Text.Value.Length * 7 + 5;
|
||||
_linkImage.LocalX += x;
|
||||
_linkImage.LocalY += 1;
|
||||
_linkButton.LocalX += x;
|
||||
_linkButton.LocalY += 1;
|
||||
|
||||
LinkedLabel.SetupContextMenu += (label, menu, editor) =>
|
||||
{
|
||||
@@ -127,7 +136,16 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
{
|
||||
LinkValues = !LinkValues;
|
||||
Editor.Instance.Windows.PropertiesWin.ScaleLinked = LinkValues;
|
||||
_linkImage.Brush = LinkValues ? new SpriteBrush(Editor.Instance.Icons.Link32) : new SpriteBrush();
|
||||
SetLinkStyle();
|
||||
}
|
||||
|
||||
private void SetLinkStyle()
|
||||
{
|
||||
Color backgroundColor = LinkValues ? FlaxEngine.GUI.Style.Current.BackgroundSelected : FlaxEngine.GUI.Style.Current.ForegroundDisabled;
|
||||
_linkButton.BackgroundColor = backgroundColor;
|
||||
_linkButton.BackgroundColorHighlighted = backgroundColor.RGBMultiplied(0.9f);
|
||||
_linkButton.BackgroundColorSelected = backgroundColor.RGBMultiplied(0.8f);
|
||||
_linkButton.TooltipText = (LinkValues ? "Unlink" : "Link") + " values for uniform scaling.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user