mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2024-11-22 00:47:00 +00:00
Add support for disabled blocks (#196)
This commit is contained in:
parent
49f7bb245e
commit
f6cad45dab
@ -279,6 +279,11 @@ module DearImGui
|
|||||||
, Raw.beginTooltip
|
, Raw.beginTooltip
|
||||||
, Raw.endTooltip
|
, Raw.endTooltip
|
||||||
|
|
||||||
|
-- ** Disabled blocks
|
||||||
|
, withDisabled
|
||||||
|
, Raw.beginDisabled
|
||||||
|
, Raw.endDisabled
|
||||||
|
|
||||||
-- * Popups/Modals
|
-- * Popups/Modals
|
||||||
|
|
||||||
-- ** Generic
|
-- ** Generic
|
||||||
@ -1763,6 +1768,17 @@ setTabItemClosed tabName = liftIO do
|
|||||||
withTooltip :: MonadUnliftIO m => m a -> m a
|
withTooltip :: MonadUnliftIO m => m a -> m a
|
||||||
withTooltip = bracket_ Raw.beginTooltip Raw.endTooltip
|
withTooltip = bracket_ Raw.beginTooltip Raw.endTooltip
|
||||||
|
|
||||||
|
|
||||||
|
-- | Action wrapper for disabled blocks.
|
||||||
|
--
|
||||||
|
-- See 'Raw.beginDisabled' and 'Raw.endDisabled' for more info.
|
||||||
|
withDisabled :: (MonadUnliftIO m, HasGetter ref Bool) => ref -> m a -> m a
|
||||||
|
withDisabled disabledRef action = do
|
||||||
|
disabled <- get disabledRef
|
||||||
|
if disabled then bracket_ (Raw.beginDisabled 1) Raw.endDisabled action else action
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- | Returns 'True' if the popup is open, and you can start outputting to it.
|
-- | Returns 'True' if the popup is open, and you can start outputting to it.
|
||||||
--
|
--
|
||||||
-- Wraps @ImGui::BeginPopup()@
|
-- Wraps @ImGui::BeginPopup()@
|
||||||
|
@ -65,6 +65,8 @@ module DearImGui.Raw
|
|||||||
, setNextWindowSizeConstraints
|
, setNextWindowSizeConstraints
|
||||||
, setNextWindowCollapsed
|
, setNextWindowCollapsed
|
||||||
, setNextWindowBgAlpha
|
, setNextWindowBgAlpha
|
||||||
|
, beginDisabled
|
||||||
|
, endDisabled
|
||||||
|
|
||||||
-- ** Child Windows
|
-- ** Child Windows
|
||||||
, beginChild
|
, beginChild
|
||||||
@ -1582,6 +1584,29 @@ setNextWindowBgAlpha alpha = liftIO do
|
|||||||
[C.exp| void { SetNextWindowBgAlpha($(float alpha)) } |]
|
[C.exp| void { SetNextWindowBgAlpha($(float alpha)) } |]
|
||||||
|
|
||||||
|
|
||||||
|
-- | Begin a block that may be disabled. This disables all user interactions
|
||||||
|
-- and dims item visuals.
|
||||||
|
--
|
||||||
|
-- Always call a matching 'endDisabled' for each 'beginDisabled' call.
|
||||||
|
--
|
||||||
|
-- The boolean argument is only intended to facilitate use of boolean
|
||||||
|
-- expressions. If you can avoid calling @beginDisabled 0@ altogether,
|
||||||
|
-- that should be preferred.
|
||||||
|
--
|
||||||
|
-- Wraps @ImGui::BeginDisabled()@
|
||||||
|
beginDisabled :: (MonadIO m) => CBool -> m ()
|
||||||
|
beginDisabled disabled = liftIO do
|
||||||
|
[C.exp| void { BeginDisabled($(bool disabled)) } |]
|
||||||
|
|
||||||
|
|
||||||
|
-- | Ends a block that may be disabled.
|
||||||
|
--
|
||||||
|
-- Wraps @ImGui::EndDisabled()@
|
||||||
|
endDisabled :: (MonadIO m) => m ()
|
||||||
|
endDisabled = liftIO do
|
||||||
|
[C.exp| void { EndDisabled() } |]
|
||||||
|
|
||||||
|
|
||||||
-- | undo a sameLine or force a new line when in an horizontal-layout context.
|
-- | undo a sameLine or force a new line when in an horizontal-layout context.
|
||||||
--
|
--
|
||||||
-- Wraps @ImGui::NewLine()@
|
-- Wraps @ImGui::NewLine()@
|
||||||
|
Loading…
Reference in New Issue
Block a user