mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2024-11-22 16:57:00 +00:00
Return Bool when appropriate (#11)
I also updated the main functions to use (/=0) instead of (==1).
This commit is contained in:
parent
e4b75e355f
commit
d227561885
@ -265,7 +265,7 @@ styleColorsClassic = liftIO do
|
|||||||
begin :: MonadIO m => String -> m Bool
|
begin :: MonadIO m => String -> m Bool
|
||||||
begin name = liftIO do
|
begin name = liftIO do
|
||||||
withCString name \namePtr ->
|
withCString name \namePtr ->
|
||||||
(1 ==) <$> [C.exp| bool { ImGui::Begin($(char* namePtr)) } |]
|
(0 /=) <$> [C.exp| bool { ImGui::Begin($(char* namePtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Pop window from the stack.
|
-- | Pop window from the stack.
|
||||||
@ -308,7 +308,7 @@ text t = liftIO do
|
|||||||
button :: MonadIO m => String -> m Bool
|
button :: MonadIO m => String -> m Bool
|
||||||
button label = liftIO do
|
button label = liftIO do
|
||||||
withCString label \labelPtr ->
|
withCString label \labelPtr ->
|
||||||
(1 ==) <$> [C.exp| bool { Button($(char* labelPtr)) } |]
|
(0 /=) <$> [C.exp| bool { Button($(char* labelPtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Button with @FramePadding=(0,0)@ to easily embed within text.
|
-- | Button with @FramePadding=(0,0)@ to easily embed within text.
|
||||||
@ -317,7 +317,7 @@ button label = liftIO do
|
|||||||
smallButton :: MonadIO m => String -> m Bool
|
smallButton :: MonadIO m => String -> m Bool
|
||||||
smallButton label = liftIO do
|
smallButton label = liftIO do
|
||||||
withCString label \labelPtr ->
|
withCString label \labelPtr ->
|
||||||
(1 ==) <$> [C.exp| bool { SmallButton($(char* labelPtr)) } |]
|
(0 /=) <$> [C.exp| bool { SmallButton($(char* labelPtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Square button with an arrow shape.
|
-- | Square button with an arrow shape.
|
||||||
@ -326,7 +326,7 @@ smallButton label = liftIO do
|
|||||||
arrowButton :: MonadIO m => String -> ImGuiDir -> m Bool
|
arrowButton :: MonadIO m => String -> ImGuiDir -> m Bool
|
||||||
arrowButton strId (ImGuiDir dir) = liftIO do
|
arrowButton strId (ImGuiDir dir) = liftIO do
|
||||||
withCString strId \strIdPtr ->
|
withCString strId \strIdPtr ->
|
||||||
(1 ==) <$> [C.exp| bool { ArrowButton($(char* strIdPtr), $(int dir)) } |]
|
(0 /=) <$> [C.exp| bool { ArrowButton($(char* strIdPtr), $(int dir)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui::Checkbox()@.
|
-- | Wraps @ImGui::Checkbox()@.
|
||||||
@ -335,7 +335,7 @@ checkbox label ref = liftIO do
|
|||||||
currentValue <- get ref
|
currentValue <- get ref
|
||||||
with (bool 0 1 currentValue :: CBool) \boolPtr -> do
|
with (bool 0 1 currentValue :: CBool) \boolPtr -> do
|
||||||
changed <- withCString label \labelPtr ->
|
changed <- withCString label \labelPtr ->
|
||||||
(1 ==) <$> [C.exp| bool { Checkbox($(char* labelPtr), $(bool* boolPtr)) } |]
|
(0 /=) <$> [C.exp| bool { Checkbox($(char* labelPtr), $(bool* boolPtr)) } |]
|
||||||
|
|
||||||
newValue <- peek boolPtr
|
newValue <- peek boolPtr
|
||||||
ref $=! (newValue == 1)
|
ref $=! (newValue == 1)
|
||||||
@ -369,7 +369,7 @@ beginCombo :: MonadIO m => String -> String -> m Bool
|
|||||||
beginCombo label previewValue = liftIO $
|
beginCombo label previewValue = liftIO $
|
||||||
withCString label \labelPtr ->
|
withCString label \labelPtr ->
|
||||||
withCString previewValue \previewValuePtr ->
|
withCString previewValue \previewValuePtr ->
|
||||||
(1 ==) <$> [C.exp| bool { BeginCombo($(char* labelPtr), $(char* previewValuePtr)) } |]
|
(0 /=) <$> [C.exp| bool { BeginCombo($(char* labelPtr), $(char* previewValuePtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Only call 'endCombo' if 'beginCombon' returns 'True'!
|
-- | Only call 'endCombo' if 'beginCombon' returns 'True'!
|
||||||
@ -386,7 +386,7 @@ colorPicker3 desc ref = liftIO do
|
|||||||
ImVec3{x, y, z} <- get ref
|
ImVec3{x, y, z} <- get ref
|
||||||
withArray (realToFrac <$> [x, y, z]) \refPtr -> do
|
withArray (realToFrac <$> [x, y, z]) \refPtr -> do
|
||||||
changed <- withCString desc \descPtr ->
|
changed <- withCString desc \descPtr ->
|
||||||
(1 == ) <$> [C.exp| bool { ColorPicker3( $(char* descPtr), $(float *refPtr) ) } |]
|
(0 /= ) <$> [C.exp| bool { ColorPicker3( $(char* descPtr), $(float *refPtr) ) } |]
|
||||||
|
|
||||||
[x', y', z'] <- peekArray 3 refPtr
|
[x', y', z'] <- peekArray 3 refPtr
|
||||||
ref $=! ImVec3 (realToFrac x') (realToFrac y') (realToFrac z')
|
ref $=! ImVec3 (realToFrac x') (realToFrac y') (realToFrac z')
|
||||||
@ -399,7 +399,7 @@ sliderFloat desc ref minValue maxValue = liftIO do
|
|||||||
currentValue <- get ref
|
currentValue <- get ref
|
||||||
with (realToFrac currentValue) \floatPtr -> do
|
with (realToFrac currentValue) \floatPtr -> do
|
||||||
changed <- withCString desc \descPtr ->
|
changed <- withCString desc \descPtr ->
|
||||||
(1 ==) <$> [C.exp| bool { SliderFloat( $(char* descPtr), $(float *floatPtr), $(float min'), $(float max')) } |]
|
(0 /=) <$> [C.exp| bool { SliderFloat( $(char* descPtr), $(float *floatPtr), $(float min'), $(float max')) } |]
|
||||||
|
|
||||||
newValue <- peek floatPtr
|
newValue <- peek floatPtr
|
||||||
ref $=! realToFrac newValue
|
ref $=! realToFrac newValue
|
||||||
@ -418,7 +418,7 @@ colorButton desc ref = liftIO do
|
|||||||
currentValue <- get ref
|
currentValue <- get ref
|
||||||
with currentValue \refPtr -> do
|
with currentValue \refPtr -> do
|
||||||
changed <- withCString desc \descPtr ->
|
changed <- withCString desc \descPtr ->
|
||||||
(1 == ) <$> [C.exp| bool { ColorButton( $(char* descPtr), *$(ImVec4 *refPtr) ) } |]
|
(0 /=) <$> [C.exp| bool { ColorButton( $(char* descPtr), *$(ImVec4 *refPtr) ) } |]
|
||||||
|
|
||||||
newValue <- peek refPtr
|
newValue <- peek refPtr
|
||||||
ref $=! newValue
|
ref $=! newValue
|
||||||
@ -430,7 +430,7 @@ colorButton desc ref = liftIO do
|
|||||||
selectable :: MonadIO m => String -> m Bool
|
selectable :: MonadIO m => String -> m Bool
|
||||||
selectable label = liftIO do
|
selectable label = liftIO do
|
||||||
withCString label \labelPtr ->
|
withCString label \labelPtr ->
|
||||||
(1 == ) <$> [C.exp| bool { Selectable($(char* labelPtr)) } |]
|
(0 /=) <$> [C.exp| bool { Selectable($(char* labelPtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui::PlotHistogram()@.
|
-- | Wraps @ImGui::PlotHistogram()@.
|
||||||
@ -448,7 +448,7 @@ plotHistogram label values = liftIO $
|
|||||||
-- Wraps @ImGui::BeginMenuBar()@.
|
-- Wraps @ImGui::BeginMenuBar()@.
|
||||||
beginMenuBar :: MonadIO m => m Bool
|
beginMenuBar :: MonadIO m => m Bool
|
||||||
beginMenuBar = liftIO do
|
beginMenuBar = liftIO do
|
||||||
(1 == ) <$> [C.exp| bool { BeginMenuBar() } |]
|
(0 /=) <$> [C.exp| bool { BeginMenuBar() } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Only call 'endMenuBar' if 'beginMenuBar' returns true!
|
-- | Only call 'endMenuBar' if 'beginMenuBar' returns true!
|
||||||
@ -464,7 +464,7 @@ endMenuBar = liftIO do
|
|||||||
-- Wraps @ImGui::BeginMainMenuBar()@.
|
-- Wraps @ImGui::BeginMainMenuBar()@.
|
||||||
beginMainMenuBar :: MonadIO m => m Bool
|
beginMainMenuBar :: MonadIO m => m Bool
|
||||||
beginMainMenuBar = liftIO do
|
beginMainMenuBar = liftIO do
|
||||||
(1 == ) <$> [C.exp| bool { BeginMainMenuBar() } |]
|
(0 /=) <$> [C.exp| bool { BeginMainMenuBar() } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Only call 'endMainMenuBar' if 'beginMainMenuBar' returns true!
|
-- | Only call 'endMainMenuBar' if 'beginMainMenuBar' returns true!
|
||||||
@ -481,7 +481,7 @@ endMainMenuBar = liftIO do
|
|||||||
beginMenu :: MonadIO m => String -> m Bool
|
beginMenu :: MonadIO m => String -> m Bool
|
||||||
beginMenu label = liftIO do
|
beginMenu label = liftIO do
|
||||||
withCString label \labelPtr ->
|
withCString label \labelPtr ->
|
||||||
(1 == ) <$> [C.exp| bool { BeginMenu($(char* labelPtr)) } |]
|
(0 /=) <$> [C.exp| bool { BeginMenu($(char* labelPtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Only call 'endMenu' if 'beginMenu' returns true!
|
-- | Only call 'endMenu' if 'beginMenu' returns true!
|
||||||
@ -499,7 +499,7 @@ endMenu = liftIO do
|
|||||||
menuItem :: MonadIO m => String -> m Bool
|
menuItem :: MonadIO m => String -> m Bool
|
||||||
menuItem label = liftIO do
|
menuItem label = liftIO do
|
||||||
withCString label \labelPtr ->
|
withCString label \labelPtr ->
|
||||||
(1 ==) <$> [C.exp| bool { MenuItem($(char* labelPtr)) } |]
|
(0 /=) <$> [C.exp| bool { MenuItem($(char* labelPtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Begin/append a tooltip window to create full-featured tooltip (with any
|
-- | Begin/append a tooltip window to create full-featured tooltip (with any
|
||||||
@ -523,7 +523,7 @@ endTooltip = liftIO do
|
|||||||
beginPopup :: MonadIO m => String -> m Bool
|
beginPopup :: MonadIO m => String -> m Bool
|
||||||
beginPopup popupId = liftIO do
|
beginPopup popupId = liftIO do
|
||||||
withCString popupId \popupIdPtr ->
|
withCString popupId \popupIdPtr ->
|
||||||
(1 ==) <$> [C.exp| bool { BeginPopup($(char* popupIdPtr)) } |]
|
(0 /=) <$> [C.exp| bool { BeginPopup($(char* popupIdPtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Returns 'True' if the modal is open, and you can start outputting to it.
|
-- | Returns 'True' if the modal is open, and you can start outputting to it.
|
||||||
@ -532,7 +532,7 @@ beginPopup popupId = liftIO do
|
|||||||
beginPopupModal :: MonadIO m => String -> m Bool
|
beginPopupModal :: MonadIO m => String -> m Bool
|
||||||
beginPopupModal popupId = liftIO do
|
beginPopupModal popupId = liftIO do
|
||||||
withCString popupId \popupIdPtr ->
|
withCString popupId \popupIdPtr ->
|
||||||
(1 ==) <$> [C.exp| bool { BeginPopupModal($(char* popupIdPtr)) } |]
|
(0 /=) <$> [C.exp| bool { BeginPopupModal($(char* popupIdPtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Only call 'endPopup' if 'beginPopup' or 'beginPopupModal' returns 'True'!
|
-- | Only call 'endPopup' if 'beginPopup' or 'beginPopupModal' returns 'True'!
|
||||||
@ -565,7 +565,7 @@ closeCurrentPopup = liftIO do
|
|||||||
-- Wraps @ImGui::IsItemHovered()@
|
-- Wraps @ImGui::IsItemHovered()@
|
||||||
isItemHovered :: MonadIO m => m Bool
|
isItemHovered :: MonadIO m => m Bool
|
||||||
isItemHovered = liftIO do
|
isItemHovered = liftIO do
|
||||||
(1 ==) <$> [C.exp| bool { IsItemHovered() } |]
|
(0 /=) <$> [C.exp| bool { IsItemHovered() } |]
|
||||||
|
|
||||||
|
|
||||||
-- | A cardinal direction.
|
-- | A cardinal direction.
|
||||||
|
@ -42,9 +42,9 @@ Cpp.using "namespace ImGui"
|
|||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui_ImplOpenGL2_Init@.
|
-- | Wraps @ImGui_ImplOpenGL2_Init@.
|
||||||
openGL2Init :: MonadIO m => m ()
|
openGL2Init :: MonadIO m => m Bool
|
||||||
openGL2Init = liftIO do
|
openGL2Init = liftIO do
|
||||||
[C.exp| void { ImGui_ImplOpenGL2_Init(); } |]
|
( 0 /= ) <$> [C.exp| bool { ImGui_ImplOpenGL2_Init() } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui_ImplOpenGL2_Shutdown@.
|
-- | Wraps @ImGui_ImplOpenGL2_Shutdown@.
|
||||||
|
@ -49,9 +49,9 @@ Cpp.using "namespace ImGui"
|
|||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui_ImplSDL2_InitForOpenGL@.
|
-- | Wraps @ImGui_ImplSDL2_InitForOpenGL@.
|
||||||
sdl2InitForOpenGL :: MonadIO m => Window -> GLContext -> m ()
|
sdl2InitForOpenGL :: MonadIO m => Window -> GLContext -> m Bool
|
||||||
sdl2InitForOpenGL (Window windowPtr) glContext = liftIO do
|
sdl2InitForOpenGL (Window windowPtr) glContext = liftIO do
|
||||||
[C.exp| void { ImGui_ImplSDL2_InitForOpenGL((SDL_Window*)$(void* windowPtr), $(void* glContextPtr)); } |]
|
( 0 /= ) <$> [C.exp| bool { ImGui_ImplSDL2_InitForOpenGL((SDL_Window*)$(void* windowPtr), $(void* glContextPtr)) } |]
|
||||||
where
|
where
|
||||||
glContextPtr :: Ptr ()
|
glContextPtr :: Ptr ()
|
||||||
glContextPtr = unsafeCoerce glContext
|
glContextPtr = unsafeCoerce glContext
|
||||||
|
Loading…
Reference in New Issue
Block a user