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

Provide wrapped functions with all the options exposed #61

Open dpwiz opened 3 years ago

dpwiz commented 3 years ago

A follow-up to #52, but can be done concurrently.

The current functions can remain intact and a new set of functions can be added as a cheap wrapper for raw procedures.

-- current
withWindowOpen :: MonadUnliftIO m => String -> m () -> m ()

-- proposed
withWindowOpen' :: (MonadUnliftIO m, StateVar Bool isOpen) => ImGuiWindowFlags -> isOpen -> String -> m () -> m ()

Fancy wrappers (labels, lenses, etc.) can be provided as alternatives in their own packages.

Cons: this will double the amount of functions published. The previous implementation, however, can be rebased upon those new expanded.

Alternative 1: Add all the arguments to existing functions. A breaking change, a bit noisier to write but lighter on maintenance.

Alternative 2: Rename current shortcuts to underscored, add expanded versions like in A1. Also a breaking change and may require breakage again when "expandable defaults" are to be implemented.

chekoopa commented 2 years ago

It is possible to put expanded version in a separate module, so "sensible default" shortcuts would stay at their place, and special scenarios could incorporate something like DearImGui.LowLevel.

UPD: As DearImGui.Raw exists already, we would expand them, and then add aforementioned LowLevel module, on which sensible defaults are built.