From c9f70ead9f8694ff3641adf4d5aa49aa3bf9b11f Mon Sep 17 00:00:00 2001 From: Gauthier Quesnel Date: Fri, 11 Oct 2024 10:46:53 +0200 Subject: [PATCH] app: cleaning settings window class --- app/gui/application.hpp | 4 +++- app/gui/settings-window.cpp | 7 +------ lib/include/irritator/global.hpp | 28 +++++----------------------- lib/src/global.cpp | 20 ++++++++++++++++++++ 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/app/gui/application.hpp b/app/gui/application.hpp index 6aa3eca0..833e7170 100644 --- a/app/gui/application.hpp +++ b/app/gui/application.hpp @@ -809,7 +809,9 @@ class project_window child_id m_selected_child = undefined(); }; -struct settings_window { +class settings_window +{ +public: constexpr static inline const char* name = "Settings"; settings_window() noexcept = default; diff --git a/app/gui/settings-window.cpp b/app/gui/settings-window.cpp index 291db744..7aa7dc96 100644 --- a/app/gui/settings-window.cpp +++ b/app/gui/settings-window.cpp @@ -12,16 +12,11 @@ namespace irt { -constexpr auto to_C(const rgba_color x) noexcept -> int +static constexpr auto to_C(const rgba_color x) noexcept -> int { return IM_COL32(x.r, x.g, x.b, x.a); } -constexpr auto to(const rgba_color x) noexcept -> int -{ - return IM_COL32(x.r, x.g, x.b, 255); -} - static auto display_themes_selector(application& app) noexcept -> bool { auto theme_id = undefined(); diff --git a/lib/include/irritator/global.hpp b/lib/include/irritator/global.hpp index 103cf414..47130e01 100644 --- a/lib/include/irritator/global.hpp +++ b/lib/include/irritator/global.hpp @@ -38,10 +38,10 @@ struct rgba_color { template constexpr rgba_color(T r_, T g_, T b_, T a_ = 255) noexcept - : r{ static_cast(std::clamp(r_* T{ 255 }, T{ 0 }, T{ 255 })) } - , g{ static_cast(std::clamp(g_* T{ 255 }, T{ 0 }, T{ 255 })) } - , b{ static_cast(std::clamp(b_* T{ 255 }, T{ 0 }, T{ 255 })) } - , a{ static_cast(std::clamp(a_* T{ 255 }, T{ 0 }, T{ 255 })) } + : r{ static_cast(std::clamp(r_ * T{ 255 }, T{ 0 }, T{ 255 })) } + , g{ static_cast(std::clamp(g_ * T{ 255 }, T{ 0 }, T{ 255 })) } + , b{ static_cast(std::clamp(b_ * T{ 255 }, T{ 0 }, T{ 255 })) } + , a{ static_cast(std::clamp(a_ * T{ 255 }, T{ 0 }, T{ 255 })) } {} std::uint8_t r, g, b, a; @@ -129,25 +129,7 @@ struct recorded_paths { vector> names; vector priorities; - vector sort_by_priorities() const noexcept - { - vector ret(ids.size()); - - if (ids.capacity() >= ids.ssize()) { - for (auto id : ids) - ret.emplace_back(id); - - std::sort( - ret.begin(), ret.end(), [&](const auto a, const auto b) noexcept { - const auto idx_a = get_index(a); - const auto idx_b = get_index(b); - - return idx_a < idx_b; - }); - } - - return ret; - } + vector sort_by_priorities() const noexcept; }; struct variables { diff --git a/lib/src/global.cpp b/lib/src/global.cpp index a4fd8e65..65daf8c9 100644 --- a/lib/src/global.cpp +++ b/lib/src/global.cpp @@ -670,6 +670,26 @@ static std::error_code do_load(const char* filename, return do_parse(vars, latest); } +vector recorded_paths::sort_by_priorities() const noexcept +{ + vector ret(ids.size()); + + if (ids.capacity() >= ids.ssize()) { + for (auto id : ids) + ret.emplace_back(id); + + std::sort( + ret.begin(), ret.end(), [&](const auto a, const auto b) noexcept { + const auto idx_a = get_index(a); + const auto idx_b = get_index(b); + + return priorities[idx_a] < priorities[idx_b]; + }); + } + + return ret; +} + config_manager::config_manager() noexcept : m_vars{ do_build_default() } {}