mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-04-18 05:17:53 -04:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
46 lines
877 B
C#
46 lines
877 B
C#
|
|
namespace Sandbox.UI
|
|
{
|
|
/// <summary>
|
|
/// A button that opens a <see cref="Popup"/> panel.
|
|
/// Useless on its own - you need to implement Open
|
|
/// </summary>
|
|
public abstract class PopupButton : Button
|
|
{
|
|
/// <summary>
|
|
/// The opened <see cref="UI.Popup"/>.
|
|
/// </summary>
|
|
protected Popup Popup;
|
|
|
|
public PopupButton()
|
|
{
|
|
AddClass( "popupbutton" );
|
|
}
|
|
|
|
protected override void OnClick( MousePanelEvent e )
|
|
{
|
|
base.OnClick( e );
|
|
|
|
Open();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Open a popup. You should set <see cref="Popup"/> here.
|
|
/// </summary>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|