mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2024-11-22 16:57:00 +00:00
added options to selectable (#137)
This commit is contained in:
parent
fc307a4d6e
commit
f066d03017
@ -190,6 +190,9 @@ module DearImGui
|
|||||||
|
|
||||||
-- ** Selectables
|
-- ** Selectables
|
||||||
, selectable
|
, selectable
|
||||||
|
, selectableWith
|
||||||
|
, SelectableOptions(..)
|
||||||
|
, defSelectableOptions
|
||||||
|
|
||||||
-- ** List Boxes
|
-- ** List Boxes
|
||||||
, listBox
|
, listBox
|
||||||
@ -1284,10 +1287,25 @@ treePush label = liftIO do
|
|||||||
withCString label Raw.treePush
|
withCString label Raw.treePush
|
||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui::Selectable()@.
|
-- | Wraps @ImGui::Selectable()@ with default options.
|
||||||
selectable :: MonadIO m => String -> m Bool
|
selectable :: MonadIO m => String -> m Bool
|
||||||
selectable label = liftIO do
|
selectable = selectableWith defSelectableOptions
|
||||||
withCString label Raw.selectable
|
|
||||||
|
data SelectableOptions = SelectableOptions
|
||||||
|
{ selected :: Bool
|
||||||
|
, flags :: ImGuiSelectableFlags
|
||||||
|
, size :: ImVec2
|
||||||
|
} deriving Show
|
||||||
|
|
||||||
|
defSelectableOptions :: SelectableOptions
|
||||||
|
defSelectableOptions = SelectableOptions False (ImGuiSelectableFlags 0) (ImVec2 0 0)
|
||||||
|
|
||||||
|
-- | Wraps @ImGui::Selectable()@ with explicit options.
|
||||||
|
selectableWith :: MonadIO m => SelectableOptions -> String -> m Bool
|
||||||
|
selectableWith (SelectableOptions selected flags size) label = liftIO do
|
||||||
|
with size $ \sizePtr ->
|
||||||
|
withCString label $ \labelPtr ->
|
||||||
|
Raw.selectable labelPtr (bool 0 1 selected) flags sizePtr
|
||||||
|
|
||||||
|
|
||||||
listBox :: (MonadIO m, HasGetter ref Int, HasSetter ref Int) => String -> ref -> [String] -> m Bool
|
listBox :: (MonadIO m, HasGetter ref Int, HasSetter ref Int) => String -> ref -> [String] -> m Bool
|
||||||
|
@ -1086,10 +1086,17 @@ treePop = liftIO do
|
|||||||
[C.exp| void { TreePop() } |]
|
[C.exp| void { TreePop() } |]
|
||||||
|
|
||||||
|
|
||||||
|
-- -- | Wraps @ImGui::Selectable()@.
|
||||||
|
-- selectable :: (MonadIO m) => CString -> m Bool
|
||||||
|
-- selectable labelPtr = liftIO do
|
||||||
|
-- (0 /=) <$> [C.exp| bool { Selectable($(char* labelPtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui::Selectable()@.
|
-- | Wraps @ImGui::Selectable()@.
|
||||||
selectable :: (MonadIO m) => CString -> m Bool
|
selectable :: (MonadIO m) => CString -> CBool -> ImGuiSelectableFlags -> Ptr ImVec2 -> m Bool
|
||||||
selectable labelPtr = liftIO do
|
selectable labelPtr selected flags size = liftIO do
|
||||||
(0 /=) <$> [C.exp| bool { Selectable($(char* labelPtr)) } |]
|
(0 /=) <$> [C.exp| bool { Selectable($(char* labelPtr), $(bool selected), $(ImGuiSelectableFlags flags), *$(ImVec2 *size)) } |]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui::ListBox()@.
|
-- | Wraps @ImGui::ListBox()@.
|
||||||
|
Loading…
Reference in New Issue
Block a user