Implemented view change and trash in file selector, and moved more file IO to SDL file IO

This commit is contained in:
Yousef Khadadeh 2026-04-23 20:56:11 +03:00
parent b81b33660e
commit 9ea5a1eae9
15 changed files with 585 additions and 203 deletions

View file

@ -0,0 +1,20 @@
#include "MutableTextLabel.hpp"
#include "../GUIManager.hpp"
namespace GUIStuff {
MutableTextLabel::MutableTextLabel(GUIManager& gui): Element(gui) {}
void MutableTextLabel::layout(const Clay_ElementId& id, const std::string& text, Clay_TextElementConfig* textConfig) {
if(text != oldText) {
oldText = text;
gui.invalidate_draw_element(this);
}
CLAY(id, {
.layout = {.sizing = {.width = CLAY_SIZING_FIT(0), .height = CLAY_SIZING_FIT(0)}}
}) {
CLAY_TEXT(gui.strArena.std_str_to_clay_str(text), textConfig);
}
}
}

View file

@ -0,0 +1,15 @@
#pragma once
#include "Element.hpp"
#include "Helpers/ConvertVec.hpp"
namespace GUIStuff {
class MutableTextLabel : public Element {
public:
MutableTextLabel(GUIManager& gui);
void layout(const Clay_ElementId& id, const std::string& text, Clay_TextElementConfig* textConfig);
private:
std::string oldText;
};
}

View file

@ -17,15 +17,6 @@ void PositionAdjustingPopupMenu::layout(const Clay_ElementId& id, Vector2f popup
layoutElement = gui.element<LayoutElement>("popup", [&] (LayoutElement*, const Clay_ElementId& lId) {
CLAY(lId, {
.layout = {
.sizing = {.width = CLAY_SIZING_FIT(100), .height = CLAY_SIZING_FIT(0)},
.padding = CLAY_PADDING_ALL(gui.io.theme->padding1),
.childGap = 1,
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP},
.layoutDirection = CLAY_TOP_TO_BOTTOM
},
.backgroundColor = convert_vec4<Clay_Color>(gui.io.theme->backColor1),
.cornerRadius = CLAY_CORNER_RADIUS(gui.io.theme->windowCorners1),
.floating = {
.offset = {popupPos.x(), popupPos.y()},
.zIndex = gui.get_z_index(),