2019-01-13 20:22:53 +00:00
|
|
|
|
using RecrownedAthenaeum.UI.Modular;
|
2018-11-30 02:41:06 +00:00
|
|
|
|
|
2018-12-04 13:45:09 +00:00
|
|
|
|
namespace RecrownedAthenaeum.UI.Book
|
2018-11-30 02:41:06 +00:00
|
|
|
|
{
|
2019-01-14 07:26:46 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// A page a part of a <see cref="Book"/>.
|
|
|
|
|
/// </summary>
|
2018-12-04 13:45:09 +00:00
|
|
|
|
public class Page : UIModuleGroup
|
2018-11-30 02:41:06 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly int pageX, pageY;
|
2019-01-14 07:26:46 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether or not this book needs to be refreshed with new dimensions.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool requiresSizeUpdate;
|
2018-11-30 02:41:06 +00:00
|
|
|
|
|
2019-01-14 07:26:46 +00:00
|
|
|
|
/// <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>
|
2018-11-30 02:41:06 +00:00
|
|
|
|
public Page(int pageX, int pageY) : base(false)
|
|
|
|
|
{
|
|
|
|
|
this.pageX = pageX;
|
|
|
|
|
this.pageY = pageY;
|
2019-01-14 07:26:46 +00:00
|
|
|
|
requiresSizeUpdate = true;
|
2018-11-30 02:41:06 +00:00
|
|
|
|
Name = ToString();
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-14 07:26:46 +00:00
|
|
|
|
/// <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>
|
2018-11-30 02:41:06 +00:00
|
|
|
|
public virtual void ApplySize(int width, int height)
|
|
|
|
|
{
|
|
|
|
|
bounds.X = pageX * width;
|
|
|
|
|
bounds.Y = pageY * height;
|
|
|
|
|
bounds.Width = width;
|
|
|
|
|
bounds.Height = height;
|
2019-01-14 07:26:46 +00:00
|
|
|
|
requiresSizeUpdate = false;
|
2018-11-30 02:41:06 +00:00
|
|
|
|
}
|
2019-01-27 20:57:47 +00:00
|
|
|
|
|
|
|
|
|
/// <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()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2018-11-30 02:41:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|