mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2024-12-22 20:56:36 +00:00
Remove seg faults (#87)
* Removed double OpenGl3Shutdown, leading to a segmentation fault in Main.hs. * Changed nullPtr passing with Maybe to use DearImGui default arguments.
This commit is contained in:
parent
cede825dff
commit
08b3139477
2
Main.hs
2
Main.hs
@ -38,8 +38,6 @@ main = do
|
||||
tab2 <- newIORef True
|
||||
loop w checked color slider r pos size' selected tab1 tab2
|
||||
|
||||
openGL3Shutdown
|
||||
|
||||
|
||||
loop
|
||||
:: Window
|
||||
|
@ -283,7 +283,7 @@ getVersion = liftIO do
|
||||
begin :: MonadIO m => String -> m Bool
|
||||
begin name = liftIO do
|
||||
withCString name \namePtr ->
|
||||
Raw.begin namePtr nullPtr (ImGuiWindowFlags 0)
|
||||
Raw.begin namePtr Nothing Nothing
|
||||
|
||||
-- | Append items to a window.
|
||||
--
|
||||
@ -315,7 +315,7 @@ withFullscreen action = bracket open close (`when` action)
|
||||
open = liftIO do
|
||||
Raw.setNextWindowFullscreen
|
||||
withCString "FullScreen" \namePtr ->
|
||||
Raw.begin namePtr nullPtr fullscreenFlags
|
||||
Raw.begin namePtr (Just nullPtr) (Just fullscreenFlags)
|
||||
|
||||
close = liftIO . const Raw.end
|
||||
|
||||
@ -357,7 +357,7 @@ withChildOpen name action =
|
||||
text :: MonadIO m => String -> m ()
|
||||
text t = liftIO do
|
||||
withCString t \textPtr ->
|
||||
Raw.textUnformatted textPtr nullPtr
|
||||
Raw.textUnformatted textPtr Nothing
|
||||
|
||||
-- | Colored text.
|
||||
textColored :: (HasGetter ref ImVec4, MonadIO m) => ref -> String -> m ()
|
||||
@ -1369,9 +1369,9 @@ setNextWindowPos posRef cond pivotMaybe = liftIO do
|
||||
Just pivotRef -> do
|
||||
pivot <- get pivotRef
|
||||
with pivot $ \pivotPtr ->
|
||||
Raw.setNextWindowPos posPtr cond pivotPtr
|
||||
Raw.setNextWindowPos posPtr cond (Just pivotPtr)
|
||||
Nothing ->
|
||||
Raw.setNextWindowPos posPtr cond nullPtr
|
||||
Raw.setNextWindowPos posPtr cond Nothing
|
||||
|
||||
-- | Set next window size. Call before `begin`
|
||||
--
|
||||
|
@ -346,10 +346,14 @@ styleColorsClassic = liftIO do
|
||||
--
|
||||
-- Passing non-null @Ptr CBool@ shows a window-closing widget in the upper-right corner of the window,
|
||||
-- wich clicking will set the boolean to false when clicked.
|
||||
begin :: (MonadIO m) => CString -> Ptr CBool -> ImGuiWindowFlags -> m Bool
|
||||
begin namePtr openPtr flags = liftIO do
|
||||
begin :: (MonadIO m) => CString -> Maybe (Ptr CBool) -> Maybe (ImGuiWindowFlags) -> m Bool
|
||||
begin namePtr (Just openPtr) (Just flags) = liftIO do
|
||||
(0 /=) <$> [C.exp| bool { Begin($(char* namePtr), $(bool* openPtr), $(ImGuiWindowFlags flags)) } |]
|
||||
|
||||
begin namePtr (Just openPtr) Nothing = liftIO do
|
||||
(0 /=) <$> [C.exp| bool { Begin($(char* namePtr), $(bool* openPtr)) } |]
|
||||
begin namePtr Nothing Nothing = liftIO do
|
||||
(0 /=) <$> [C.exp| bool { Begin($(char* namePtr)) } |]
|
||||
begin _ Nothing _ = error "C++ default argument restriction."
|
||||
|
||||
-- | Pop window from the stack.
|
||||
--
|
||||
@ -394,9 +398,11 @@ sameLine = liftIO do
|
||||
-- B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text.
|
||||
--
|
||||
-- Wraps @ImGui::TextUnformatted()@.
|
||||
textUnformatted :: (MonadIO m) => CString -> CString -> m ()
|
||||
textUnformatted textPtr textEndPtr = liftIO do
|
||||
textUnformatted :: (MonadIO m) => CString -> Maybe CString -> m ()
|
||||
textUnformatted textPtr (Just textEndPtr) = liftIO do
|
||||
[C.exp| void { TextUnformatted($(char* textPtr), $(char* textEndPtr)) } |]
|
||||
textUnformatted textPtr Nothing = liftIO do
|
||||
[C.exp| void { TextUnformatted($(char* textPtr)) } |]
|
||||
|
||||
-- | Shortcut for @PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();@.
|
||||
--
|
||||
@ -1086,9 +1092,11 @@ isItemHovered = liftIO do
|
||||
-- | 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) => Ptr ImVec2 -> ImGuiCond -> Ptr ImVec2 -> m ()
|
||||
setNextWindowPos posPtr cond pivotPtr = liftIO do
|
||||
setNextWindowPos :: (MonadIO m) => Ptr ImVec2 -> ImGuiCond -> Maybe (Ptr ImVec2) -> m ()
|
||||
setNextWindowPos posPtr cond (Just pivotPtr) = liftIO do
|
||||
[C.exp| void { SetNextWindowPos(*$(ImVec2* posPtr), $(ImGuiCond cond), *$(ImVec2* pivotPtr)) } |]
|
||||
setNextWindowPos posPtr cond Nothing = liftIO do
|
||||
[C.exp| void { SetNextWindowPos(*$(ImVec2* posPtr), $(ImGuiCond cond)) } |]
|
||||
|
||||
|
||||
-- | Set next window size. Call before `begin`
|
||||
|
Loading…
Reference in New Issue
Block a user