Class FoliosLayout
java.lang.Object
net.ixdarklord.folios.api.client.page.FoliosLayout
Where pages are laid out: the page's size and margins, the font, and helpers for the parts most pages have (a
title, and text that continues onto further pages).
A page is pageWidth() by pageHeight() pixels: 136 by 180 in a
handheld book and on a screen at the Auto GUI scale, larger on a screen at a smaller GUI scale, so more fits on it.
Content sits between the margins, from CONTENT_LEFT to contentRight() and CONTENT_TOP to
contentBottom(). A page type lays itself out to these (and draws to its FoliosPainter's), so it
fills a larger page; the constants are the default page's.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordWhat a page askedflow(String, int, String, FoliosPageElement.Part)for: its title, its own part and how tall it is, and its text.static final recordA named place on the pages a page lays out: thepageth of them (from 0), fromtopdown tobottomon it. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intUnder this are the page's number and its turn buttons, with 2 pixels between them and what is on the page.static final intstatic final intstatic final intstatic final intstatic final intHow far above a page's foot its content stops: under it are the page's number and its turn buttons, 2 pixels clear.static final intstatic final intstatic final intThe default page's size: a handheld book's, and a screen book's at the Auto GUI scale.static final intHow many texture pixels a scene has for each page pixel it is shown over: enough for it to stay sharp on a handheld book held close and on large screens.static final intHow much room a title takes: its line, its rule under it, and 4 pixels under that (as a heading in text has). -
Constructor Summary
ConstructorsConstructorDescriptionFoliosLayout(FoliosBook book, net.minecraft.client.gui.Font font) FoliosLayout(FoliosBook book, net.minecraft.client.gui.Font font, int pageWidth, int pageHeight) A layout for pagespageWidthbypageHeight, no smaller than the default page. -
Method Summary
Modifier and TypeMethodDescription@Nullable FoliosAlignHow what is laid out now is aligned across the page ("alignment"); null for each part's own way.voidalignment(@Nullable FoliosAlign alignment) Sets how what is laid out next is aligned, as a page sets it for each of its elements; null for each part's own way.book()capture(FoliosPageElement page) Lays a page out only as far as what it asksflow(String, int, String, FoliosPageElement.Part)for, to set it inside another page; empty for a page that lays itself out some other way.voidclose()Closes the scenes made for this layout.intintWhere content ends at the right, how wide it is, and where it ends at the foot (above the number and turn buttons).intflow(@Nullable String title, int reserved, @Nullable String text, @Nullable FoliosPageElement.Part part) A page with an optional title, a part of its ownreservedpixels tall under it, and text under that; text that doesn't fit runs on over as many more pages as it needs.net.minecraft.client.gui.Fontfont()voidMarks the whole of thelaidth page laid out (from 0) with a name.voidmark(String name, FoliosLayout.Mark mark) Marks a place on the pages the page being laid out lays out with a name, for links to reach and to be shown when they do: where a part of it is, as a page of elements marks each of its elements.intintThe page's width and height, in its own pixels.static intplace(FoliosPainter painter, @Nullable FoliosAlign align, int width) Where somethingwidthwide starts across the page's content, for an alignment: centred for null andFoliosAlign.JUSTIFY, the way a picture or a card is placed by default.intscaled(int height) A height written for the default page, for this one: grown as the page is wider, so a window (a scene, a picture) keeps its shape on a larger page rather than turning into a strip.The names marked since this was last asked, each with its place; and forgets them.static voidtitle(FoliosPainter painter, net.minecraft.network.chat.Component title, int y) A page's title: bold, with a line under it.static voidtitle(FoliosPainter painter, net.minecraft.network.chat.Component title, int y, FoliosIcon icon) Astitle(FoliosPainter, Component, int), with an icon before it, unless none: three quarters of its size, centred over a mark of the book's colour that heads the line under the title, the title starting where the rest of the line does.static voidtitle(FoliosPainter painter, net.minecraft.network.chat.Component title, int y, FoliosIcon icon, @Nullable FoliosAlign align) Astitle(FoliosPainter, Component, int, FoliosIcon), placed across the page by an alignment (left for null or justify).voidtitleIcon(FoliosIcon icon) The icon put before the titles of the pages laid out next (asflow(String, int, String, FoliosPageElement.Part)draws them): their entry's, or a page's own.net.ixdarklord.coolcatcanvas.api.client.viewport.SceneViewportviewport(int width, int height) A scene for a page to show (an entity, a structure), drawn to a texture ofwidthbyheightpixels (its size on the page timesSCENE_DETAIL).
-
Field Details
-
PAGE_WIDTH
public static final int PAGE_WIDTHThe default page's size: a handheld book's, and a screen book's at the Auto GUI scale.- See Also:
-
PAGE_HEIGHT
public static final int PAGE_HEIGHT- See Also:
-
MARGIN
public static final int MARGIN- See Also:
-
CONTENT_LEFT
public static final int CONTENT_LEFT- See Also:
-
CONTENT_RIGHT
public static final int CONTENT_RIGHT- See Also:
-
CONTENT_WIDTH
public static final int CONTENT_WIDTH- See Also:
-
CONTENT_TOP
public static final int CONTENT_TOP- See Also:
-
FOOT
public static final int FOOTHow far above a page's foot its content stops: under it are the page's number and its turn buttons, 2 pixels clear.- See Also:
-
CONTENT_BOTTOM
public static final int CONTENT_BOTTOMUnder this are the page's number and its turn buttons, with 2 pixels between them and what is on the page.- See Also:
-
TITLE_HEIGHT
public static final int TITLE_HEIGHTHow much room a title takes: its line, its rule under it, and 4 pixels under that (as a heading in text has).- See Also:
-
SCENE_DETAIL
public static final int SCENE_DETAILHow many texture pixels a scene has for each page pixel it is shown over: enough for it to stay sharp on a handheld book held close and on large screens.- See Also:
-
-
Constructor Details
-
FoliosLayout
-
FoliosLayout
public FoliosLayout(FoliosBook book, net.minecraft.client.gui.Font font, int pageWidth, int pageHeight) A layout for pagespageWidthbypageHeight, no smaller than the default page.
-
-
Method Details
-
pageWidth
public int pageWidth()The page's width and height, in its own pixels. -
pageHeight
public int pageHeight() -
scaled
public int scaled(int height) A height written for the default page, for this one: grown as the page is wider, so a window (a scene, a picture) keeps its shape on a larger page rather than turning into a strip. -
contentRight
public int contentRight()Where content ends at the right, how wide it is, and where it ends at the foot (above the number and turn buttons). -
contentWidth
public int contentWidth() -
contentBottom
public int contentBottom() -
book
-
font
public net.minecraft.client.gui.Font font() -
alignment
How what is laid out now is aligned across the page ("alignment"); null for each part's own way. -
alignment
Sets how what is laid out next is aligned, as a page sets it for each of its elements; null for each part's own way. -
place
Where somethingwidthwide starts across the page's content, for an alignment: centred for null andFoliosAlign.JUSTIFY, the way a picture or a card is placed by default. -
text
-
flow
public List<FoliosPageElement.Laid> flow(@Nullable String title, int reserved, @Nullable String text, @Nullable FoliosPageElement.Part part) A page with an optional title, a part of its ownreservedpixels tall under it, and text under that; text that doesn't fit runs on over as many more pages as it needs.- Parameters:
part- draws the page's own part, given the height it starts at; null for none
-
capture
Lays a page out only as far as what it asksflow(String, int, String, FoliosPageElement.Part)for, to set it inside another page; empty for a page that lays itself out some other way. -
titleIcon
The icon put before the titles of the pages laid out next (asflow(String, int, String, FoliosPageElement.Part)draws them): their entry's, or a page's own. The book sets it as it lays out each page of an entry;FoliosIcon.NONEfor none. -
titleIcon
-
mark
Marks a place on the pages the page being laid out lays out with a name, for links to reach and to be shown when they do: where a part of it is, as a page of elements marks each of its elements. Ignored while a page is only captured; the first mark of a name holds. -
mark
Marks the whole of thelaidth page laid out (from 0) with a name. -
takeMarks
The names marked since this was last asked, each with its place; and forgets them. -
title
A page's title: bold, with a line under it. -
title
public static void title(FoliosPainter painter, net.minecraft.network.chat.Component title, int y, FoliosIcon icon) Astitle(FoliosPainter, Component, int), with an icon before it, unless none: three quarters of its size, centred over a mark of the book's colour that heads the line under the title, the title starting where the rest of the line does. Without an icon the line runs unbroken. -
title
public static void title(FoliosPainter painter, net.minecraft.network.chat.Component title, int y, FoliosIcon icon, @Nullable FoliosAlign align) Astitle(FoliosPainter, Component, int, FoliosIcon), placed across the page by an alignment (left for null or justify). -
viewport
public net.ixdarklord.coolcatcanvas.api.client.viewport.SceneViewport viewport(int width, int height) A scene for a page to show (an entity, a structure), drawn to a texture ofwidthbyheightpixels (its size on the page timesSCENE_DETAIL). It belongs to this layout: it is closed when the book is laid out again. -
close
public void close()Closes the scenes made for this layout.
-