small fixes

This commit is contained in:
MihailRis
2025-03-11 00:39:59 +03:00
parent 9a01b5ad2d
commit 4c9019e03c
8 changed files with 21 additions and 9 deletions
+1 -1
View File
@@ -262,7 +262,7 @@ void GUI::draw(const DrawContext& pctx, const Assets& assets) {
auto pos = node->calcPos();
auto size = node->getSize();
batch2D->setColor(0, 0, 255);
batch2D->setColor(0, 255, 255);
batch2D->lineRect(pos.x, pos.y, size.x-1, size.y-1);
node = node->getParent();
-1
View File
@@ -4,7 +4,6 @@
#include "typedefs.hpp"
#include <memory>
#include <glm/glm.hpp>
class Assets;
class DrawContext;
+6
View File
@@ -404,6 +404,12 @@ void TextBox::onFocus(GUI* gui) {
}
}
void TextBox::reposition() {
auto size = getSize();
UINode::reposition();
refreshLabel();
}
void TextBox::refresh() {
Container::refresh();
label->setSize(size-glm::vec2(padding.z+padding.x, padding.w+padding.y));
+1
View File
@@ -210,6 +210,7 @@ namespace gui {
virtual void setShowLineNumbers(bool flag);
virtual bool isShowLineNumbers() const;
virtual void reposition() override;
virtual void onFocus(GUI*) override;
virtual void refresh() override;
virtual void doubleClick(GUI*, int x, int y) override;
+6 -2
View File
@@ -301,9 +301,13 @@ const std::string& UINode::getId() const {
void UINode::reposition() {
if (sizefunc) {
auto newSize = sizefunc();
auto defsize = newSize;
if (parent) {
defsize = parent->getSize();
}
setSize(
{newSize.x < 0 ? size.x : newSize.x,
newSize.y < 0 ? size.y : newSize.y}
{newSize.x < 0 ? defsize.x : newSize.x,
newSize.y < 0 ? defsize.y : newSize.y}
);
}
if (positionfunc) {
+1 -1
View File
@@ -250,7 +250,7 @@ namespace gui {
const std::string& getId() const;
/// @brief Fetch pos from positionfunc if assigned
void reposition();
virtual void reposition();
virtual void setGravity(Gravity gravity);