haskell-game / dear-imgui.hs

Haskell bindings to Dear ImGui, an immediate mode GUI toolkit
BSD 3-Clause "New" or "Revised" License
142 stars 31 forks source link

Expose flags to widgets #154

Closed ailrk closed 2 years ago

ailrk commented 2 years ago

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:

https://github.com/haskell-game/dear-imgui.hs/blob/7795b3d838b10427ed31d164b641d6f0c241b955/src/DearImGui.hs#L1216-L1224

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 commented 2 years ago

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

Previously: #61, #52, #33

dpwiz commented 2 years ago

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 commented 2 years ago

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

Drezil commented 2 years ago

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 https://github.com/haskell-game/dear-imgui.hs/pull/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 commented 2 years ago

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.