Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose flags to widgets #154

Closed
ailrk opened this issue Aug 1, 2022 · 5 comments
Closed

Expose flags to widgets #154

ailrk opened this issue Aug 1, 2022 · 5 comments
Labels
duplicate This issue or pull request already exists

Comments

@ailrk
Copy link

ailrk commented Aug 1, 2022

Hey all,
I'm trying to make an inputText that returns true when an enter is hit, which requires the ImGuiInputTextFlags_EnterReturnsTrue flag. I notice all flags are already there, but most widgets are set with a default value instead of exposing it to the public interface, I find it is a bit limiting. Is there a reason for this? e.g for this piece:

dear-imgui.hs/src/DearImGui.hs

Lines 1216 to 1224 in 7795b3d

-- | Wraps @ImGui::InputText()@.
inputText :: (MonadIO m, HasSetter ref Text, HasGetter ref Text) => Text -> ref -> Int -> m Bool
inputText label ref bufSize =
withInputString ref bufSize \bufPtrLen ->
Text.withCString label \labelPtr ->
Raw.inputText
labelPtr
bufPtrLen
ImGuiInputTextFlags_None

Can we expose the flag as an option to the user like this?

 inputText :: (MonadIO m, HasSetter ref Text, HasGetter ref Text) => Text -> ref -> Int -> ImGuiInputTextFlags -> m Bool 
@dpwiz
Copy link
Member

dpwiz commented Aug 1, 2022

This is a known limitation. Alas, a satisfactory implementation is yet to be found.

Previously: #61, #52, #33

@dpwiz
Copy link
Member

dpwiz commented Aug 1, 2022

The "high level" bindings are optimized for the most common case. You can use raw bindings for the extra bits, or clone existing wrappers and tweak them.

@ailrk
Copy link
Author

ailrk commented Aug 1, 2022

Thank you, I might need to write things like withInputString again because it's not exposed but I guess it's ok.

@ailrk ailrk closed this as completed Aug 1, 2022
@dpwiz dpwiz added the duplicate This issue or pull request already exists label Aug 1, 2022
@Drezil
Copy link
Contributor

Drezil commented Aug 2, 2022

Addendum:
We had this discussion at length already in March. And that time we ended up with the following code:
https://github.com/haskell-game/dear-imgui.hs/blob/main/src/DearImGui.hs#L1549-L1573

See #137 for the corresponding PR

@ailrk i think a PR in the style of #137 should be no problem to merge if you need things :)

@ailrk
Copy link
Author

ailrk commented Aug 12, 2022

Addendum: We had this discussion at length already in March. And that time we ended up with the following code: https://github.com/haskell-game/dear-imgui.hs/blob/main/src/DearImGui.hs#L1549-L1573

See #137 for the corresponding PR

@ailrk i think a PR in the style of #137 should be no problem to merge if you need things :)

Thanks, I'm happy to contribute once I get some spare time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants