mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2024-11-22 16:57:00 +00:00
Add more withXXX wrappers (#82)
- withStyleColor - withStyleVar - withIndent - withItemWidth Closes #63
This commit is contained in:
parent
d3a0396623
commit
8d07a5a42b
@ -64,8 +64,11 @@ module DearImGui
|
|||||||
, Raw.endChild
|
, Raw.endChild
|
||||||
|
|
||||||
-- * Parameter stacks
|
-- * Parameter stacks
|
||||||
|
, withStyleColor
|
||||||
, pushStyleColor
|
, pushStyleColor
|
||||||
, Raw.popStyleColor
|
, Raw.popStyleColor
|
||||||
|
|
||||||
|
, withStyleVar
|
||||||
, pushStyleVar
|
, pushStyleVar
|
||||||
, popStyleVar
|
, popStyleVar
|
||||||
|
|
||||||
@ -75,9 +78,13 @@ module DearImGui
|
|||||||
, Raw.newLine
|
, Raw.newLine
|
||||||
, Raw.spacing
|
, Raw.spacing
|
||||||
, dummy
|
, dummy
|
||||||
|
|
||||||
|
, withIndent
|
||||||
, indent
|
, indent
|
||||||
, unindent
|
, unindent
|
||||||
|
|
||||||
, setNextItemWidth
|
, setNextItemWidth
|
||||||
|
, withItemWidth
|
||||||
, pushItemWidth
|
, pushItemWidth
|
||||||
, Raw.popItemWidth
|
, Raw.popItemWidth
|
||||||
|
|
||||||
@ -1420,6 +1427,9 @@ dummy sizeRef = liftIO do
|
|||||||
size' <- get sizeRef
|
size' <- get sizeRef
|
||||||
with size' Raw.dummy
|
with size' Raw.dummy
|
||||||
|
|
||||||
|
withIndent :: MonadUnliftIO m => Float -> m a -> m a
|
||||||
|
withIndent width =
|
||||||
|
bracket_ (indent width) (unindent width)
|
||||||
|
|
||||||
-- | Move content position toward the right, by indent_w, or style.IndentSpacing if indent_w <= 0
|
-- | Move content position toward the right, by indent_w, or style.IndentSpacing if indent_w <= 0
|
||||||
--
|
--
|
||||||
@ -1445,6 +1455,10 @@ setNextItemWidth itemWidth = liftIO do
|
|||||||
Raw.setNextItemWidth (CFloat itemWidth)
|
Raw.setNextItemWidth (CFloat itemWidth)
|
||||||
|
|
||||||
|
|
||||||
|
withItemWidth :: MonadUnliftIO m => Float -> m a -> m a
|
||||||
|
withItemWidth width =
|
||||||
|
bracket_ (pushItemWidth width) Raw.popItemWidth
|
||||||
|
|
||||||
-- Wraps @ImGui::PushItemWidth()@
|
-- Wraps @ImGui::PushItemWidth()@
|
||||||
pushItemWidth :: (MonadIO m) => Float -> m ()
|
pushItemWidth :: (MonadIO m) => Float -> m ()
|
||||||
pushItemWidth itemWidth = liftIO do
|
pushItemWidth itemWidth = liftIO do
|
||||||
@ -1504,7 +1518,13 @@ instance ToID (Ptr CChar, Int) where
|
|||||||
instance ToID String where
|
instance ToID String where
|
||||||
pushID s = liftIO $ withCStringLen s pushID
|
pushID s = liftIO $ withCStringLen s pushID
|
||||||
|
|
||||||
-- | Modify a style color by pushing to the shared stack. always use this if you modify the style after `newFrame`
|
withStyleColor :: (MonadUnliftIO m, HasGetter ref ImVec4) => ImGuiCol -> ref -> m a -> m a
|
||||||
|
withStyleColor color ref =
|
||||||
|
bracket_ (pushStyleColor color ref) (Raw.popStyleColor 1)
|
||||||
|
|
||||||
|
-- | Modify a style color by pushing to the shared stack.
|
||||||
|
--
|
||||||
|
-- Always use this if you modify the style after `newFrame`.
|
||||||
--
|
--
|
||||||
-- Wraps @ImGui::PushStyleColor()@
|
-- Wraps @ImGui::PushStyleColor()@
|
||||||
pushStyleColor :: (MonadIO m, HasGetter ref ImVec4) => ImGuiCol -> ref -> m ()
|
pushStyleColor :: (MonadIO m, HasGetter ref ImVec4) => ImGuiCol -> ref -> m ()
|
||||||
@ -1513,8 +1533,13 @@ pushStyleColor col colorRef = liftIO do
|
|||||||
with color \colorPtr ->
|
with color \colorPtr ->
|
||||||
Raw.pushStyleColor col colorPtr
|
Raw.pushStyleColor col colorPtr
|
||||||
|
|
||||||
|
withStyleVar :: (MonadUnliftIO m, HasGetter ref ImVec2) => ImGuiStyleVar -> ref -> m a -> m a
|
||||||
|
withStyleVar style ref =
|
||||||
|
bracket_ (pushStyleVar style ref) (Raw.popStyleVar 1)
|
||||||
|
|
||||||
-- | Modify a style variable by pushing to the shared stack. always use this if you modify the style after `newFrame`
|
-- | Modify a style variable by pushing to the shared stack.
|
||||||
|
--
|
||||||
|
-- Always use this if you modify the style after `newFrame`.
|
||||||
--
|
--
|
||||||
-- Wraps @ImGui::PushStyleVar()@
|
-- Wraps @ImGui::PushStyleVar()@
|
||||||
pushStyleVar :: (MonadIO m, HasGetter ref ImVec2) => ImGuiStyleVar -> ref -> m ()
|
pushStyleVar :: (MonadIO m, HasGetter ref ImVec2) => ImGuiStyleVar -> ref -> m ()
|
||||||
@ -1523,7 +1548,6 @@ pushStyleVar style valRef = liftIO do
|
|||||||
with val \valPtr ->
|
with val \valPtr ->
|
||||||
Raw.pushStyleVar style valPtr
|
Raw.pushStyleVar style valPtr
|
||||||
|
|
||||||
|
|
||||||
-- | Remove style variable modifications from the shared stack
|
-- | Remove style variable modifications from the shared stack
|
||||||
--
|
--
|
||||||
-- Wraps @ImGui::PopStyleVar()@
|
-- Wraps @ImGui::PopStyleVar()@
|
||||||
|
Loading…
Reference in New Issue
Block a user