recrownedathenaeum/RecrownedAthenaeum/UI/Book/Page.cs

52 lines
1.5 KiB
C#

using RecrownedAthenaeum.UI.Modular;
namespace RecrownedAthenaeum.UI.Book
{
/// <summary>
/// A page a part of a <see cref="Book"/>.
/// </summary>
public class Page : UIModuleGroup
{
private readonly int pageX, pageY;
/// <summary>
/// Whether or not this book needs to be refreshed with new dimensions.
/// </summary>
public bool requiresSizeUpdate;
/// <summary>
/// Constructs a page.
/// </summary>
/// <param name="pageX">The X position in the book.</param>
/// <param name="pageY">The Y position in the book.</param>
public Page(int pageX, int pageY) : base(false)
{
this.pageX = pageX;
this.pageY = pageY;
requiresSizeUpdate = true;
Name = ToString();
}
/// <summary>
/// Called when this page is flagged as needing a size update.
/// </summary>
/// <param name="width">New width.</param>
/// <param name="height">New Height</param>
public virtual void ApplySize(int width, int height)
{
bounds.X = pageX * width;
bounds.Y = pageY * height;
bounds.Width = width;
bounds.Height = height;
requiresSizeUpdate = false;
}
/// <summary>
/// Called only once after a page is added to a <see cref="Book"/>. Generally used to instantiate the modules of the page.
/// </summary>
protected internal virtual void Initialize()
{
}
}
}