Fixed ui text.

This commit is contained in:
Kapendev 2024-12-18 21:04:46 +02:00
parent 22c8cf700a
commit 2603bf6d76
4 changed files with 35 additions and 44 deletions

View file

@ -11,6 +11,8 @@ void ready() {
bool update(float dt) {
// Prepare the UI for this frame. This call is required for the UI to function as expected.
prepareUi();
// Disable the UI focus for this frame. Focus is only needed for UIs that support keyboard controls.
setUiFocus(0);
// Set the starting point for subsequent UI items.
setUiStartPoint(Vec2(8));
// Create a button and print if it is clicked.

View file

@ -1,7 +1,8 @@
/// This example shows how to place buttons relative to each other.
/// This example shows how to place UI items relative to each other.
import parin;
auto textSize = Vec2(80, 20);
auto buttonSize = Vec2(20);
void ready() {
@ -10,17 +11,18 @@ void ready() {
bool update(float dt) {
prepareUi();
setUiFocus(0);
// Set the margin between subsequent UI items.
setUiMargin(2);
setUiStartPoint(Vec2(8));
// Create a layout for arranging subsequent UI items.
useUiLayout(Layout.h);
uiText(Vec2(70, buttonSize.y), "Button 1", UiButtonOptions(Alignment.left));
if (uiButton(buttonSize, "")) println(1);
uiText(textSize, "Cool Button", UiButtonOptions(Alignment.left));
if (uiButton(buttonSize, "")) println("Cool");
// Create a new layout under the previous layout.
useUiLayout(Layout.h);
uiText(Vec2(70, buttonSize.y), "Button 22", UiButtonOptions(Alignment.left));
if (uiButton(buttonSize, "")) println(22);
uiText(textSize, "Super Button", UiButtonOptions(Alignment.left));
if (uiButton(buttonSize, "")) println("Super");
return false;
}

View file

@ -13,6 +13,7 @@ void ready() {
bool update(float dt) {
prepareUi();
setUiFocus(0);
// Set the viewport state for subsequent UI items.
setUiViewportState(viewportPosition, viewport.size, viewportScale);
viewport.attach();