Fix ui macros

This commit is contained in:
MrLetsplay 2023-10-15 21:15:41 +02:00
parent e619767b04
commit 5b10076720
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
3 changed files with 9 additions and 6 deletions

View File

@ -251,7 +251,6 @@ void TextFieldElement::updateText(std::u32string newText) {
// Adjust offset to make sure the text field is always fully utilized (if possible)
float adjust = bounds.w - (fullM.width - offsetX);
std::cout << adjust << std::endl;
if(adjust > 0) offsetX -= adjust;
offsetX = clamp(offsetX, minOffsetX, maxOffsetX);

View File

@ -6,11 +6,11 @@
#include "fonts.h"
#include "input.h"
#define uiPx(val) UIValue(val, UIUnit::PIXELS)
#define uiPw(val) UIValue(val, UIUnit::PARENT_WIDTH)
#define uiPh(val) UIValue(val, UIUnit::PARENT_HEIGHT)
#define uiSw(val) UIValue(val, UIUnit::SCREEN_WIDTH)
#define uiSh(val) UIValue(val, UIUnit::SCREEN_HEIGHT)
#define uiPx(val) kek::UIValue(val, kek::UIUnit::PIXELS)
#define uiPw(val) kek::UIValue(val, kek::UIUnit::PARENT_WIDTH)
#define uiPh(val) kek::UIValue(val, kek::UIUnit::PARENT_HEIGHT)
#define uiSw(val) kek::UIValue(val, kek::UIUnit::SCREEN_WIDTH)
#define uiSh(val) kek::UIValue(val, kek::UIUnit::SCREEN_HEIGHT)
namespace kek {

View File

@ -128,6 +128,10 @@ int main(int argc, char **argv) {
TextFieldElement *textField = new TextFieldElement(uiPx(10), uiPx(200), uiPx(500));
UI::addElement(textField);
TextElement *text = new TextElement(uiPx(0), uiPx(260));
text->setText("Lorem ipsum\ndolor sit amet\nsussy amogus, KekEngine sample text\nWhen the impostor is\nAmogus");
UI::addElement(text);
if(Engine::start() != KEK_SUCCESS) return 1;
return 0;
}