summaryrefslogtreecommitdiff
path: root/ui/modeHelper.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-04-02 23:22:12 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2025-04-02 23:22:12 +0100
commit2245fc8a3bb521afc2e6dd575cd1757ecab23558 (patch)
treec4565e14b2e9b01c970b3ee5816f6ec849b61e92 /ui/modeHelper.h
parentMerge remote-tracking branch 'origin/ptrs' (diff)
parentRemove the old unused network.png icon (diff)
downloadilt-2245fc8a3bb521afc2e6dd575cd1757ecab23558.tar.bz2
ilt-2245fc8a3bb521afc2e6dd575cd1757ecab23558.tar.xz
ilt-2245fc8a3bb521afc2e6dd575cd1757ecab23558.zip
Merge branch 'imgui'HEADmain
Diffstat (limited to 'ui/modeHelper.h')
-rw-r--r--ui/modeHelper.h40
1 files changed, 0 insertions, 40 deletions
diff --git a/ui/modeHelper.h b/ui/modeHelper.h
deleted file mode 100644
index d20f2db..0000000
--- a/ui/modeHelper.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#pragma once
-
-#include <memory>
-union SDL_Event;
-
-enum ModeSecondClick { Unset, Reset, NoAction };
-
-template<typename Target, ModeSecondClick msc = ModeSecondClick::Unset> class Mode {
-public:
- explicit Mode(Target & t) : target {t} { }
-
- Target & target;
-
- template<typename Mode, typename... Params>
- auto
- toggle(Params &&... params)
- {
- return [params..., this](const SDL_Event &) {
- toggleSetMode<Mode>(std::forward<Params>(params)...);
- };
- }
-
-private:
- template<typename Mode, typename... Params>
- void
- toggleSetMode(Params &&... params)
- {
- if (dynamic_cast<Mode *>(target.get())) {
- if constexpr (msc == ModeSecondClick::Unset) {
- target.reset();
- }
- if constexpr (msc == ModeSecondClick::Reset) {
- target = std::make_unique<Mode>(std::forward<Params>(params)...);
- }
- }
- else {
- target = std::make_unique<Mode>(std::forward<Params>(params)...);
- }
- }
-};