// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. using FlaxEngine; using FlaxEngine.GUI; namespace FlaxEditor.GUI { /// /// A navigation bar control. Shows the current location path with UI buttons to navigate around. /// /// public class NavigationBar : Panel { /// /// The default buttons margin. /// public const float DefaultButtonsMargin = 2; /// /// Initializes a new instance of the class. /// public NavigationBar() : base(ScrollBars.Horizontal) { } /// protected override void Arrange() { base.Arrange(); // Arrange buttons float x = DefaultButtonsMargin; for (int i = 0; i < _children.Count; i++) { var child = _children[i]; if (child.IsScrollable) { child.X = x; x += child.Width + DefaultButtonsMargin; } } } /// /// Updates the bar bounds and positions it after the last toolstrip button. Ensures to fit the toolstrip area (navigation bar horizontal scroll bar can be used to view the full path). /// /// The toolstrip. public void UpdateBounds(ToolStrip toolstrip) { if (toolstrip == null) return; var lastToolstripButton = toolstrip.LastButton; var parentSize = Parent.Size; Bounds = new Rectangle(lastToolstripButton.Right + 8.0f, 0, parentSize.X - X - 8.0f, toolstrip.Height); } } }