From dc6c9ac94bf8e2a8a78c8d4c1cd03fce1164b94c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Sun, 28 Jul 2024 12:57:36 -0400 Subject: [PATCH] [core] Add missing file --- src/lib/score/graphics/DefaultControlImpl.hpp | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/lib/score/graphics/DefaultControlImpl.hpp diff --git a/src/lib/score/graphics/DefaultControlImpl.hpp b/src/lib/score/graphics/DefaultControlImpl.hpp new file mode 100644 index 0000000000..5c1e9ec48a --- /dev/null +++ b/src/lib/score/graphics/DefaultControlImpl.hpp @@ -0,0 +1,40 @@ +#pragma once +#include +#include +#include +#include + +namespace score +{ +struct DefaultControlImpl +{ + static void editWidgetInContextMenu( + auto& self, QGraphicsScene* scene, QGraphicsItem* obj, double v) + { + self.m_value = self.unmap(v); + + QPointer p{&self}; + if constexpr(requires { self.m_noValueChangeOnMove; }) + { + if(!self.m_noValueChangeOnMove) + self.sliderMoved(); + } + else + { + self.sliderMoved(); + } + + if(p) + { + self.update(); + } + else + { + QTimer::singleShot(0, &self, [scene, obj] { + scene->removeItem(obj); + delete obj; + }); + } + } +}; +}