Skip to content

Commit

Permalink
app: cleaning settings window class
Browse files Browse the repository at this point in the history
  • Loading branch information
quesnel committed Oct 11, 2024
1 parent ab96729 commit c9f70ea
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 30 deletions.
4 changes: 3 additions & 1 deletion app/gui/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,9 @@ class project_window
child_id m_selected_child = undefined<child_id>();
};

struct settings_window {
class settings_window
{
public:
constexpr static inline const char* name = "Settings";

settings_window() noexcept = default;
Expand Down
7 changes: 1 addition & 6 deletions app/gui/settings-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<gui_theme_id>();
Expand Down
28 changes: 5 additions & 23 deletions lib/include/irritator/global.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ struct rgba_color {

template<std::floating_point T>
constexpr rgba_color(T r_, T g_, T b_, T a_ = 255) noexcept
: r{ static_cast<u8>(std::clamp(r_* T{ 255 }, T{ 0 }, T{ 255 })) }
, g{ static_cast<u8>(std::clamp(g_* T{ 255 }, T{ 0 }, T{ 255 })) }
, b{ static_cast<u8>(std::clamp(b_* T{ 255 }, T{ 0 }, T{ 255 })) }
, a{ static_cast<u8>(std::clamp(a_* T{ 255 }, T{ 0 }, T{ 255 })) }
: r{ static_cast<u8>(std::clamp(r_ * T{ 255 }, T{ 0 }, T{ 255 })) }
, g{ static_cast<u8>(std::clamp(g_ * T{ 255 }, T{ 0 }, T{ 255 })) }
, b{ static_cast<u8>(std::clamp(b_ * T{ 255 }, T{ 0 }, T{ 255 })) }
, a{ static_cast<u8>(std::clamp(a_ * T{ 255 }, T{ 0 }, T{ 255 })) }
{}

std::uint8_t r, g, b, a;
Expand Down Expand Up @@ -129,25 +129,7 @@ struct recorded_paths {
vector<small_string<31>> names;
vector<int> priorities;

vector<recorded_path_id> sort_by_priorities() const noexcept
{
vector<recorded_path_id> 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<recorded_path_id> sort_by_priorities() const noexcept;
};

struct variables {
Expand Down
20 changes: 20 additions & 0 deletions lib/src/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,26 @@ static std::error_code do_load(const char* filename,
return do_parse(vars, latest);
}

vector<recorded_path_id> recorded_paths::sort_by_priorities() const noexcept
{
vector<recorded_path_id> 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() }
{}
Expand Down

0 comments on commit c9f70ea

Please sign in to comment.