diff options
Diffstat (limited to 'include/cru/platform/painter_util.hpp')
-rw-r--r-- | include/cru/platform/painter_util.hpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/cru/platform/painter_util.hpp b/include/cru/platform/painter_util.hpp index fed0c487..5711d099 100644 --- a/include/cru/platform/painter_util.hpp +++ b/include/cru/platform/painter_util.hpp @@ -2,13 +2,17 @@ #include "painter.hpp" #include <functional> +#include <type_traits> namespace cru::platform::util { +template <typename Fn> inline void WithTransform(Painter* painter, const Matrix& matrix, - const std::function<void(Painter*)>& action) { + const Fn& action) { + static_assert(std::is_invocable_v<decltype(action), Painter*>, + "Action must can be be invoked with painter."); const auto old = painter->GetTransform(); painter->SetTransform(old * matrix); action(painter); painter->SetTransform(old); } -} +} // namespace cru::platform::util |