From f5d757a9a510ebb955e08c702324a1c631b1c13d Mon Sep 17 00:00:00 2001 From: Yousef Khadadeh Date: Tue, 7 Apr 2026 19:15:58 +0300 Subject: [PATCH] Fixed color display and global log bugs --- .../ElementHelpers/TextBoxHelpers.hpp | 10 +-- src/GUIStuff/Elements/TextBox.decl.hpp | 2 +- src/GUIStuff/Elements/TextBox.impl.hpp | 2 +- src/Toolbar.cpp | 85 ++++++++++--------- 4 files changed, 51 insertions(+), 48 deletions(-) diff --git a/src/GUIStuff/ElementHelpers/TextBoxHelpers.hpp b/src/GUIStuff/ElementHelpers/TextBoxHelpers.hpp index 5d5867a..920655b 100644 --- a/src/GUIStuff/ElementHelpers/TextBoxHelpers.hpp +++ b/src/GUIStuff/ElementHelpers/TextBoxHelpers.hpp @@ -18,7 +18,7 @@ template TextBoxData textbox_options_to_data(cons } struct TextBoxOptions { - bool updateEveryEdit = false; + bool updateEveryEdit = true; bool immutable = false; std::function onEnter; std::function onEdit; @@ -28,7 +28,7 @@ struct TextBoxOptions { struct TextBoxScalarOptions { int decimalPrecision = 0; - bool updateEveryEdit = false; + bool updateEveryEdit = true; bool immutable = false; std::function onEnter; std::function onEdit; @@ -38,7 +38,7 @@ struct TextBoxScalarOptions { struct TextBoxScalarsOptions { int decimalPrecision = 0; - bool updateEveryEdit = false; + bool updateEveryEdit = true; bool immutable = false; std::function onEnter; std::function onEdit; @@ -48,7 +48,7 @@ struct TextBoxScalarsOptions { struct TextBoxPathOptions { std::filesystem::file_type fileTypeRestriction; - bool updateEveryEdit = false; + bool updateEveryEdit = true; bool immutable = false; std::function onEnter; std::function onEdit; @@ -58,7 +58,7 @@ struct TextBoxPathOptions { struct TextBoxHexColorOptions { bool hasAlpha = true; - bool updateEveryEdit = false; + bool updateEveryEdit = true; bool immutable = false; std::function onEnter; std::function onEdit; diff --git a/src/GUIStuff/Elements/TextBox.decl.hpp b/src/GUIStuff/Elements/TextBox.decl.hpp index 71ae946..68803fc 100644 --- a/src/GUIStuff/Elements/TextBox.decl.hpp +++ b/src/GUIStuff/Elements/TextBox.decl.hpp @@ -14,7 +14,7 @@ template struct TextBoxData { std::function(const std::string&)> fromStr; std::function toStr; bool singleLine = true; - bool updateEveryEdit = false; + bool updateEveryEdit = true; bool immutable = false; InputManager::TextInputProperties textInputProps; std::function onEdit; diff --git a/src/GUIStuff/Elements/TextBox.impl.hpp b/src/GUIStuff/Elements/TextBox.impl.hpp index a8d1db2..ec80b5e 100644 --- a/src/GUIStuff/Elements/TextBox.impl.hpp +++ b/src/GUIStuff/Elements/TextBox.impl.hpp @@ -91,7 +91,7 @@ template void TextBox::after_text_input_callback() { if(userInfo.immutable) cur->pos = cur->selectionBeginPos = cur->selectionEndPos = textbox->insert({0, 0}, userInfo.toStr(*userInfo.data)); else { - if(update_data() && userInfo.onEdit) + if(userInfo.updateEveryEdit && update_data() && userInfo.onEdit) gui.set_post_callback_func_high_priority(userInfo.onEdit); } } diff --git a/src/Toolbar.cpp b/src/Toolbar.cpp index 423a62d..9a301c2 100644 --- a/src/Toolbar.cpp +++ b/src/Toolbar.cpp @@ -1170,51 +1170,53 @@ void Toolbar::global_log() { auto& gui = main.g.gui; auto& io = gui.io; - CLAY_AUTO_ID({ - .layout = { - .sizing = {.width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_FIT(0) }, - .childGap = io.theme->childGap1, - .childAlignment = { .x = CLAY_ALIGN_X_RIGHT, .y = CLAY_ALIGN_Y_TOP}, - .layoutDirection = CLAY_TOP_TO_BOTTOM - }, - .floating = {.offset = {0, 10}, .attachPoints = {.element = CLAY_ATTACH_POINT_RIGHT_TOP, .parent = CLAY_ATTACH_POINT_RIGHT_BOTTOM}, .attachTo = CLAY_ATTACH_TO_PARENT} - }) { - int i = 0; - for(auto& logM : main.logMessages) { - logM.time.update_time_since(); - if(logM.time < LogMessage::DISPLAY_TIME) { - float a = 1.0f - lerp_time(logM.time, LogMessage::DISPLAY_TIME, LogMessage::FADE_START_TIME); - gui.new_id(i, [&] { - gui.element("GLOBAL LOG", [&] (LayoutElement*, const Clay_ElementId& lId) { - CLAY(lId, { - .layout = { - .sizing = {.width = CLAY_SIZING_FIT(300), .height = CLAY_SIZING_FIT(0) }, - .padding = CLAY_PADDING_ALL(io.theme->padding1), - .childGap = 0, - .childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_TOP}, - .layoutDirection = CLAY_TOP_TO_BOTTOM - }, - .backgroundColor = convert_vec4(color_mul_alpha(io.theme->backColor1, a)), - .cornerRadius = CLAY_CORNER_RADIUS(io.theme->windowCorners1) - }) { - SkColor4f c{0, 0, 0, 0}; - switch(logM.color) { - case LogMessage::COLOR_NORMAL: - c = io.theme->frontColor1; - break; - case LogMessage::COLOR_ERROR: - c = io.theme->errorColor; - break; + gui.new_id("Global log popup list", [&] { + CLAY_AUTO_ID({ + .layout = { + .sizing = {.width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_FIT(0) }, + .childGap = io.theme->childGap1, + .childAlignment = { .x = CLAY_ALIGN_X_RIGHT, .y = CLAY_ALIGN_Y_TOP}, + .layoutDirection = CLAY_TOP_TO_BOTTOM + }, + .floating = {.offset = {0, 10}, .attachPoints = {.element = CLAY_ATTACH_POINT_RIGHT_TOP, .parent = CLAY_ATTACH_POINT_RIGHT_BOTTOM}, .attachTo = CLAY_ATTACH_TO_PARENT} + }) { + for(size_t i = 0; i < main.logMessages.size(); i++) { + auto& logM = main.logMessages[i]; + logM.time.update_time_since(); + if(logM.time < LogMessage::DISPLAY_TIME) { + float a = 1.0f - lerp_time(logM.time, LogMessage::DISPLAY_TIME, LogMessage::FADE_START_TIME); + gui.new_id(i, [&] { + gui.element("Global log message", [&] (LayoutElement*, const Clay_ElementId& lId) { + CLAY(lId, { + .layout = { + .sizing = {.width = CLAY_SIZING_FIT(300), .height = CLAY_SIZING_FIT(0) }, + .padding = CLAY_PADDING_ALL(io.theme->padding1), + .childGap = 0, + .childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_TOP}, + .layoutDirection = CLAY_TOP_TO_BOTTOM + }, + .backgroundColor = convert_vec4(color_mul_alpha(io.theme->backColor1, a)), + .cornerRadius = CLAY_CORNER_RADIUS(io.theme->windowCorners1) + }) { + SkColor4f c{0, 0, 0, 0}; + switch(logM.color) { + case LogMessage::COLOR_NORMAL: + c = io.theme->frontColor1; + break; + case LogMessage::COLOR_ERROR: + c = io.theme->errorColor; + break; + } + text_label_color(gui, logM.text, color_mul_alpha(c, a)); } - text_label_color(gui, logM.text, color_mul_alpha(c, a)); - } + }); }); - }); + } + else + break; } - else - break; } - } + }); } void Toolbar::drawing_program_gui() { @@ -2131,6 +2133,7 @@ void Toolbar::file_picker_gui() { } }); input_path_field(gui, "file picker path", "Path", &filePicker.currentSearchPath, { + .updateEveryEdit = false, .onEdit = [&] { file_picker_gui_refresh_entries(); }