Fix TabItem flags type (#183)

Resolves #175
This commit is contained in:
Alexander Bondarenko 2023-07-20 19:42:11 +03:00 committed by GitHub
parent 6dbb455d62
commit 8df98e075c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View File

@ -79,10 +79,10 @@ loop window checked color slider r pos size' selected tab1Ref tab2Ref = do
text "Hello!" text "Hello!"
beginTabBar "My tab bar" ImGuiTabBarFlags_Reorderable >>= whenTrue do beginTabBar "My tab bar" ImGuiTabBarFlags_Reorderable >>= whenTrue do
beginTabItem "Tab 1" tab1Ref ImGuiTabBarFlags_None >>= whenTrue do beginTabItem "Tab 1" tab1Ref ImGuiTabItemFlags_None >>= whenTrue do
text "Tab 1 is currently selected." text "Tab 1 is currently selected."
endTabItem endTabItem
beginTabItem "Tab 2" tab2Ref ImGuiTabBarFlags_None >>= whenTrue do beginTabItem "Tab 2" tab2Ref ImGuiTabItemFlags_None >>= whenTrue do
text "Tab 2 is selected now." text "Tab 2 is selected now."
endTabItem endTabItem
reOpen <- tabItemButton "ReopenTabs" ImGuiTabItemFlags_Trailing reOpen <- tabItemButton "ReopenTabs" ImGuiTabItemFlags_Trailing

View File

@ -1690,7 +1690,7 @@ withTabBarOpen tabBarID flags action =
-- | Create a new tab. Returns @True@ if the tab is selected. -- | Create a new tab. Returns @True@ if the tab is selected.
-- --
-- Wraps @ImGui::BeginTabItem@. -- Wraps @ImGui::BeginTabItem@.
beginTabItem :: (MonadIO m, HasGetter ref Bool, HasSetter ref Bool) => Text -> ref -> ImGuiTabBarFlags -> m Bool beginTabItem :: (MonadIO m, HasGetter ref Bool, HasSetter ref Bool) => Text -> ref -> ImGuiTabItemFlags -> m Bool
beginTabItem tabName ref flags = liftIO do beginTabItem tabName ref flags = liftIO do
currentValue <- get ref currentValue <- get ref
with (bool 0 1 currentValue) \refPtr -> do with (bool 0 1 currentValue) \refPtr -> do
@ -1706,14 +1706,14 @@ beginTabItem tabName ref flags = liftIO do
-- | Create a new tab. -- | Create a new tab.
-- --
-- The action will get 'True' if the tab is selected. -- The action will get 'True' if the tab is selected.
withTabItem :: (MonadUnliftIO m, HasGetter ref Bool, HasSetter ref Bool) => Text -> ref -> ImGuiTabBarFlags -> (Bool -> m a) -> m a withTabItem :: (MonadUnliftIO m, HasGetter ref Bool, HasSetter ref Bool) => Text -> ref -> ImGuiTabItemFlags -> (Bool -> m a) -> m a
withTabItem tabName ref flags = withTabItem tabName ref flags =
bracket (beginTabItem tabName ref flags) (`when` Raw.endTabItem) bracket (beginTabItem tabName ref flags) (`when` Raw.endTabItem)
-- | Create a new tab. -- | Create a new tab.
-- --
-- The action will be skipped unless the tab is selected. -- The action will be skipped unless the tab is selected.
withTabItemOpen :: (MonadUnliftIO m, HasGetter ref Bool, HasSetter ref Bool) => Text -> ref -> ImGuiTabBarFlags -> m () -> m () withTabItemOpen :: (MonadUnliftIO m, HasGetter ref Bool, HasSetter ref Bool) => Text -> ref -> ImGuiTabItemFlags -> m () -> m ()
withTabItemOpen tabName ref flags action = withTabItemOpen tabName ref flags action =
withTabItem tabName ref flags (`when` action) withTabItem tabName ref flags (`when` action)

View File

@ -1346,9 +1346,9 @@ endTabBar = liftIO do
-- | Create a new tab. Returns @True@ if the tab is selected. -- | Create a new tab. Returns @True@ if the tab is selected.
-- --
-- Wraps @ImGui::BeginTabItem@. -- Wraps @ImGui::BeginTabItem@.
beginTabItem :: (MonadIO m) => CString -> Ptr CBool -> ImGuiTabBarFlags -> m Bool beginTabItem :: (MonadIO m) => CString -> Ptr CBool -> ImGuiTabItemFlags -> m Bool
beginTabItem namePtr refPtr flags = liftIO do beginTabItem namePtr refPtr flags = liftIO do
(0 /=) <$> [C.exp| bool { BeginTabItem($(char* namePtr), $(bool* refPtr), $(ImGuiTabBarFlags flags) ) } |] (0 /=) <$> [C.exp| bool { BeginTabItem($(char* namePtr), $(bool* refPtr), $(ImGuiTabItemFlags flags) ) } |]
-- | Finish appending elements to a tab. Only call if 'beginTabItem' returns @True@. -- | Finish appending elements to a tab. Only call if 'beginTabItem' returns @True@.