Commit graph

6 commits

Author SHA1 Message Date
CMDRNuffin
66fde2d458 Prevent unnecessary string creation in ImGui TextInput methods
We now only create a new string if we either know the buffer changed or
the EnterReturnsTrue flag was set (because that one does a LOT while
still updating the buffer on every actual input), so I had to choose
between replicating all that behavior in each of the various InputText
methods (hell no, lol), scanning the buffer for actual changes (which
would require making another copy) or accepting that in that case we
would create a new string every frame.

This still makes the GC happy in the majority of cases, while giving
callers the option to take a slight performance hit for the convenience
EnterReturnsTrue provides.
2025-12-20 03:19:20 +01:00
goaaats
c7dd694a53 Revert "Prevent ImGui text box methods from cloning unchanged input every frame"
This reverts commit db5f27518f.
Causes issues with certain flags.
2025-12-20 02:02:57 +01:00
CMDRNuffin
db5f27518f Prevent ImGui text box methods from cloning unchanged input every frame
The overloads taking a string by ref for the input text of the various
ways to display a text box would all take the input string, copy it into
a buffer for imgui and then unconditionally produce a new string once
the imgui call returned. Now we only create a new string when the return
value of the native function actually indicates that the text changed.

This makes the GC happy, and also users like me who like to make the GC
happy.

Other side effects: The assumption that the reference doesn't change if
the method returns false, which is very reasonable IMO, is now correct.
2025-12-19 01:24:43 +01:00
Soreepeong
afe58dae76 Make ImU8String not IDisposable 2025-08-09 08:23:38 +09:00
Soreepeong
cc21480d21 Add overloads for InputText which callbacks take Ptr instead 2025-08-09 08:23:38 +09:00
srkizer
c69329f592
Manual overloads for ImGui functions accepting text (#2319)
* wip2

* Implement AutoUtf8Buffer

* reformat

* Work on manual bindings

* restructure

* Name scripts properly

* Update utility functions to use ImU8String

* add overloads

* Add more overloads

* Use ImGuiWindow from gen, support AddCallback

* Use LibraryImport for custom ImGuiNative functinos

* Make manual overloads for string-returning functinos

* Make all overloads with self as its first parameter extension methods

* Fix overload resolution by removing unnecessary

* in => scoped in

* Fix compilation errors
2025-08-04 11:14:00 -07:00