diff --git a/include/wayfire/util/duration.hpp b/include/wayfire/util/duration.hpp index e33d042..61fecd7 100644 --- a/include/wayfire/util/duration.hpp +++ b/include/wayfire/util/duration.hpp @@ -2,7 +2,7 @@ #include #include #include - +#include namespace wf { @@ -23,6 +23,8 @@ extern smooth_function linear; extern smooth_function circle; /** "sigmoid" smoothing function, i.e x -> 1.0 / (1 + exp(-12 * x + 6)) */ extern smooth_function sigmoid; + +std::vector get_available_smooth_functions(); } } diff --git a/src/duration.cpp b/src/duration.cpp index 9473cb5..fb61430 100644 --- a/src/duration.cpp +++ b/src/duration.cpp @@ -265,7 +265,25 @@ smooth_function ease_out_elastic = [] (double x) -> double return (a * std::pow(2, -10 * x) * std::sin((x * d - s) * (2 * std::acos(-1)) / p) + 1.0); }; + +static const std::map easing_map = { + {"linear", animation::smoothing::linear}, + {"circle", animation::smoothing::circle}, + {"sigmoid", animation::smoothing::sigmoid}, + {"easeOutElastic", animation::smoothing::ease_out_elastic}, +}; + +std::vector get_available_smooth_functions() +{ + std::vector result; + for (auto& func : easing_map) + { + result.push_back(func.first); + } + + return result; } +} // namespace smoothing } namespace option_type @@ -303,14 +321,7 @@ std::optional from_string(cons result.easing_name = "circle"; } - static const std::map easing_map = { - {"linear", animation::smoothing::linear}, - {"circle", animation::smoothing::circle}, - {"sigmoid", animation::smoothing::sigmoid}, - {"easeOutElastic", animation::smoothing::ease_out_elastic}, - }; - - if (!easing_map.count(result.easing_name)) + if (!animation::smoothing::easing_map.count(result.easing_name)) { return {}; } @@ -322,7 +333,7 @@ std::optional from_string(cons return {}; } - result.easing = easing_map.at(result.easing_name); + result.easing = animation::smoothing::easing_map.at(result.easing_name); if (suffix == "s") { result.length_ms = N * 1000;