Add remaining BeginChild arguments as required (#93)

Old behaviour with all default arguments is a special case to run
some action scoped to a different child window.

This now handled by `beginChildContext`/`withChildContext`.
This commit is contained in:
Alexander Bondarenko
2021-09-12 13:28:48 +03:00
committed by GitHub
parent c219f8eb4f
commit c7a694bce8
3 changed files with 83 additions and 18 deletions

View File

@ -66,6 +66,7 @@ module DearImGui.Raw
-- ** Child Windows
, beginChild
, beginChildContext
, endChild
-- * Parameter stacks
@ -390,11 +391,47 @@ end = liftIO do
[C.exp| void { End(); } |]
-- | Wraps @ImGui::BeginChild()@.
beginChild :: (MonadIO m) => CString -> m Bool
beginChild namePtr = liftIO do
(0 /=) <$> [C.exp| bool { BeginChild($(char* namePtr)) } |]
-- | Begin a self-contained independent scrolling/clipping regions within a host window.
--
-- Child windows can embed their own child.
--
-- For each independent axis of @size@:
-- * ==0.0f: use remaining host window size
-- * >0.0f: fixed size
-- * <0.0f: use remaining window size minus abs(size)
--
-- Each axis can use a different mode, e.g. @ImVec2 0 400@.
--
-- @BeginChild()@ returns `False` to indicate the window is collapsed or fully clipped, so you may early out and omit submitting anything to the window.
--
-- Always call a matching `endChild` for each `beginChild` call, regardless of its return value.
--
-- Wraps @ImGui::BeginChild()@.
beginChild :: (MonadIO m) => CString -> Ptr ImVec2 -> CBool -> ImGuiWindowFlags -> m Bool
beginChild namePtr sizePtr border flags = liftIO do
(0 /=) <$> [C.exp|
bool {
BeginChild(
$(char* namePtr),
*$(ImVec2* sizePtr),
$(bool border),
$(ImGuiWindowFlags flags)
)
}
|]
-- | Switch context to another child window by its ID
--
-- Wraps @ImGui::BeginChild()@.
beginChildContext :: (MonadIO m) => CString -> m Bool
beginChildContext namePtr = liftIO do
(0 /=) <$> [C.exp|
bool {
BeginChild(
$(char* namePtr)
)
}
|]
-- | Wraps @ImGui::EndChild()@.
endChild :: (MonadIO m) => m ()