// Copyright (c) Wojciech Figat. All rights reserved. using System; using FlaxEngine; using FlaxEngine.GUI; namespace FlaxEditor.GUI.Tabs { /// /// Single tab control used by . /// /// [HideInEditor] public class Tab : ContainerControl { internal Tabs _selectedInTabs; /// /// Gets or sets the text. /// public string Text; /// /// Gets or sets the icon. /// public SpriteHandle Icon; /// /// Occurs when tab gets selected. /// public event Action Selected; /// /// Occurs when tab gets deselected. /// public event Action Deselected; /// /// Initializes a new instance of the class. /// /// The icon. public Tab(SpriteHandle icon) : this(string.Empty, icon) { } /// /// Initializes a new instance of the class. /// /// The text. public Tab(string text) : this(text, SpriteHandle.Invalid) { } /// /// Initializes a new instance of the class. /// /// The text. /// The icon. public Tab(string text, SpriteHandle icon) { Text = text; Icon = icon; } /// /// Called when tab gets selected. /// public virtual void OnSelected() { Selected?.Invoke(this); } /// /// Called when tab gets deselected. /// public virtual void OnDeselected() { Deselected?.Invoke(this); } /// /// Factory method for tabs header control (UI for the tabs strip to represent this tab). /// /// The tab header control. public virtual Tabs.TabHeader CreateHeader() { return new Tabs.TabHeader((Tabs)Parent, this); } /// protected override void OnParentChangedInternal() { if (_selectedInTabs != null) _selectedInTabs.SelectedTab = null; base.OnParentChangedInternal(); } /// public override void OnDestroy() { if (IsDisposing) return; if (_selectedInTabs != null) _selectedInTabs.SelectedTab = null; base.OnDestroy(); } } }