namespace Sandbox.UI
{
///
/// A button that opens a panel.
/// Useless on its own - you need to implement Open
///
public abstract class PopupButton : Button
{
///
/// The opened .
///
protected Popup Popup;
public PopupButton()
{
AddClass( "popupbutton" );
}
protected override void OnClick( MousePanelEvent e )
{
base.OnClick( e );
Open();
}
///
/// Open a popup. You should set here.
///
public abstract void Open();
public override void Tick()
{
base.Tick();
SetClass( "open", Popup.IsValid() && !Popup.IsDeleting );
SetClass( "active", Popup.IsValid() && !Popup.IsDeleting );
if ( Popup.IsValid() )
{
Popup.Style.Width = Box.Rect.Width * ScaleFromScreen;
}
}
}
}