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