mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2024-12-22 04:36:35 +00:00
parent
6dbb455d62
commit
8df98e075c
4
Main.hs
4
Main.hs
@ -79,10 +79,10 @@ loop window checked color slider r pos size' selected tab1Ref tab2Ref = do
|
||||
text "Hello!"
|
||||
|
||||
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."
|
||||
endTabItem
|
||||
beginTabItem "Tab 2" tab2Ref ImGuiTabBarFlags_None >>= whenTrue do
|
||||
beginTabItem "Tab 2" tab2Ref ImGuiTabItemFlags_None >>= whenTrue do
|
||||
text "Tab 2 is selected now."
|
||||
endTabItem
|
||||
reOpen <- tabItemButton "ReopenTabs" ImGuiTabItemFlags_Trailing
|
||||
|
@ -1690,7 +1690,7 @@ withTabBarOpen tabBarID flags action =
|
||||
-- | Create a new tab. Returns @True@ if the tab is selected.
|
||||
--
|
||||
-- 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
|
||||
currentValue <- get ref
|
||||
with (bool 0 1 currentValue) \refPtr -> do
|
||||
@ -1706,14 +1706,14 @@ beginTabItem tabName ref flags = liftIO do
|
||||
-- | Create a new tab.
|
||||
--
|
||||
-- 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 =
|
||||
bracket (beginTabItem tabName ref flags) (`when` Raw.endTabItem)
|
||||
|
||||
-- | Create a new tab.
|
||||
--
|
||||
-- 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 =
|
||||
withTabItem tabName ref flags (`when` action)
|
||||
|
||||
|
@ -1346,9 +1346,9 @@ endTabBar = liftIO do
|
||||
-- | Create a new tab. Returns @True@ if the tab is selected.
|
||||
--
|
||||
-- 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
|
||||
(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@.
|
||||
|
Loading…
Reference in New Issue
Block a user