From 7d4f3a8b936c3c99a1b5ce0043034ea31e256338 Mon Sep 17 00:00:00 2001 From: Alexander Bondarenko <486682+dpwiz@users.noreply.github.com> Date: Wed, 23 Mar 2022 21:22:05 +0300 Subject: [PATCH] Make value and read-only range types distinct (#143) Fixes #142 --- src/DearImGui.hs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/DearImGui.hs b/src/DearImGui.hs index 86add16..69559f9 100644 --- a/src/DearImGui.hs +++ b/src/DearImGui.hs @@ -847,8 +847,8 @@ dragIntRange2 desc refMin refMax speed minValue maxValue minFmt maxFmt = liftIO return changed dragScalar - :: (HasSetter ref a, HasGetter ref a, Storable a, MonadIO m) - => String -> ImGuiDataType -> ref -> Float -> ref -> ref -> String -> ImGuiSliderFlags -> m Bool + :: (HasSetter ref a, HasGetter ref a, HasGetter range a, Storable a, MonadIO m) + => String -> ImGuiDataType -> ref -> Float -> range -> range -> String -> ImGuiSliderFlags -> m Bool dragScalar label dataType ref vSpeed refMin refMax format flags = liftIO do currentValue <- get ref minValue <- get refMin @@ -877,8 +877,8 @@ dragScalar label dataType ref vSpeed refMin refMax format flags = liftIO do return changed dragScalarN - :: (HasSetter valueRef [a], HasGetter valueRef [a], HasGetter rangeRef a, Storable a, MonadIO m) - => String -> ImGuiDataType -> valueRef -> Float -> rangeRef -> rangeRef -> String -> ImGuiSliderFlags -> m Bool + :: (HasSetter ref [a], HasGetter ref [a], HasGetter range a, Storable a, MonadIO m) + => String -> ImGuiDataType -> ref -> Float -> range -> range -> String -> ImGuiSliderFlags -> m Bool dragScalarN label dataType ref vSpeed refMin refMax format flags = liftIO do currentValues <- get ref minValue <- get refMin @@ -908,8 +908,8 @@ dragScalarN label dataType ref vSpeed refMin refMax format flags = liftIO do return changed sliderScalar - :: (HasSetter ref a, HasGetter ref a, Storable a, MonadIO m) - => String -> ImGuiDataType -> ref -> ref -> ref -> String -> ImGuiSliderFlags -> m Bool + :: (HasGetter ref a, HasSetter ref a, HasGetter range a, Storable a, MonadIO m) + => String -> ImGuiDataType -> ref -> range -> range -> String -> ImGuiSliderFlags -> m Bool sliderScalar label dataType ref refMin refMax format flags = liftIO do currentValue <- get ref minValue <- get refMin @@ -937,8 +937,8 @@ sliderScalar label dataType ref refMin refMax format flags = liftIO do return changed sliderScalarN - :: (HasSetter valueRef [a], HasGetter valueRef [a], HasGetter rangeRef a, Storable a, MonadIO m) - => String -> ImGuiDataType -> valueRef -> rangeRef -> rangeRef -> String -> ImGuiSliderFlags -> m Bool + :: (HasSetter value [a], HasGetter value [a], HasGetter range a, Storable a, MonadIO m) + => String -> ImGuiDataType -> value -> range -> range -> String -> ImGuiSliderFlags -> m Bool sliderScalarN label dataType ref refMin refMax format flags = liftIO do currentValues <- get ref minValue <- get refMin @@ -1187,8 +1187,8 @@ vSliderInt label size ref minValue maxValue = liftIO do return changed vSliderScalar - :: (HasSetter ref a, HasGetter ref a, Storable a, MonadIO m) - => String -> ImVec2 -> ImGuiDataType -> ref -> ref -> ref -> String -> ImGuiSliderFlags -> m Bool + :: (HasSetter ref a, HasGetter ref a, HasGetter range a, Storable a, MonadIO m) + => String -> ImVec2 -> ImGuiDataType -> ref -> range -> range -> String -> ImGuiSliderFlags -> m Bool vSliderScalar label size dataType ref refMin refMax format flags = liftIO do currentValue <- get ref minValue <- get refMin @@ -1885,7 +1885,12 @@ withCStringOrNull (Just s) k = withCString s k -- | Set next window position. Call before `begin` Use pivot=(0.5,0.5) to center on given point, etc. -- -- Wraps @ImGui::SetNextWindowPos()@ -setNextWindowPos :: (MonadIO m, HasGetter ref ImVec2) => ref -> ImGuiCond -> Maybe ref -> m () +setNextWindowPos + :: (MonadIO m, HasGetter ref ImVec2) + => ref + -> ImGuiCond + -> Maybe ref -- XXX: the type should be distinct, but using `setNextWindowPos .. Nothing` is ambiguous resulting in bad UX. + -> m () setNextWindowPos posRef cond pivotMaybe = liftIO do pos <- get posRef with pos $ \posPtr ->