Modding:GUIs: Difference between revisions

From Vintage Story Wiki
→‎GuiElementInset: describe GuiElementStaticText
(→‎GuiElementDialogTitleBar: mention GuiStyle.TitleBarHeight)
(→‎GuiElementInset: describe GuiElementStaticText)
Line 227: Line 227:
File:AddInset.png|class=pixelated|Inset drawn on top of a background, with 10 units on all sides.
File:AddInset.png|class=pixelated|Inset drawn on top of a background, with 10 units on all sides.
File:AddInset_with_padding.png|class=pixelated|Do not use padding in the inset bounds. Otherwise the rectangle for the darkened section is miscalculated and drawn outside of the embossed border.
File:AddInset_with_padding.png|class=pixelated|Do not use padding in the inset bounds. Otherwise the rectangle for the darkened section is miscalculated and drawn outside of the embossed border.
</gallery>
=== GuiElementStaticText  ===
Add a static snippet of text.
GuiComposer factory functions:
* <code>.AddStaticText(string text, CairoFont font, ElementBounds bounds, string key = null)</code>
* <code>.AddStaticText(string text, CairoFont font, EnumTextOrientation orientation, ElementBounds bounds, string key = null)</code>
* <code>.AddStaticTextAutoBoxSize(string text, CairoFont font, EnumTextOrientation orientation, ElementBounds bounds, string key = null)</code>: adds text and resizes the bounding box such that the text fits on one line. Since the bounds are updated immediately, this may be useful for adding additional components to the right of the text. After calling <code>AddStaticTextAutoBoxSize</code>, one could use <code>newbounds.FixedRightOf(textbounds)</code>,  <code>newbounds.RightOf(textbounds)</code>, or  <code>textbounds.RightCopy()</code>.
* <code>.AddStaticTextAutoFontSize(string text, string text, CairoFont font, ElementBounds bounds, string key = null)</code>: attempts to shrink the font size such that the text fits in one line in <code>bounds</code>.
The standard fonts can be obtained through static factory methods inside of CairoFont. These are commonly used:
* <code>CairoFont.WhiteSmallText()</code>
* <code>CairoFont.WhiteDetailText()</code>
The text orientation would more accurately be called the text justification. It defaults to the font's justification, which is typically left. The options are:
* <code>Left</code>
* <code>Right</code>
* <code>Center</code>
* <code>Justify</code>: does the same thing as Left.
The key option is used to find the static text later with <code>GuiElementStaticText.GetStaticText(SingleComposer, key)</code>.
<gallery>
File:AddStaticText.png|class=pixelated|WhiteSmallText drawn on top of a dialog background, with 10 units of padding.
File:AddStaticTextAutoBoxSize.png|class=pixelated|<code>AddStaticTextAutoBoxSize</code> auto sized the text box such that the single line of text was clipped by the dialog bounds.
File:AddStaticTextAutoFontSize.png|class=pixelated|<code>AddStaticTextAutoFontSize</code> attempted to shrink down the font so that it could fit on a single line.
</gallery>
</gallery>


Confirmedusers
261

edits