From af4ae684cdacd46739b0211594339b688a172535 Mon Sep 17 00:00:00 2001 From: ChancellorIkseew <156004311+ChancellorIkseew@users.noreply.github.com> Date: Sun, 15 Jun 2025 03:50:58 +1000 Subject: [PATCH 01/11] debug::Logger refactoring (#534) --- src/debug/Logger.cpp | 17 ++++++++--------- src/debug/Logger.hpp | 18 ++++-------------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/debug/Logger.cpp b/src/debug/Logger.cpp index 970b2102..12d8975a 100644 --- a/src/debug/Logger.cpp +++ b/src/debug/Logger.cpp @@ -2,25 +2,24 @@ #include #include +#include #include #include +#include #include using namespace debug; -std::ofstream Logger::file; -std::mutex Logger::mutex; -std::string Logger::utcOffset = ""; -unsigned Logger::moduleLen = 20; +static std::ofstream file; +static std::mutex mutex; +static std::string utcOffset = ""; +constexpr unsigned int moduleLen = 20; LogMessage::~LogMessage() { logger->log(level, ss.str()); } -Logger::Logger(std::string name) : name(std::move(name)) { -} - -void Logger::log( +static void write( LogLevel level, const std::string& name, const std::string& message ) { if (level == LogLevel::print) { @@ -84,5 +83,5 @@ void Logger::flush() { } void Logger::log(LogLevel level, std::string message) { - log(level, name, std::move(message)); + write(level, name, std::move(message)); } diff --git a/src/debug/Logger.hpp b/src/debug/Logger.hpp index 9505affd..598dc4ef 100644 --- a/src/debug/Logger.hpp +++ b/src/debug/Logger.hpp @@ -1,7 +1,5 @@ #pragma once -#include -#include #include namespace debug { @@ -27,24 +25,16 @@ namespace debug { }; class Logger { - static std::mutex mutex; - static std::string utcOffset; - static std::ofstream file; - static unsigned moduleLen; - std::string name; - - static void log( - LogLevel level, const std::string& name, const std::string& message - ); public: static void init(const std::string& filename); static void flush(); - Logger(std::string name); + Logger(const std::string& name) : name(name) { + } void log(LogLevel level, std::string message); - + LogMessage debug() { return LogMessage(this, LogLevel::debug); } @@ -60,7 +50,7 @@ namespace debug { LogMessage warning() { return LogMessage(this, LogLevel::warning); } - + /// @brief Print-debugging tool (printed without header) LogMessage print() { return LogMessage(this, LogLevel::print); From f473df33fb2ec42933b335971317e9c1456d2b0c Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 26 Jun 2025 20:29:38 +0300 Subject: [PATCH 02/11] minor refactor Button --- src/coders/yaml.cpp | 2 +- src/graphics/ui/elements/Button.cpp | 27 +++++++++++---------------- src/graphics/ui/elements/Panel.cpp | 11 +++++++++++ src/graphics/ui/elements/Panel.hpp | 6 ++++++ 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/coders/yaml.cpp b/src/coders/yaml.cpp index a9944ea3..b10d5ce2 100644 --- a/src/coders/yaml.cpp +++ b/src/coders/yaml.cpp @@ -308,7 +308,7 @@ dv::value Parser::parseObject(dv::value&& object, int indent) { object[std::string(name)] = parseFullValue(indent); skipEmptyLines(); } - return object; + return std::move(object); } dv::value yaml::parse(std::string_view filename, std::string_view source) { diff --git a/src/graphics/ui/elements/Button.cpp b/src/graphics/ui/elements/Button.cpp index bb531889..7600fbd0 100644 --- a/src/graphics/ui/elements/Button.cpp +++ b/src/graphics/ui/elements/Button.cpp @@ -34,14 +34,12 @@ Button::Button( const onaction& action, glm::vec2 size ) - : Panel(gui, size, padding, 0) { - if (size.y < 0.0f) { - size = glm::vec2( - glm::max(padding.x + padding.z + text.length() * 8, size.x), - glm::max(padding.y + padding.w + 16, size.y) - ); + : Panel(gui, size, padding, 0.0f) { + if (size.x < 0.0f || size.y < 0.0f) { + setContentSize({text.length() * 8, 16}); + } else { + setSize(size); } - setSize(size); if (action) { listenAction(action); @@ -50,13 +48,12 @@ Button::Button( label = std::make_shared