mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-22 07:36:35 +00:00
Merge branch 'master' into viewport
# Conflicts: # imgui.cpp
This commit is contained in:
commit
b0fb340b57
@ -37,24 +37,27 @@ HOW TO UPDATE?
|
|||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
VERSION 1.61 WIP
|
VERSION 1.61 (Released 2018-05-14)
|
||||||
|
|
||||||
Breaking Changes:
|
Breaking Changes:
|
||||||
(IN PROGRESS, WILL ADD TO THIS LIST AS WE WORK ON 1.61)
|
|
||||||
|
|
||||||
- DragInt: The default compile-time format string has been changed from "%.0f" to "%d", we are not using integers internally any more.
|
- DragInt(): The default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally any more.
|
||||||
If you used DragInt() with custom format strings, make sure you change them to use %d or an integer-compatible format.
|
If you used DragInt() with custom format strings, make sure you change them to use %d or an integer-compatible format.
|
||||||
To honor backward-compatibility, the DragInt() code will currently parse and modify format strings to replace %*f with %d, giving time to users to upgrade their code.
|
To honor backward-compatibility, the DragInt() code will currently parse and modify format strings to replace %*f with %d, giving time to users to upgrade their code.
|
||||||
If you have IMGUI_DISABLE_OBSOLETE_FUNCTIONS enabled, the code will instead assert! You may run a reg-exp search on your codebase for e.g. "DragInt.*%f" to you find them.
|
If you have IMGUI_DISABLE_OBSOLETE_FUNCTIONS enabled, the code will instead assert! You may run a reg-exp search on your codebase for e.g. "DragInt.*%f" to you find them.
|
||||||
- Misc: IM_DELETE() helper function added in 1.60 doesn't set the input pointer to NULL, more consistent with standard expectation and allows passing r-value.
|
- InputFloat(): Obsoleted InputFloat() functions taking an optional "int decimal_precision" in favor of an equivalent and more flexible "const char* format",
|
||||||
|
consistent with other functions. Kept redirection functions (will obsolete).
|
||||||
|
- Misc: IM_DELETE() helper function added in 1.60 doesn't set the input pointer to NULL, more consistent with standard expectation and allows passing r-values.
|
||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
(IN PROGRESS, WILL ADD TO THIS LIST AS WE WORK ON 1.61)
|
|
||||||
|
|
||||||
- Window: Fixed default proportional item width lagging by one frame on resize.
|
- Added DragScalar, DragScalarN: supports signed/unsigned, 32/64 bits, float/double data types. (#643, #320, #708, #1011)
|
||||||
|
- Added InputScalar, InputScalarN: supports signed/unsigned, 32/64 bits, float/double data types. (#643, #320, #708, #1011)
|
||||||
|
- Added SliderScalar, SliderScalarN: supports signed/unsigned, 32/64 bits, float/double data types. (#643, #320, #708, #1011)
|
||||||
- Window: Fixed pop-ups/tooltips/menus not honoring style.DisplaySafeAreaPadding as well as it should have (part of menus displayed outside the safe area, etc.).
|
- Window: Fixed pop-ups/tooltips/menus not honoring style.DisplaySafeAreaPadding as well as it should have (part of menus displayed outside the safe area, etc.).
|
||||||
- Window: Fixed windows using the ImGuiWindowFlags_NoSavedSettings flag from not using the same default position as other windows. (#1760)
|
- Window: Fixed windows using the ImGuiWindowFlags_NoSavedSettings flag from not using the same default position as other windows. (#1760)
|
||||||
- Window: Relaxed the internal stack size checker to allow Push/Begin/Pop/.../End patterns to be used with PushStyleColor, PushStyleVar, PushFont without causing a false positive assert. (#1767)
|
- Window: Relaxed the internal stack size checker to allow Push/Begin/Pop/.../End patterns to be used with PushStyleColor, PushStyleVar, PushFont without causing a false positive assert. (#1767)
|
||||||
|
- Window: Fixed the default proportional item width lagging by one frame on resize.
|
||||||
- Columns: Fixed a bug introduced in 1.51 where columns would affect the contents size of their container, often creating feedback loops when ImGuiWindowFlags_AlwaysAutoResize was used. (#1760)
|
- Columns: Fixed a bug introduced in 1.51 where columns would affect the contents size of their container, often creating feedback loops when ImGuiWindowFlags_AlwaysAutoResize was used. (#1760)
|
||||||
- Settings: Fixed saving an empty .ini file if CreateContext/DestroyContext are called without a single call to NewFrame(). (#1741)
|
- Settings: Fixed saving an empty .ini file if CreateContext/DestroyContext are called without a single call to NewFrame(). (#1741)
|
||||||
- Settings: Added LoadIniSettingsFromDisk(), LoadIniSettingsFromMemory(), SaveIniSettingsToDisk(), SaveIniSettingsToMemory() to manually load/save .ini settings. (#923, #993)
|
- Settings: Added LoadIniSettingsFromDisk(), LoadIniSettingsFromMemory(), SaveIniSettingsToDisk(), SaveIniSettingsToMemory() to manually load/save .ini settings. (#923, #993)
|
||||||
@ -63,12 +66,9 @@ Other Changes:
|
|||||||
- MenuBar: Made BeginMainMenuBar() honor style.DisplaySafeAreaPadding so the text can be made visible on TV settings that don't display all pixels. (#1439) [@dougbinks]
|
- MenuBar: Made BeginMainMenuBar() honor style.DisplaySafeAreaPadding so the text can be made visible on TV settings that don't display all pixels. (#1439) [@dougbinks]
|
||||||
- InputText: On Mac OS X, filter out characters when the CMD modifier is held. (#1747) [@sivu]
|
- InputText: On Mac OS X, filter out characters when the CMD modifier is held. (#1747) [@sivu]
|
||||||
- InputText: On Mac OS X, support CMD+SHIFT+Z for Redo. CMD+Y is also supported as major apps seems to default to support both. (#1765) [@lfnoise]
|
- InputText: On Mac OS X, support CMD+SHIFT+Z for Redo. CMD+Y is also supported as major apps seems to default to support both. (#1765) [@lfnoise]
|
||||||
- InputText: Fixed returning true when edition is canceled with ESC and the current buffer matches the initial value.
|
- InputText: Fixed returning true when edition is cancelled with ESC and the current buffer matches the initial value.
|
||||||
- InputFloat,InputFloat2,InputFloat3,InputFloat4: Added variations taking a more flexible and consistent optional "const char* format" parameter instead of "int decimal_precision".
|
- InputFloat,InputFloat2,InputFloat3,InputFloat4: Added variations taking a more flexible and consistent optional "const char* format" parameter instead of "int decimal_precision".
|
||||||
This allow using custom formats to display values in scientific notation, and is generally more consistent with other API. Obsoleted functions using the optional "int decimal_precision" parameter. (#648)
|
This allow using custom formats to display values in scientific notation, and is generally more consistent with other API. Obsoleted functions using the optional "int decimal_precision" parameter. (#648)
|
||||||
- Added DragScalar, DragScalarN: supports signed/unsigned, 32/64 bits, float/double data types. (#320, #643, #708, #1011)
|
|
||||||
- Added InputScalar, InputScalarN: supports signed/unsigned, 32/64 bits, float/double data types. (#320, #643, #708, #1011)
|
|
||||||
- Added SliderScalar, SliderScalarN: supports signed/unsigned, 32/64 bits, float/double data types. (#320, #643, #708, #1011)
|
|
||||||
- DragFloat, DragInt: Cancel mouse tweak when current value is initially past the min/max boundaries and mouse is pushing in the same direction (keyboard/gamepad version already did this).
|
- DragFloat, DragInt: Cancel mouse tweak when current value is initially past the min/max boundaries and mouse is pushing in the same direction (keyboard/gamepad version already did this).
|
||||||
- DragFloat, DragInt: Honor natural type limits (e.g. INT_MAX, FLT_MAX) instead of wrapping around. (#708, #320)
|
- DragFloat, DragInt: Honor natural type limits (e.g. INT_MAX, FLT_MAX) instead of wrapping around. (#708, #320)
|
||||||
- DragFloat, SliderFloat: Fixes to allow input of scientific notation numbers when using CTRL+Click to input the value. (~#648, #1011)
|
- DragFloat, SliderFloat: Fixes to allow input of scientific notation numbers when using CTRL+Click to input the value. (~#648, #1011)
|
||||||
@ -76,13 +76,16 @@ Other Changes:
|
|||||||
- DragFloat: Improved computation when using the power curve. Improved lost of input precision with very small steps. Added an assert than power-curve requires a min/max range. (~#642)
|
- DragFloat: Improved computation when using the power curve. Improved lost of input precision with very small steps. Added an assert than power-curve requires a min/max range. (~#642)
|
||||||
- DragFloat: The 'power' parameter is only honored if the min/max parameter are also setup.
|
- DragFloat: The 'power' parameter is only honored if the min/max parameter are also setup.
|
||||||
- DragInt, SliderInt: Fixed handling of large integers (we previously passed data around internally as float, which reduced the range of valid integers).
|
- DragInt, SliderInt: Fixed handling of large integers (we previously passed data around internally as float, which reduced the range of valid integers).
|
||||||
|
- ColorEdit: Fixed not being able to pass the ImGuiColorEditFlags_NoAlpha or ImGuiColorEditFlags_HDR flags to SetColorEditOptions().
|
||||||
- Nav: Fixed hovering a Selectable() with the mouse so that it update the navigation cursor (as it happened in the pre-1.60 navigation branch). (#787)
|
- Nav: Fixed hovering a Selectable() with the mouse so that it update the navigation cursor (as it happened in the pre-1.60 navigation branch). (#787)
|
||||||
- Style: Changed default style.DisplaySafeAreaPadding values from (4,4) to (3,3) so it is smaller than FramePadding and has no effect on main menu bar on a computer. (#1439)
|
- Style: Changed default style.DisplaySafeAreaPadding values from (4,4) to (3,3) so it is smaller than FramePadding and has no effect on main menu bar on a computer. (#1439)
|
||||||
- Fonts: When building font atlas, glyphs that are missing in the fonts are not using the glyph slot to render a dummy/default glyph. Saves space and allow merging fonts with
|
- Fonts: When building font atlas, glyphs that are missing in the fonts are not using the glyph slot to render a dummy/default glyph. Saves space and allow merging fonts with
|
||||||
overlapping font ranges such as FontAwesome5 which split out the Brands separately from the Solid fonts. (#1703, #1671)
|
overlapping font ranges such as FontAwesome5 which split out the Brands separately from the Solid fonts. (#1703, #1671)
|
||||||
- Misc: Added IMGUI_CHECKVERSION() macro to compare version string and data structure sizes in order to catch issues with mismatching compilation unit settings. (#1695, #1769)
|
- Misc: Added IMGUI_CHECKVERSION() macro to compare version string and data structure sizes in order to catch issues with mismatching compilation unit settings. (#1695, #1769)
|
||||||
|
- Misc: Added IMGUI_DISABLE_MATH_FUNCTIONS in imconfig.h to make it easier to redefine wrappers for std/crt math functions.
|
||||||
- Misc: Fix to allow compiling in unity builds where stb_rectpack/stb_truetype may be already included in the same compilation unit.
|
- Misc: Fix to allow compiling in unity builds where stb_rectpack/stb_truetype may be already included in the same compilation unit.
|
||||||
- Demo: Fixed Overlay: Added a context menu item to enable freely moving the window.
|
- Demo: Simple Overlay: Added a context menu item to enable freely moving the window.
|
||||||
|
- Demo: Added demo for DragScalar(), InputScalar(), SliderScalar(). (#643)
|
||||||
- Examples: Calling IMGUI_CHECKVERSION() in the main.cpp of every example application.
|
- Examples: Calling IMGUI_CHECKVERSION() in the main.cpp of every example application.
|
||||||
- Examples: Allegro 5: Added support for 32-bit indices setup via defining ImDrawIdx, to avoid an unnecessary conversion (Allegro 5 doesn't support 16-bit indices).
|
- Examples: Allegro 5: Added support for 32-bit indices setup via defining ImDrawIdx, to avoid an unnecessary conversion (Allegro 5 doesn't support 16-bit indices).
|
||||||
- Examples: Allegro 5: Renamed bindings from imgui_impl_a5.cpp to imgui_impl_allegro5.cpp.
|
- Examples: Allegro 5: Renamed bindings from imgui_impl_a5.cpp to imgui_impl_allegro5.cpp.
|
||||||
|
17
README.md
17
README.md
@ -96,7 +96,7 @@ Demo Binaries
|
|||||||
-------------
|
-------------
|
||||||
|
|
||||||
You should be able to build the examples from sources (tested on Windows/Mac/Linux). If you don't, let me know! If you want to have a quick look at some Dear ImGui features, you can download Windows binaries of the demo app here:
|
You should be able to build the examples from sources (tested on Windows/Mac/Linux). If you don't, let me know! If you want to have a quick look at some Dear ImGui features, you can download Windows binaries of the demo app here:
|
||||||
- [imgui-demo-binaries-20180407.zip](http://www.miracleworld.net/imgui/binaries/imgui-demo-binaries-20180407.zip) (Windows binaries, Dear ImGui 1.60 built 2018/04/07, 5 executables)
|
- [imgui-demo-binaries-20180512.zip](http://www.miracleworld.net/imgui/binaries/imgui-demo-binaries-20180512.zip) (Windows binaries, Dear ImGui 1.61 WIP built 2018/05/12, 5 executables)
|
||||||
|
|
||||||
The demo applications are unfortunately not yet DPI aware so expect some blurriness on a 4K screen. For DPI awareness you can load/reload your font at different scale, and scale your Style with `style.ScaleAllSizes()`.
|
The demo applications are unfortunately not yet DPI aware so expect some blurriness on a 4K screen. For DPI awareness you can load/reload your font at different scale, and scale your Style with `style.ScaleAllSizes()`.
|
||||||
|
|
||||||
@ -115,11 +115,12 @@ Languages: (third-party bindings)
|
|||||||
- Go: [go-imgui](https://github.com/Armored-Dragon/go-imgui)
|
- Go: [go-imgui](https://github.com/Armored-Dragon/go-imgui)
|
||||||
- Haxe/hxcpp: [linc_imgui](https://github.com/Aidan63/linc_imgui)
|
- Haxe/hxcpp: [linc_imgui](https://github.com/Aidan63/linc_imgui)
|
||||||
- JavaScript: [imgui-js](https://github.com/flyover/imgui-js)
|
- JavaScript: [imgui-js](https://github.com/flyover/imgui-js)
|
||||||
- Lua: [imgui_lua_bindings](https://github.com/patrickriordan/imgui_lua_bindings)
|
- Java: [jimgui](https://github.com/ice1000/jimgui)
|
||||||
|
- Lua: [imgui_lua_bindings](https://github.com/patrickriordan/imgui_lua_bindings) or [lua-ffi-bindings](https://github.com/thenumbernine/lua-ffi-bindings)
|
||||||
- Odin: [odin-dear_imgui](https://github.com/ThisDrunkDane/odin-dear_imgui)
|
- Odin: [odin-dear_imgui](https://github.com/ThisDrunkDane/odin-dear_imgui)
|
||||||
- Pascal: [imgui-pas](https://github.com/dpethes/imgui-pas)
|
- Pascal: [imgui-pas](https://github.com/dpethes/imgui-pas)
|
||||||
- Python [CyImGui](https://github.com/chromy/cyimgui)
|
- PureBasic: [pb-cimgui](https://github.com/hippyau/pb-cimgui)
|
||||||
- Python [pyimgui](https://github.com/swistakm/pyimgui)
|
- Python [CyImGui](https://github.com/chromy/cyimgui) or [pyimgui](https://github.com/swistakm/pyimgui)
|
||||||
- Rust: [imgui-rs](https://github.com/Gekkio/imgui-rs)
|
- Rust: [imgui-rs](https://github.com/Gekkio/imgui-rs)
|
||||||
|
|
||||||
Frameworks:
|
Frameworks:
|
||||||
@ -140,10 +141,12 @@ Frameworks:
|
|||||||
- OpenFrameworks: [ofxImGui](https://github.com/jvcleave/ofxImGui)
|
- OpenFrameworks: [ofxImGui](https://github.com/jvcleave/ofxImGui)
|
||||||
- OpenSceneGraph/OSG: [gist](https://gist.github.com/fulezi/d2442ca7626bf270226014501357042c)
|
- OpenSceneGraph/OSG: [gist](https://gist.github.com/fulezi/d2442ca7626bf270226014501357042c)
|
||||||
- LÖVE: [love-imgui](https://github.com/slages/love-imgui)
|
- LÖVE: [love-imgui](https://github.com/slages/love-imgui)
|
||||||
|
- Magnum: [magnum-imgui](https://github.com/lecopivo/magnum-imgui), [MagnumImguiPort](https://github.com/lecopivo/MagnumImguiPort)
|
||||||
- NanoRT: [syoyo/imgui](https://github.com/syoyo/imgui/tree/nanort)
|
- NanoRT: [syoyo/imgui](https://github.com/syoyo/imgui/tree/nanort)
|
||||||
- Qt3d: [imgui-qt3d](https://github.com/alpqr/imgui-qt3d)
|
- Qt3d: [imgui-qt3d](https://github.com/alpqr/imgui-qt3d)
|
||||||
- Unreal Engine 4: [segross/UnrealImGui](https://github.com/segross/UnrealImGui) or [sronsse/UnrealEngine_ImGui](https://github.com/sronsse/UnrealEngine_ImGui)
|
|
||||||
- SFML: [imgui-sfml](https://github.com/EliasD/imgui-sfml) or [imgui-backends](https://github.com/Mischa-Alff/imgui-backends)
|
- SFML: [imgui-sfml](https://github.com/EliasD/imgui-sfml) or [imgui-backends](https://github.com/Mischa-Alff/imgui-backends)
|
||||||
|
- Software renderer: [imgui_software_renderer](https://github.com/emilk/imgui_software_renderer)
|
||||||
|
- Unreal Engine 4: [segross/UnrealImGui](https://github.com/segross/UnrealImGui) or [sronsse/UnrealEngine_ImGui](https://github.com/sronsse/UnrealEngine_ImGui)
|
||||||
|
|
||||||
For other bindings: see [this page](https://github.com/ocornut/imgui/wiki/Links/). Also see [wiki](https://github.com/ocornut/imgui/wiki) for a few other links and ideas. Contact me if you would like to add to those lists.
|
For other bindings: see [this page](https://github.com/ocornut/imgui/wiki/Links/). Also see [wiki](https://github.com/ocornut/imgui/wiki) for a few other links and ideas. Contact me if you would like to add to those lists.
|
||||||
|
|
||||||
@ -312,10 +315,10 @@ Double-chocolate sponsors:
|
|||||||
- DotEmu
|
- DotEmu
|
||||||
|
|
||||||
Salty caramel supporters:
|
Salty caramel supporters:
|
||||||
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Recognition Robotics, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko, Mercury Labs, Singularity Demo Group, Mischa Alff, Sebastien Ronsse, Lionel Landwerlin, Nikolay Ivanov, Ron Gilbert.
|
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Recognition Robotics, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko, Mercury Labs, Singularity Demo Group, Mischa Alff, Sebastien Ronsse, Lionel Landwerlin, Nikolay Ivanov, Ron Gilbert, Brandon Townsend, Nikhil Deshpande, Cort Stratton, drudru.
|
||||||
|
|
||||||
Caramel supporters:
|
Caramel supporters:
|
||||||
- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, Kit framework, Josh Faust, Martin Donlon, Quinton, Felix, Andrew Belt, Codecat, Cort Stratton, Claudio Canepa, Doug McNabb, Emmanuel Julien, Guillaume Chereau, Jeffrey Slutter, Jeremiah Deckard, r-lyeh, Roger Clark, Nekith, Joshua Fisher, Malte Hoffmann, Mustafa Karaalioglu, Merlyn Morgan-Graham, Per Vognsen, Fabian Giesen, Jan Staubach, Matt Hargett, John Shearer, Jesse Chounard, kingcoopa, Miloš Tošić, Jonas Bernemann, Johan Andersson, Nathan Hartman, Michael Labbe, Tomasz Golebiowski, Louis Schnellbach, Felipe Alfonso, Jimmy Andrews, Bojan Endrovski, Robin Berg Pettersen, Rachel Crawford, Edsel Malasig, Andrew Johnson, Sean Hunter, Jordan Mellow.
|
- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, Kit framework, Josh Faust, Martin Donlon, Quinton, Felix, Andrew Belt, Codecat, Cort Stratton, Claudio Canepa, Doug McNabb, Emmanuel Julien, Guillaume Chereau, Jeffrey Slutter, Jeremiah Deckard, r-lyeh, Roger Clark, Nekith, Joshua Fisher, Malte Hoffmann, Mustafa Karaalioglu, Merlyn Morgan-Graham, Per Vognsen, Fabian Giesen, Jan Staubach, Matt Hargett, John Shearer, Jesse Chounard, kingcoopa, Miloš Tošić, Jonas Bernemann, Johan Andersson, Nathan Hartman, Michael Labbe, Tomasz Golebiowski, Louis Schnellbach, Felipe Alfonso, Jimmy Andrews, Bojan Endrovski, Robin Berg Pettersen, Rachel Crawford, Edsel Malasig, Andrew Johnson, Sean Hunter, Jordan Mellow, Nefarius Software Solutions, Laura Wieme, Robert Nix, Mick Honey.
|
||||||
|
|
||||||
And other supporters; thanks!
|
And other supporters; thanks!
|
||||||
(Please contact me or PR if you would like to be added or removed from this list)
|
(Please contact me or PR if you would like to be added or removed from this list)
|
||||||
|
4
TODO.txt
4
TODO.txt
@ -245,6 +245,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- nav: patterns to make it possible for arrows key to update selection
|
- nav: patterns to make it possible for arrows key to update selection
|
||||||
- nav: SetItemDefaultFocus() level of priority, so widget like Selectable when inside a popup could claim a low-priority default focus on the first selected iem
|
- nav: SetItemDefaultFocus() level of priority, so widget like Selectable when inside a popup could claim a low-priority default focus on the first selected iem
|
||||||
- nav: allow input system to be be more tolerant of io.DeltaTime=0.0f
|
- nav: allow input system to be be more tolerant of io.DeltaTime=0.0f
|
||||||
|
- nav: ESC within a menu of a child window seems to exit the child window.
|
||||||
- nav: ESC on a flattened child
|
- nav: ESC on a flattened child
|
||||||
- nav: Left within a tree node block as a fallback (ImGuiTreeNodeFlags_NavLeftJumpsBackHere by default?)
|
- nav: Left within a tree node block as a fallback (ImGuiTreeNodeFlags_NavLeftJumpsBackHere by default?)
|
||||||
- nav: menus: pressing left-right on a vertically clipped menu bar tends to jump to the collapse/close buttons.
|
- nav: menus: pressing left-right on a vertically clipped menu bar tends to jump to the collapse/close buttons.
|
||||||
@ -272,6 +273,8 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- inputs: we need an explicit flag about whether the imgui window is focused, to be able to distinguish focused key releases vs alt-tabbing all release behaviors.
|
- inputs: we need an explicit flag about whether the imgui window is focused, to be able to distinguish focused key releases vs alt-tabbing all release behaviors.
|
||||||
- inputs: rework IO system to be able to pass actual ordered/timestamped events. use an event queue? (~#335, #71)
|
- inputs: rework IO system to be able to pass actual ordered/timestamped events. use an event queue? (~#335, #71)
|
||||||
- inputs: support track pad style scrolling & slider edit.
|
- inputs: support track pad style scrolling & slider edit.
|
||||||
|
- inputs/io: backspace and arrows in the context of a text input could use system repeat rate.
|
||||||
|
- inputs/io: clarify/standardize/expose repeat rate and repeat delays (#1808)
|
||||||
|
|
||||||
- misc: idle refresh: expose cursor blink animation timer for backend to be able to lower framerate.
|
- misc: idle refresh: expose cursor blink animation timer for backend to be able to lower framerate.
|
||||||
- misc: make the ImGuiCond values linear (non-power-of-two). internal storage for ImGuiWindow can use integers to combine into flags (Why?)
|
- misc: make the ImGuiCond values linear (non-power-of-two). internal storage for ImGuiWindow can use integers to combine into flags (Why?)
|
||||||
@ -279,6 +282,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- misc: PushItemFlag(): add a flag to disable keyboard capture when used with mouse? (#1682)
|
- misc: PushItemFlag(): add a flag to disable keyboard capture when used with mouse? (#1682)
|
||||||
- misc: use more size_t in public api?
|
- misc: use more size_t in public api?
|
||||||
- misc: ImVector: erase_unsorted() helper
|
- misc: ImVector: erase_unsorted() helper
|
||||||
|
- misc: imgui_cpp: perhaps a misc/ header file with more friendly helper (e.g. type-infer versions of DragScalar, vector<> variants if appropriate for some functions).
|
||||||
|
|
||||||
- web/emscriptem: refactor some examples to facilitate integration with emscripten main loop system. (#1713, #336)
|
- web/emscriptem: refactor some examples to facilitate integration with emscripten main loop system. (#1713, #336)
|
||||||
- web/emscriptem: tweak OpenGL renderers to support OpenGL ES. (#1713, #336)
|
- web/emscriptem: tweak OpenGL renderers to support OpenGL ES. (#1713, #336)
|
||||||
|
15
imconfig.h
15
imconfig.h
@ -15,24 +15,25 @@
|
|||||||
|
|
||||||
//---- Define assertion handler. Defaults to calling assert().
|
//---- Define assertion handler. Defaults to calling assert().
|
||||||
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
|
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
|
||||||
|
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
|
||||||
|
|
||||||
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows.
|
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows.
|
||||||
//#define IMGUI_API __declspec( dllexport )
|
//#define IMGUI_API __declspec( dllexport )
|
||||||
//#define IMGUI_API __declspec( dllimport )
|
//#define IMGUI_API __declspec( dllimport )
|
||||||
|
|
||||||
//---- Don't define obsolete functions/enums names. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names
|
//---- Don't define obsolete functions/enums names. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
|
||||||
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
|
||||||
//---- Don't implement default handlers for Windows (so as not to link with certain functions)
|
|
||||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // Don't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc.
|
|
||||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // Don't use and link with ImmGetContext/ImmSetCompositionWindow.
|
|
||||||
|
|
||||||
//---- Don't implement demo windows functionality (ShowDemoWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty)
|
//---- Don't implement demo windows functionality (ShowDemoWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty)
|
||||||
//---- It is very strongly recommended to NOT disable the demo windows during development. Please read the comments in imgui_demo.cpp.
|
//---- It is very strongly recommended to NOT disable the demo windows during development. Please read the comments in imgui_demo.cpp.
|
||||||
//#define IMGUI_DISABLE_DEMO_WINDOWS
|
//#define IMGUI_DISABLE_DEMO_WINDOWS
|
||||||
|
|
||||||
//---- Don't implement ImFormatString(), ImFormatStringV() so you can reimplement them yourself.
|
//---- Don't implement some functions to reduce linkage requirements.
|
||||||
//#define IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
|
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc.
|
||||||
|
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow.
|
||||||
|
//#define IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself if you don't want to link with vsnprintf.
|
||||||
|
//#define IMGUI_DISABLE_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 wrapper so you can implement them yourself. Declare your prototypes in imconfig.h.
|
||||||
|
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free(). You will need to call ImGui::SetAllocatorFunctions().
|
||||||
|
|
||||||
//---- Include imgui_user.h at the end of imgui.h as a convenience
|
//---- Include imgui_user.h at the end of imgui.h as a convenience
|
||||||
//#define IMGUI_INCLUDE_IMGUI_USER_H
|
//#define IMGUI_INCLUDE_IMGUI_USER_H
|
||||||
|
70
imgui.cpp
70
imgui.cpp
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.61 WIP
|
// dear imgui, v1.61
|
||||||
// (main code and documentation)
|
// (main code and documentation)
|
||||||
|
|
||||||
// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
|
// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
|
||||||
@ -267,16 +267,17 @@
|
|||||||
- 2018/XX/XX (1.XX) - Moved IME support functions from io.ImeSetInputScreenPosFn, io.ImeWindowHandle to the PlatformIO api.
|
- 2018/XX/XX (1.XX) - Moved IME support functions from io.ImeSetInputScreenPosFn, io.ImeWindowHandle to the PlatformIO api.
|
||||||
- 2018/XX/XX (1.XX) - removed io.DisplayVisibleMin, io.DisplayVisibleMax settings (it was used to clip within the DisplayMin..DisplayMax range, I don't know of anyone using it)
|
- 2018/XX/XX (1.XX) - removed io.DisplayVisibleMin, io.DisplayVisibleMax settings (it was used to clip within the DisplayMin..DisplayMax range, I don't know of anyone using it)
|
||||||
|
|
||||||
- 2018/05/03 (1.61) - DragInt(): The default compile-time format string has been changed from "%.0f" to "%d", we are not using integers internally any more.
|
- 2018/05/03 (1.61) - DragInt(): The default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally any more.
|
||||||
If you used DragInt() with custom format strings, make sure you change them to use %d or an integer-compatible format.
|
If you used DragInt() with custom format strings, make sure you change them to use %d or an integer-compatible format.
|
||||||
To honor backward-compatibility, the DragInt() code will currently parse and modify format strings to replace %*f with %d, giving time to users to upgrade their code.
|
To honor backward-compatibility, the DragInt() code will currently parse and modify format strings to replace %*f with %d, giving time to users to upgrade their code.
|
||||||
If you have IMGUI_DISABLE_OBSOLETE_FUNCTIONS enabled, the code will instead assert! You may run a reg-exp search on your codebase for e.g. "DragInt.*%f" to help you find them.
|
If you have IMGUI_DISABLE_OBSOLETE_FUNCTIONS enabled, the code will instead assert! You may run a reg-exp search on your codebase for e.g. "DragInt.*%f" to help you find them.
|
||||||
- 2018/04/28 (1.61) - obsoleted InputFloat() functions taking an optional "int decimal_precision" in favor of an equivalent and more flexible "const char* format", consistent with other functions. Kept redirection functions (will obsolete).
|
- 2018/04/28 (1.61) - obsoleted InputFloat() functions taking an optional "int decimal_precision" in favor of an equivalent and more flexible "const char* format",
|
||||||
|
consistent with other functions. Kept redirection functions (will obsolete).
|
||||||
- 2018/04/09 (1.61) - IM_DELETE() helper function added in 1.60 doesn't clear the input _pointer_ reference, more consistent with expectation and allows passing r-value.
|
- 2018/04/09 (1.61) - IM_DELETE() helper function added in 1.60 doesn't clear the input _pointer_ reference, more consistent with expectation and allows passing r-value.
|
||||||
- 2018/03/20 (1.60) - Renamed io.WantMoveMouse to io.WantSetMousePos for consistency and ease of understanding (was added in 1.52, _not_ used by core and only honored by some binding ahead of merging the Nav branch).
|
- 2018/03/20 (1.60) - renamed io.WantMoveMouse to io.WantSetMousePos for consistency and ease of understanding (was added in 1.52, _not_ used by core and only honored by some binding ahead of merging the Nav branch).
|
||||||
- 2018/03/12 (1.60) - Removed ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered as the closing cross uses regular button colors now.
|
- 2018/03/12 (1.60) - removed ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered as the closing cross uses regular button colors now.
|
||||||
- 2018/03/08 (1.60) - Changed ImFont::DisplayOffset.y to default to 0 instead of +1. Fixed rounding of Ascent/Descent to match TrueType renderer. If you were adding or subtracting to ImFont::DisplayOffset check if your fonts are correctly aligned vertically.
|
- 2018/03/08 (1.60) - changed ImFont::DisplayOffset.y to default to 0 instead of +1. Fixed rounding of Ascent/Descent to match TrueType renderer. If you were adding or subtracting to ImFont::DisplayOffset check if your fonts are correctly aligned vertically.
|
||||||
- 2018/03/03 (1.60) - Renamed ImGuiStyleVar_Count_ to ImGuiStyleVar_COUNT and ImGuiMouseCursor_Count_ to ImGuiMouseCursor_COUNT for consistency with other public enums.
|
- 2018/03/03 (1.60) - renamed ImGuiStyleVar_Count_ to ImGuiStyleVar_COUNT and ImGuiMouseCursor_Count_ to ImGuiMouseCursor_COUNT for consistency with other public enums.
|
||||||
- 2018/02/18 (1.60) - BeginDragDropSource(): temporarily removed the optional mouse_button=0 parameter because it is not really usable in many situations at the moment.
|
- 2018/02/18 (1.60) - BeginDragDropSource(): temporarily removed the optional mouse_button=0 parameter because it is not really usable in many situations at the moment.
|
||||||
- 2018/02/16 (1.60) - obsoleted the io.RenderDrawListsFn callback, you can call your graphics engine render function after ImGui::Render(). Use ImGui::GetDrawData() to retrieve the ImDrawData* to display.
|
- 2018/02/16 (1.60) - obsoleted the io.RenderDrawListsFn callback, you can call your graphics engine render function after ImGui::Render(). Use ImGui::GetDrawData() to retrieve the ImDrawData* to display.
|
||||||
- 2018/02/07 (1.60) - reorganized context handling to be more explicit,
|
- 2018/02/07 (1.60) - reorganized context handling to be more explicit,
|
||||||
@ -669,7 +670,6 @@
|
|||||||
#include "imgui_internal.h"
|
#include "imgui_internal.h"
|
||||||
|
|
||||||
#include <ctype.h> // toupper, isprint
|
#include <ctype.h> // toupper, isprint
|
||||||
#include <stdlib.h> // NULL, malloc, free, qsort, atoi
|
|
||||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
||||||
#include <stddef.h> // intptr_t
|
#include <stddef.h> // intptr_t
|
||||||
@ -1437,7 +1437,7 @@ void ImGui::ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float&
|
|||||||
}
|
}
|
||||||
|
|
||||||
const float chroma = r - (g < b ? g : b);
|
const float chroma = r - (g < b ? g : b);
|
||||||
out_h = fabsf(K + (g - b) / (6.f * chroma + 1e-20f));
|
out_h = ImFabs(K + (g - b) / (6.f * chroma + 1e-20f));
|
||||||
out_s = chroma / (r + 1e-20f);
|
out_s = chroma / (r + 1e-20f);
|
||||||
out_v = r;
|
out_v = r;
|
||||||
}
|
}
|
||||||
@ -1453,7 +1453,7 @@ void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float&
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
h = fmodf(h, 1.0f) / (60.0f/360.0f);
|
h = ImFmod(h, 1.0f) / (60.0f/360.0f);
|
||||||
int i = (int)h;
|
int i = (int)h;
|
||||||
float f = h - (float)i;
|
float f = h - (float)i;
|
||||||
float p = v * (1.0f - s);
|
float p = v * (1.0f - s);
|
||||||
@ -2221,7 +2221,7 @@ void ImGui::ItemSize(const ImRect& bb, float text_offset_y)
|
|||||||
|
|
||||||
static ImGuiDir inline NavScoreItemGetQuadrant(float dx, float dy)
|
static ImGuiDir inline NavScoreItemGetQuadrant(float dx, float dy)
|
||||||
{
|
{
|
||||||
if (fabsf(dx) > fabsf(dy))
|
if (ImFabs(dx) > ImFabs(dy))
|
||||||
return (dx > 0.0f) ? ImGuiDir_Right : ImGuiDir_Left;
|
return (dx > 0.0f) ? ImGuiDir_Right : ImGuiDir_Left;
|
||||||
return (dy > 0.0f) ? ImGuiDir_Down : ImGuiDir_Up;
|
return (dy > 0.0f) ? ImGuiDir_Down : ImGuiDir_Up;
|
||||||
}
|
}
|
||||||
@ -2270,12 +2270,12 @@ static bool NavScoreItem(ImGuiNavMoveResult* result, ImRect cand)
|
|||||||
float dby = NavScoreItemDistInterval(ImLerp(cand.Min.y, cand.Max.y, 0.2f), ImLerp(cand.Min.y, cand.Max.y, 0.8f), ImLerp(curr.Min.y, curr.Max.y, 0.2f), ImLerp(curr.Min.y, curr.Max.y, 0.8f)); // Scale down on Y to keep using box-distance for vertically touching items
|
float dby = NavScoreItemDistInterval(ImLerp(cand.Min.y, cand.Max.y, 0.2f), ImLerp(cand.Min.y, cand.Max.y, 0.8f), ImLerp(curr.Min.y, curr.Max.y, 0.2f), ImLerp(curr.Min.y, curr.Max.y, 0.8f)); // Scale down on Y to keep using box-distance for vertically touching items
|
||||||
if (dby != 0.0f && dbx != 0.0f)
|
if (dby != 0.0f && dbx != 0.0f)
|
||||||
dbx = (dbx/1000.0f) + ((dbx > 0.0f) ? +1.0f : -1.0f);
|
dbx = (dbx/1000.0f) + ((dbx > 0.0f) ? +1.0f : -1.0f);
|
||||||
float dist_box = fabsf(dbx) + fabsf(dby);
|
float dist_box = ImFabs(dbx) + ImFabs(dby);
|
||||||
|
|
||||||
// Compute distance between centers (this is off by a factor of 2, but we only compare center distances with each other so it doesn't matter)
|
// Compute distance between centers (this is off by a factor of 2, but we only compare center distances with each other so it doesn't matter)
|
||||||
float dcx = (cand.Min.x + cand.Max.x) - (curr.Min.x + curr.Max.x);
|
float dcx = (cand.Min.x + cand.Max.x) - (curr.Min.x + curr.Max.x);
|
||||||
float dcy = (cand.Min.y + cand.Max.y) - (curr.Min.y + curr.Max.y);
|
float dcy = (cand.Min.y + cand.Max.y) - (curr.Min.y + curr.Max.y);
|
||||||
float dist_center = fabsf(dcx) + fabsf(dcy); // L1 metric (need this for our connectedness guarantee)
|
float dist_center = ImFabs(dcx) + ImFabs(dcy); // L1 metric (need this for our connectedness guarantee)
|
||||||
|
|
||||||
// Determine which quadrant of 'curr' our candidate item 'cand' lies in based on distance
|
// Determine which quadrant of 'curr' our candidate item 'cand' lies in based on distance
|
||||||
ImGuiDir quadrant;
|
ImGuiDir quadrant;
|
||||||
@ -3350,7 +3350,7 @@ static void ImGui::NavUpdate()
|
|||||||
g.NavScoringRectScreen = g.NavWindow ? ImRect(g.NavWindow->Pos + nav_rect_rel.Min, g.NavWindow->Pos + nav_rect_rel.Max) : ImRect(0,0,0,0);
|
g.NavScoringRectScreen = g.NavWindow ? ImRect(g.NavWindow->Pos + nav_rect_rel.Min, g.NavWindow->Pos + nav_rect_rel.Max) : ImRect(0,0,0,0);
|
||||||
g.NavScoringRectScreen.Min.x = ImMin(g.NavScoringRectScreen.Min.x + 1.0f, g.NavScoringRectScreen.Max.x);
|
g.NavScoringRectScreen.Min.x = ImMin(g.NavScoringRectScreen.Min.x + 1.0f, g.NavScoringRectScreen.Max.x);
|
||||||
g.NavScoringRectScreen.Max.x = g.NavScoringRectScreen.Min.x;
|
g.NavScoringRectScreen.Max.x = g.NavScoringRectScreen.Min.x;
|
||||||
IM_ASSERT(!g.NavScoringRectScreen.IsInverted()); // Ensure if we have a finite, non-inverted bounding box here will allows us to remove extraneous fabsf() calls in NavScoreItem().
|
IM_ASSERT(!g.NavScoringRectScreen.IsInverted()); // Ensure if we have a finite, non-inverted bounding box here will allows us to remove extraneous ImFabs() calls in NavScoreItem().
|
||||||
//g.OverlayDrawList.AddRect(g.NavScoringRectScreen.Min, g.NavScoringRectScreen.Max, IM_COL32(255,200,0,255)); // [DEBUG]
|
//g.OverlayDrawList.AddRect(g.NavScoringRectScreen.Min, g.NavScoringRectScreen.Max, IM_COL32(255,200,0,255)); // [DEBUG]
|
||||||
g.NavScoringCount = 0;
|
g.NavScoringCount = 0;
|
||||||
#if IMGUI_DEBUG_NAV_RECTS
|
#if IMGUI_DEBUG_NAV_RECTS
|
||||||
@ -5299,7 +5299,7 @@ bool ImGui::IsMouseClicked(int button, bool repeat)
|
|||||||
if (repeat && t > g.IO.KeyRepeatDelay)
|
if (repeat && t > g.IO.KeyRepeatDelay)
|
||||||
{
|
{
|
||||||
float delay = g.IO.KeyRepeatDelay, rate = g.IO.KeyRepeatRate;
|
float delay = g.IO.KeyRepeatDelay, rate = g.IO.KeyRepeatRate;
|
||||||
if ((fmodf(t - delay, rate) > rate*0.5f) != (fmodf(t - delay - g.IO.DeltaTime, rate) > rate*0.5f))
|
if ((ImFmod(t - delay, rate) > rate*0.5f) != (ImFmod(t - delay - g.IO.DeltaTime, rate) > rate*0.5f))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9683,7 +9683,7 @@ static inline TYPE RoundScalarWithFormat(const char* format, ImGuiDataType data_
|
|||||||
while (*p == ' ')
|
while (*p == ' ')
|
||||||
p++;
|
p++;
|
||||||
if (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double)
|
if (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double)
|
||||||
v = (TYPE)atof(p);
|
v = (TYPE)ImAtof(p);
|
||||||
else
|
else
|
||||||
ImAtoi(p, (SIGNEDTYPE*)&v);
|
ImAtoi(p, (SIGNEDTYPE*)&v);
|
||||||
return v;
|
return v;
|
||||||
@ -9798,8 +9798,8 @@ static bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType d
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (v_max - v_min <= 100.0f || v_max - v_min >= -100.0f || IsNavInputDown(ImGuiNavInput_TweakSlow))
|
if ((v_range >= -100.0f && v_range <= 100.0f) || IsNavInputDown(ImGuiNavInput_TweakSlow))
|
||||||
delta = ((delta < 0.0f) ? -1.0f : +1.0f) / (float)(v_max - v_min); // Gamepad/keyboard tweak speeds in integer steps
|
delta = ((delta < 0.0f) ? -1.0f : +1.0f) / (float)v_range; // Gamepad/keyboard tweak speeds in integer steps
|
||||||
else
|
else
|
||||||
delta /= 100.0f;
|
delta /= 100.0f;
|
||||||
}
|
}
|
||||||
@ -9830,7 +9830,7 @@ static bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType d
|
|||||||
{
|
{
|
||||||
// Positive: rescale to the positive range before powering
|
// Positive: rescale to the positive range before powering
|
||||||
float a;
|
float a;
|
||||||
if (fabsf(linear_zero_pos - 1.0f) > 1.e-6f)
|
if (ImFabs(linear_zero_pos - 1.0f) > 1.e-6f)
|
||||||
a = (clicked_t - linear_zero_pos) / (1.0f - linear_zero_pos);
|
a = (clicked_t - linear_zero_pos) / (1.0f - linear_zero_pos);
|
||||||
else
|
else
|
||||||
a = clicked_t;
|
a = clicked_t;
|
||||||
@ -10164,7 +10164,7 @@ static bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed
|
|||||||
}
|
}
|
||||||
if (g.ActiveIdSource == ImGuiInputSource_Nav)
|
if (g.ActiveIdSource == ImGuiInputSource_Nav)
|
||||||
{
|
{
|
||||||
int decimal_precision = ImParseFormatPrecision(format, 3);
|
int decimal_precision = (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) ? ImParseFormatPrecision(format, 3) : 0;
|
||||||
adjust_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard|ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 1.0f/10.0f, 10.0f).x;
|
adjust_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard|ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 1.0f/10.0f, 10.0f).x;
|
||||||
v_speed = ImMax(v_speed, GetMinimumStepAtDecimalPrecision(decimal_precision));
|
v_speed = ImMax(v_speed, GetMinimumStepAtDecimalPrecision(decimal_precision));
|
||||||
}
|
}
|
||||||
@ -10274,7 +10274,7 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* v, floa
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (power != 1.0f)
|
if (power != 1.0f)
|
||||||
IM_ASSERT(v_min != v_max); // When using a power curve the drag needs to have known bounds
|
IM_ASSERT(v_min != NULL && v_max != NULL); // When using a power curve the drag needs to have known bounds
|
||||||
|
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
const ImGuiStyle& style = g.Style;
|
const ImGuiStyle& style = g.Style;
|
||||||
@ -11599,7 +11599,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
|||||||
draw_window->DrawList->AddText(g.Font, g.FontSize, render_pos - render_scroll, GetColorU32(ImGuiCol_Text), buf_display, buf_display + edit_state.CurLenA, 0.0f, is_multiline ? NULL : &clip_rect);
|
draw_window->DrawList->AddText(g.Font, g.FontSize, render_pos - render_scroll, GetColorU32(ImGuiCol_Text), buf_display, buf_display + edit_state.CurLenA, 0.0f, is_multiline ? NULL : &clip_rect);
|
||||||
|
|
||||||
// Draw blinking cursor
|
// Draw blinking cursor
|
||||||
bool cursor_is_visible = (!g.IO.OptCursorBlink) || (g.InputTextState.CursorAnim <= 0.0f) || fmodf(g.InputTextState.CursorAnim, 1.20f) <= 0.80f;
|
bool cursor_is_visible = (!g.IO.OptCursorBlink) || (g.InputTextState.CursorAnim <= 0.0f) || ImFmod(g.InputTextState.CursorAnim, 1.20f) <= 0.80f;
|
||||||
ImVec2 cursor_screen_pos = render_pos + cursor_offset - render_scroll;
|
ImVec2 cursor_screen_pos = render_pos + cursor_offset - render_scroll;
|
||||||
ImRect cursor_screen_rect(cursor_screen_pos.x, cursor_screen_pos.y-g.FontSize+0.5f, cursor_screen_pos.x+1.0f, cursor_screen_pos.y-1.5f);
|
ImRect cursor_screen_rect(cursor_screen_pos.x, cursor_screen_pos.y-g.FontSize+0.5f, cursor_screen_pos.x+1.0f, cursor_screen_pos.y-1.5f);
|
||||||
if (cursor_is_visible && cursor_screen_rect.Overlaps(clip_rect))
|
if (cursor_is_visible && cursor_screen_rect.Overlaps(clip_rect))
|
||||||
@ -12450,7 +12450,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
|||||||
ImVec2 ta = g.IO.MousePos - g.IO.MouseDelta;
|
ImVec2 ta = g.IO.MousePos - g.IO.MouseDelta;
|
||||||
ImVec2 tb = (window->Pos.x < next_window->Pos.x) ? next_window_rect.GetTL() : next_window_rect.GetTR();
|
ImVec2 tb = (window->Pos.x < next_window->Pos.x) ? next_window_rect.GetTL() : next_window_rect.GetTR();
|
||||||
ImVec2 tc = (window->Pos.x < next_window->Pos.x) ? next_window_rect.GetBL() : next_window_rect.GetBR();
|
ImVec2 tc = (window->Pos.x < next_window->Pos.x) ? next_window_rect.GetBL() : next_window_rect.GetBR();
|
||||||
float extra = ImClamp(fabsf(ta.x - tb.x) * 0.30f, 5.0f, 30.0f); // add a bit of extra slack.
|
float extra = ImClamp(ImFabs(ta.x - tb.x) * 0.30f, 5.0f, 30.0f); // add a bit of extra slack.
|
||||||
ta.x += (window->Pos.x < next_window->Pos.x) ? -0.5f : +0.5f; // to avoid numerical issues
|
ta.x += (window->Pos.x < next_window->Pos.x) ? -0.5f : +0.5f; // to avoid numerical issues
|
||||||
tb.y = ta.y + ImMax((tb.y - extra) - ta.y, -100.0f); // triangle is maximum 200 high to limit the slope and the bias toward large sub-menus // FIXME: Multiply by fb_scale?
|
tb.y = ta.y + ImMax((tb.y - extra) - ta.y, -100.0f); // triangle is maximum 200 high to limit the slope and the bias toward large sub-menus // FIXME: Multiply by fb_scale?
|
||||||
tc.y = ta.y + ImMin((tc.y + extra) - ta.y, +100.0f);
|
tc.y = ta.y + ImMin((tc.y + extra) - ta.y, +100.0f);
|
||||||
@ -12802,15 +12802,11 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
const float w_items_all = CalcItemWidth() - w_extra;
|
const float w_items_all = CalcItemWidth() - w_extra;
|
||||||
const char* label_display_end = FindRenderedTextEnd(label);
|
const char* label_display_end = FindRenderedTextEnd(label);
|
||||||
|
|
||||||
const bool alpha = (flags & ImGuiColorEditFlags_NoAlpha) == 0;
|
|
||||||
const bool hdr = (flags & ImGuiColorEditFlags_HDR) != 0;
|
|
||||||
const int components = alpha ? 4 : 3;
|
|
||||||
const ImGuiColorEditFlags flags_untouched = flags;
|
|
||||||
|
|
||||||
BeginGroup();
|
BeginGroup();
|
||||||
PushID(label);
|
PushID(label);
|
||||||
|
|
||||||
// If we're not showing any slider there's no point in doing any HSV conversions
|
// If we're not showing any slider there's no point in doing any HSV conversions
|
||||||
|
const ImGuiColorEditFlags flags_untouched = flags;
|
||||||
if (flags & ImGuiColorEditFlags_NoInputs)
|
if (flags & ImGuiColorEditFlags_NoInputs)
|
||||||
flags = (flags & (~ImGuiColorEditFlags__InputsMask)) | ImGuiColorEditFlags_RGB | ImGuiColorEditFlags_NoOptions;
|
flags = (flags & (~ImGuiColorEditFlags__InputsMask)) | ImGuiColorEditFlags_RGB | ImGuiColorEditFlags_NoOptions;
|
||||||
|
|
||||||
@ -12827,6 +12823,10 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
flags |= (g.ColorEditOptions & ImGuiColorEditFlags__PickerMask);
|
flags |= (g.ColorEditOptions & ImGuiColorEditFlags__PickerMask);
|
||||||
flags |= (g.ColorEditOptions & ~(ImGuiColorEditFlags__InputsMask | ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask));
|
flags |= (g.ColorEditOptions & ~(ImGuiColorEditFlags__InputsMask | ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask));
|
||||||
|
|
||||||
|
const bool alpha = (flags & ImGuiColorEditFlags_NoAlpha) == 0;
|
||||||
|
const bool hdr = (flags & ImGuiColorEditFlags_HDR) != 0;
|
||||||
|
const int components = alpha ? 4 : 3;
|
||||||
|
|
||||||
// Convert to the formats we need
|
// Convert to the formats we need
|
||||||
float f[4] = { col[0], col[1], col[2], alpha ? col[3] : 1.0f };
|
float f[4] = { col[0], col[1], col[2], alpha ? col[3] : 1.0f };
|
||||||
if (flags & ImGuiColorEditFlags_HSV)
|
if (flags & ImGuiColorEditFlags_HSV)
|
||||||
@ -13090,13 +13090,13 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
if (initial_dist2 >= (wheel_r_inner-1)*(wheel_r_inner-1) && initial_dist2 <= (wheel_r_outer+1)*(wheel_r_outer+1))
|
if (initial_dist2 >= (wheel_r_inner-1)*(wheel_r_inner-1) && initial_dist2 <= (wheel_r_outer+1)*(wheel_r_outer+1))
|
||||||
{
|
{
|
||||||
// Interactive with Hue wheel
|
// Interactive with Hue wheel
|
||||||
H = atan2f(current_off.y, current_off.x) / IM_PI*0.5f;
|
H = ImAtan2(current_off.y, current_off.x) / IM_PI*0.5f;
|
||||||
if (H < 0.0f)
|
if (H < 0.0f)
|
||||||
H += 1.0f;
|
H += 1.0f;
|
||||||
value_changed = value_changed_h = true;
|
value_changed = value_changed_h = true;
|
||||||
}
|
}
|
||||||
float cos_hue_angle = cosf(-H * 2.0f * IM_PI);
|
float cos_hue_angle = ImCos(-H * 2.0f * IM_PI);
|
||||||
float sin_hue_angle = sinf(-H * 2.0f * IM_PI);
|
float sin_hue_angle = ImSin(-H * 2.0f * IM_PI);
|
||||||
if (ImTriangleContainsPoint(triangle_pa, triangle_pb, triangle_pc, ImRotate(initial_off, cos_hue_angle, sin_hue_angle)))
|
if (ImTriangleContainsPoint(triangle_pa, triangle_pb, triangle_pc, ImRotate(initial_off, cos_hue_angle, sin_hue_angle)))
|
||||||
{
|
{
|
||||||
// Interacting with SV triangle
|
// Interacting with SV triangle
|
||||||
@ -13242,14 +13242,14 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
const int vert_end_idx = draw_list->VtxBuffer.Size;
|
const int vert_end_idx = draw_list->VtxBuffer.Size;
|
||||||
|
|
||||||
// Paint colors over existing vertices
|
// Paint colors over existing vertices
|
||||||
ImVec2 gradient_p0(wheel_center.x + cosf(a0) * wheel_r_inner, wheel_center.y + sinf(a0) * wheel_r_inner);
|
ImVec2 gradient_p0(wheel_center.x + ImCos(a0) * wheel_r_inner, wheel_center.y + ImSin(a0) * wheel_r_inner);
|
||||||
ImVec2 gradient_p1(wheel_center.x + cosf(a1) * wheel_r_inner, wheel_center.y + sinf(a1) * wheel_r_inner);
|
ImVec2 gradient_p1(wheel_center.x + ImCos(a1) * wheel_r_inner, wheel_center.y + ImSin(a1) * wheel_r_inner);
|
||||||
ShadeVertsLinearColorGradientKeepAlpha(draw_list->VtxBuffer.Data + vert_start_idx, draw_list->VtxBuffer.Data + vert_end_idx, gradient_p0, gradient_p1, hue_colors[n], hue_colors[n+1]);
|
ShadeVertsLinearColorGradientKeepAlpha(draw_list->VtxBuffer.Data + vert_start_idx, draw_list->VtxBuffer.Data + vert_end_idx, gradient_p0, gradient_p1, hue_colors[n], hue_colors[n+1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render Cursor + preview on Hue Wheel
|
// Render Cursor + preview on Hue Wheel
|
||||||
float cos_hue_angle = cosf(H * 2.0f * IM_PI);
|
float cos_hue_angle = ImCos(H * 2.0f * IM_PI);
|
||||||
float sin_hue_angle = sinf(H * 2.0f * IM_PI);
|
float sin_hue_angle = ImSin(H * 2.0f * IM_PI);
|
||||||
ImVec2 hue_cursor_pos(wheel_center.x + cos_hue_angle * (wheel_r_inner+wheel_r_outer)*0.5f, wheel_center.y + sin_hue_angle * (wheel_r_inner+wheel_r_outer)*0.5f);
|
ImVec2 hue_cursor_pos(wheel_center.x + cos_hue_angle * (wheel_r_inner+wheel_r_outer)*0.5f, wheel_center.y + sin_hue_angle * (wheel_r_inner+wheel_r_outer)*0.5f);
|
||||||
float hue_cursor_rad = value_changed_h ? wheel_thickness * 0.65f : wheel_thickness * 0.55f;
|
float hue_cursor_rad = value_changed_h ? wheel_thickness * 0.65f : wheel_thickness * 0.55f;
|
||||||
int hue_cursor_segments = ImClamp((int)(hue_cursor_rad / 1.4f), 9, 32);
|
int hue_cursor_segments = ImClamp((int)(hue_cursor_rad / 1.4f), 9, 32);
|
||||||
|
12
imgui.h
12
imgui.h
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.61 WIP
|
// dear imgui, v1.61
|
||||||
// (headers)
|
// (headers)
|
||||||
|
|
||||||
// See imgui.cpp file for documentation.
|
// See imgui.cpp file for documentation.
|
||||||
@ -22,7 +22,7 @@
|
|||||||
#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
|
#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
|
||||||
|
|
||||||
// Version
|
// Version
|
||||||
#define IMGUI_VERSION "1.61 WIP"
|
#define IMGUI_VERSION "1.61"
|
||||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert))
|
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert))
|
||||||
#define IMGUI_HAS_VIEWPORT 1 // Viewport WIP branch
|
#define IMGUI_HAS_VIEWPORT 1 // Viewport WIP branch
|
||||||
|
|
||||||
@ -1649,17 +1649,17 @@ struct ImDrawList
|
|||||||
IMGUI_API void AddImageQuad(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a = ImVec2(0,0), const ImVec2& uv_b = ImVec2(1,0), const ImVec2& uv_c = ImVec2(1,1), const ImVec2& uv_d = ImVec2(0,1), ImU32 col = 0xFFFFFFFF);
|
IMGUI_API void AddImageQuad(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a = ImVec2(0,0), const ImVec2& uv_b = ImVec2(1,0), const ImVec2& uv_c = ImVec2(1,1), const ImVec2& uv_d = ImVec2(0,1), ImU32 col = 0xFFFFFFFF);
|
||||||
IMGUI_API void AddImageRounded(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col, float rounding, int rounding_corners = ImDrawCornerFlags_All);
|
IMGUI_API void AddImageRounded(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col, float rounding, int rounding_corners = ImDrawCornerFlags_All);
|
||||||
IMGUI_API void AddPolyline(const ImVec2* points, const int num_points, ImU32 col, bool closed, float thickness);
|
IMGUI_API void AddPolyline(const ImVec2* points, const int num_points, ImU32 col, bool closed, float thickness);
|
||||||
IMGUI_API void AddConvexPolyFilled(const ImVec2* points, const int num_points, ImU32 col);
|
IMGUI_API void AddConvexPolyFilled(const ImVec2* points, const int num_points, ImU32 col); // Note: Anti-aliased filling requires points to be in clockwise order.
|
||||||
IMGUI_API void AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments = 0);
|
IMGUI_API void AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments = 0);
|
||||||
|
|
||||||
// Stateful path API, add points then finish with PathFill() or PathStroke()
|
// Stateful path API, add points then finish with PathFillConvex() or PathStroke()
|
||||||
inline void PathClear() { _Path.resize(0); }
|
inline void PathClear() { _Path.resize(0); }
|
||||||
inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); }
|
inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); }
|
||||||
inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || memcmp(&_Path[_Path.Size-1], &pos, 8) != 0) _Path.push_back(pos); }
|
inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || memcmp(&_Path[_Path.Size-1], &pos, 8) != 0) _Path.push_back(pos); }
|
||||||
inline void PathFillConvex(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); PathClear(); }
|
inline void PathFillConvex(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); PathClear(); } // Note: Anti-aliased filling requires points to be in clockwise order.
|
||||||
inline void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness); PathClear(); }
|
inline void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness); PathClear(); }
|
||||||
IMGUI_API void PathArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments = 10);
|
IMGUI_API void PathArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments = 10);
|
||||||
IMGUI_API void PathArcToFast(const ImVec2& centre, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle
|
IMGUI_API void PathArcToFast(const ImVec2& centre, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle
|
||||||
IMGUI_API void PathBezierCurveTo(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, int num_segments = 0);
|
IMGUI_API void PathBezierCurveTo(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, int num_segments = 0);
|
||||||
IMGUI_API void PathRect(const ImVec2& rect_min, const ImVec2& rect_max, float rounding = 0.0f, int rounding_corners_flags = ImDrawCornerFlags_All);
|
IMGUI_API void PathRect(const ImVec2& rect_min, const ImVec2& rect_max, float rounding = 0.0f, int rounding_corners_flags = ImDrawCornerFlags_All);
|
||||||
|
|
||||||
|
124
imgui_demo.cpp
124
imgui_demo.cpp
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.61 WIP
|
// dear imgui, v1.61
|
||||||
// (demo code)
|
// (demo code)
|
||||||
|
|
||||||
// Message to the person tempted to delete this file when integrating ImGui into their code base:
|
// Message to the person tempted to delete this file when integrating ImGui into their code base:
|
||||||
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include <ctype.h> // toupper, isprint
|
#include <ctype.h> // toupper, isprint
|
||||||
|
#include <limits.h> // INT_MIN, INT_MAX
|
||||||
#include <math.h> // sqrtf, powf, cosf, sinf, floorf, ceilf
|
#include <math.h> // sqrtf, powf, cosf, sinf, floorf, ceilf
|
||||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||||
#include <stdlib.h> // NULL, malloc, free, atoi
|
#include <stdlib.h> // NULL, malloc, free, atoi
|
||||||
@ -82,7 +83,7 @@ static void ShowExampleAppPropertyEditor(bool* p_open);
|
|||||||
static void ShowExampleAppLongText(bool* p_open);
|
static void ShowExampleAppLongText(bool* p_open);
|
||||||
static void ShowExampleAppAutoResize(bool* p_open);
|
static void ShowExampleAppAutoResize(bool* p_open);
|
||||||
static void ShowExampleAppConstrainedResize(bool* p_open);
|
static void ShowExampleAppConstrainedResize(bool* p_open);
|
||||||
static void ShowExampleAppFixedOverlay(bool* p_open);
|
static void ShowExampleAppSimpleOverlay(bool* p_open);
|
||||||
static void ShowExampleAppWindowTitles(bool* p_open);
|
static void ShowExampleAppWindowTitles(bool* p_open);
|
||||||
static void ShowExampleAppCustomRendering(bool* p_open);
|
static void ShowExampleAppCustomRendering(bool* p_open);
|
||||||
static void ShowExampleAppMainMenuBar();
|
static void ShowExampleAppMainMenuBar();
|
||||||
@ -135,7 +136,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
static bool show_app_long_text = false;
|
static bool show_app_long_text = false;
|
||||||
static bool show_app_auto_resize = false;
|
static bool show_app_auto_resize = false;
|
||||||
static bool show_app_constrained_resize = false;
|
static bool show_app_constrained_resize = false;
|
||||||
static bool show_app_fixed_overlay = false;
|
static bool show_app_simple_overlay = false;
|
||||||
static bool show_app_window_titles = false;
|
static bool show_app_window_titles = false;
|
||||||
static bool show_app_custom_rendering = false;
|
static bool show_app_custom_rendering = false;
|
||||||
static bool show_app_style_editor = false;
|
static bool show_app_style_editor = false;
|
||||||
@ -151,7 +152,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
if (show_app_long_text) ShowExampleAppLongText(&show_app_long_text);
|
if (show_app_long_text) ShowExampleAppLongText(&show_app_long_text);
|
||||||
if (show_app_auto_resize) ShowExampleAppAutoResize(&show_app_auto_resize);
|
if (show_app_auto_resize) ShowExampleAppAutoResize(&show_app_auto_resize);
|
||||||
if (show_app_constrained_resize) ShowExampleAppConstrainedResize(&show_app_constrained_resize);
|
if (show_app_constrained_resize) ShowExampleAppConstrainedResize(&show_app_constrained_resize);
|
||||||
if (show_app_fixed_overlay) ShowExampleAppFixedOverlay(&show_app_fixed_overlay);
|
if (show_app_simple_overlay) ShowExampleAppSimpleOverlay(&show_app_simple_overlay);
|
||||||
if (show_app_window_titles) ShowExampleAppWindowTitles(&show_app_window_titles);
|
if (show_app_window_titles) ShowExampleAppWindowTitles(&show_app_window_titles);
|
||||||
if (show_app_custom_rendering) ShowExampleAppCustomRendering(&show_app_custom_rendering);
|
if (show_app_custom_rendering) ShowExampleAppCustomRendering(&show_app_custom_rendering);
|
||||||
|
|
||||||
@ -218,7 +219,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
ImGui::MenuItem("Long text display", NULL, &show_app_long_text);
|
ImGui::MenuItem("Long text display", NULL, &show_app_long_text);
|
||||||
ImGui::MenuItem("Auto-resizing window", NULL, &show_app_auto_resize);
|
ImGui::MenuItem("Auto-resizing window", NULL, &show_app_auto_resize);
|
||||||
ImGui::MenuItem("Constrained-resizing window", NULL, &show_app_constrained_resize);
|
ImGui::MenuItem("Constrained-resizing window", NULL, &show_app_constrained_resize);
|
||||||
ImGui::MenuItem("Simple overlay", NULL, &show_app_fixed_overlay);
|
ImGui::MenuItem("Simple overlay", NULL, &show_app_simple_overlay);
|
||||||
ImGui::MenuItem("Manipulating window titles", NULL, &show_app_window_titles);
|
ImGui::MenuItem("Manipulating window titles", NULL, &show_app_window_titles);
|
||||||
ImGui::MenuItem("Custom rendering", NULL, &show_app_custom_rendering);
|
ImGui::MenuItem("Custom rendering", NULL, &show_app_custom_rendering);
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
@ -982,13 +983,12 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
if (inputs_mode == 4) flags |= ImGuiColorEditFlags_HEX;
|
if (inputs_mode == 4) flags |= ImGuiColorEditFlags_HEX;
|
||||||
ImGui::ColorPicker4("MyColor##4", (float*)&color, flags, ref_color ? &ref_color_v.x : NULL);
|
ImGui::ColorPicker4("MyColor##4", (float*)&color, flags, ref_color ? &ref_color_v.x : NULL);
|
||||||
|
|
||||||
ImGui::Text("Programmatically set defaults/options:");
|
ImGui::Text("Programmatically set defaults:");
|
||||||
ImGui::SameLine(); ShowHelpMarker("SetColorEditOptions() is designed to allow you to set boot-time default.\nWe don't have Push/Pop functions because you can force options on a per-widget basis if needed, and the user can change non-forced ones with the options menu.\nWe don't have a getter to avoid encouraging you to persistently save values that aren't forward-compatible.");
|
ImGui::SameLine(); ShowHelpMarker("SetColorEditOptions() is designed to allow you to set boot-time default.\nWe don't have Push/Pop functions because you can force options on a per-widget basis if needed, and the user can change non-forced ones with the options menu.\nWe don't have a getter to avoid encouraging you to persistently save values that aren't forward-compatible.");
|
||||||
if (ImGui::Button("Uint8 + HSV"))
|
if (ImGui::Button("Default: Uint8 + HSV + Hue Bar"))
|
||||||
ImGui::SetColorEditOptions(ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_HSV);
|
ImGui::SetColorEditOptions(ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_HSV | ImGuiColorEditFlags_PickerHueBar);
|
||||||
ImGui::SameLine();
|
if (ImGui::Button("Default: Float + HDR + Hue Wheel"))
|
||||||
if (ImGui::Button("Float + HDR"))
|
ImGui::SetColorEditOptions(ImGuiColorEditFlags_Float | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_PickerHueWheel);
|
||||||
ImGui::SetColorEditOptions(ImGuiColorEditFlags_Float | ImGuiColorEditFlags_RGB);
|
|
||||||
|
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
@ -1002,6 +1002,79 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui::TreeNode("Data Types"))
|
||||||
|
{
|
||||||
|
// The DragScalar, InputScalar, SliderScalar functions allow manipulating most common data types: signed/unsigned int/long long and float/double
|
||||||
|
// To avoid polluting the public API with all possible combinations, we use the ImGuiDataType enum to pass the type, and argument-by-values are turned into argument-by-address.
|
||||||
|
// This is the reason the test code below creates local variables to hold "zero" "one" etc. for each types.
|
||||||
|
// In practice, if you frequently use a given type that is not covered by the normal API entry points, you may want to wrap it yourself inside a 1 line function
|
||||||
|
// which can take typed values argument instead of void*, and then pass their address to the generic function. For example:
|
||||||
|
// bool SliderU64(const char *label, u64* value, u64 min = 0, u64 max = 0, const char* format = "%lld") { return SliderScalar(label, ImGuiDataType_U64, value, &min, &max, format); }
|
||||||
|
// Below are helper variables we can take the address of to work-around this:
|
||||||
|
// Note that the SliderScalar function has a maximum usable range of half the natural type maximum, hence the /2 below.
|
||||||
|
const ImS32 s32_zero = 0, s32_one = 1, s32_fifty = 50, s32_min = INT_MIN/2, s32_max = INT_MAX/2, s32_hi_a = INT_MAX/2 - 100, s32_hi_b = INT_MAX/2;
|
||||||
|
const ImU32 u32_zero = 0, u32_one = 1, u32_fifty = 50, u32_min = 0, u32_max = UINT_MAX/2, u32_hi_a = UINT_MAX/2 - 100, u32_hi_b = UINT_MAX/2;
|
||||||
|
const ImS64 s64_zero = 0, s64_one = 1, s64_fifty = 50, s64_min = LLONG_MIN/2, s64_max = LLONG_MAX/2, s64_hi_a = LLONG_MAX/2 - 100, s64_hi_b = LLONG_MAX/2;
|
||||||
|
const ImU64 u64_zero = 0, u64_one = 1, u64_fifty = 50, u64_min = 0, u64_max = ULLONG_MAX/2, u64_hi_a = ULLONG_MAX/2 - 100, u64_hi_b = ULLONG_MAX/2;
|
||||||
|
const float f32_zero = 0.f, f32_one = 1.f, f32_lo_a = -10000000000.0f, f32_hi_a = +10000000000.0f;
|
||||||
|
const double f64_zero = 0., f64_one = 1., f64_lo_a = -1000000000000000, f64_hi_a = +1000000000000000;
|
||||||
|
|
||||||
|
// State
|
||||||
|
static ImS32 s32_v = -1;
|
||||||
|
static ImU32 u32_v = (ImU32)-1;
|
||||||
|
static ImS64 s64_v = -1;
|
||||||
|
static ImU64 u64_v = (ImU64)-1;
|
||||||
|
static float f32_v = 0.123f;
|
||||||
|
static double f64_v = 90000.01234567890123456789;
|
||||||
|
|
||||||
|
const float drag_speed = 0.2f;
|
||||||
|
static bool drag_clamp = false;
|
||||||
|
ImGui::Text("Drags:");
|
||||||
|
ImGui::Checkbox("Clamp integers to 0..50", &drag_clamp); ImGui::SameLine(); ShowHelpMarker("As with every widgets in dear imgui, we never modify values unless there is a user interaction.\nYou can override the clamping limits by using CTRL+Click to input a value.");
|
||||||
|
ImGui::DragScalar("drag s32", ImGuiDataType_S32, &s32_v, drag_speed, drag_clamp ? &s32_zero : NULL, drag_clamp ? &s32_fifty : NULL);
|
||||||
|
ImGui::DragScalar("drag u32", ImGuiDataType_U32, &u32_v, drag_speed, drag_clamp ? &u32_zero : NULL, drag_clamp ? &u32_fifty : NULL, "%u ms");
|
||||||
|
ImGui::DragScalar("drag s64", ImGuiDataType_S64, &s64_v, drag_speed, drag_clamp ? &s64_zero : NULL, drag_clamp ? &s64_fifty : NULL);
|
||||||
|
ImGui::DragScalar("drag u64", ImGuiDataType_U64, &u64_v, drag_speed, drag_clamp ? &u64_zero : NULL, drag_clamp ? &u64_fifty : NULL);
|
||||||
|
ImGui::DragScalar("drag float", ImGuiDataType_Float, &f32_v, 0.005f, &f32_zero, &f32_one, "%f", 1.0f);
|
||||||
|
ImGui::DragScalar("drag float ^2", ImGuiDataType_Float, &f32_v, 0.005f, &f32_zero, &f32_one, "%f", 2.0f); ImGui::SameLine(); ShowHelpMarker("You can use the 'power' parameter to increase tweaking precision on one side of the range.");
|
||||||
|
ImGui::DragScalar("drag double", ImGuiDataType_Double, &f64_v, 0.0005f, &f64_zero, NULL, "%.10f grams", 1.0f);
|
||||||
|
ImGui::DragScalar("drag double ^2", ImGuiDataType_Double, &f64_v, 0.0005f, &f64_zero, &f64_one, "0 < %.10f < 1", 2.0f);
|
||||||
|
|
||||||
|
ImGui::Text("Sliders");
|
||||||
|
ImGui::SliderScalar("slider s32 low", ImGuiDataType_S32, &s32_v, &s32_zero, &s32_fifty,"%d");
|
||||||
|
ImGui::SliderScalar("slider s32 high", ImGuiDataType_S32, &s32_v, &s32_hi_a, &s32_hi_b, "%d");
|
||||||
|
ImGui::SliderScalar("slider s32 full", ImGuiDataType_S32, &s32_v, &s32_min, &s32_max, "%d");
|
||||||
|
ImGui::SliderScalar("slider u32 low", ImGuiDataType_U32, &u32_v, &u32_zero, &u32_fifty,"%u");
|
||||||
|
ImGui::SliderScalar("slider u32 high", ImGuiDataType_U32, &u32_v, &u32_hi_a, &u32_hi_b, "%u");
|
||||||
|
ImGui::SliderScalar("slider u32 full", ImGuiDataType_U32, &u32_v, &u32_min, &u32_max, "%u");
|
||||||
|
ImGui::SliderScalar("slider s64 low", ImGuiDataType_S64, &s64_v, &s64_zero, &s64_fifty,"%I64d");
|
||||||
|
ImGui::SliderScalar("slider s64 high", ImGuiDataType_S64, &s64_v, &s64_hi_a, &s64_hi_b, "%I64d");
|
||||||
|
ImGui::SliderScalar("slider s64 full", ImGuiDataType_S64, &s64_v, &s64_min, &s64_max, "%I64d");
|
||||||
|
ImGui::SliderScalar("slider u64 low", ImGuiDataType_U64, &u64_v, &u64_zero, &u64_fifty,"%I64u ms");
|
||||||
|
ImGui::SliderScalar("slider u64 high", ImGuiDataType_U64, &u64_v, &u64_hi_a, &u64_hi_b, "%I64u ms");
|
||||||
|
ImGui::SliderScalar("slider u64 full", ImGuiDataType_U64, &u64_v, &u64_min, &u64_max, "%I64u ms");
|
||||||
|
ImGui::SliderScalar("slider float low", ImGuiDataType_Float, &f32_v, &f32_zero, &f32_one);
|
||||||
|
ImGui::SliderScalar("slider float low^2", ImGuiDataType_Float, &f32_v, &f32_zero, &f32_one, "%.10f", 2.0f);
|
||||||
|
ImGui::SliderScalar("slider float high", ImGuiDataType_Float, &f32_v, &f32_lo_a, &f32_hi_a, "%e");
|
||||||
|
ImGui::SliderScalar("slider double low", ImGuiDataType_Double, &f64_v, &f64_zero, &f64_one, "%.10f grams", 1.0f);
|
||||||
|
ImGui::SliderScalar("slider double low^2",ImGuiDataType_Double, &f64_v, &f64_zero, &f64_one, "%.10f", 2.0f);
|
||||||
|
ImGui::SliderScalar("slider double high", ImGuiDataType_Double, &f64_v, &f64_lo_a, &f64_hi_a, "%e grams", 1.0f);
|
||||||
|
|
||||||
|
static bool inputs_step = true;
|
||||||
|
ImGui::Text("Inputs");
|
||||||
|
ImGui::Checkbox("Show step buttons", &inputs_step);
|
||||||
|
ImGui::InputScalar("input s32", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%d");
|
||||||
|
ImGui::InputScalar("input s32 hex", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%08X", ImGuiInputTextFlags_CharsHexadecimal);
|
||||||
|
ImGui::InputScalar("input u32", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%u");
|
||||||
|
ImGui::InputScalar("input u32 hex", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%08X", ImGuiInputTextFlags_CharsHexadecimal);
|
||||||
|
ImGui::InputScalar("input s64", ImGuiDataType_S64, &s64_v, inputs_step ? &s64_one : NULL);
|
||||||
|
ImGui::InputScalar("input u64", ImGuiDataType_U64, &u64_v, inputs_step ? &u64_one : NULL);
|
||||||
|
ImGui::InputScalar("input float", ImGuiDataType_Float, &f32_v, inputs_step ? &f32_one : NULL);
|
||||||
|
ImGui::InputScalar("input double", ImGuiDataType_Double, &f64_v, inputs_step ? &f64_one : NULL);
|
||||||
|
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
if (ImGui::TreeNode("Multi-component Widgets"))
|
if (ImGui::TreeNode("Multi-component Widgets"))
|
||||||
{
|
{
|
||||||
static float vec4f[4] = { 0.10f, 0.20f, 0.30f, 0.44f };
|
static float vec4f[4] = { 0.10f, 0.20f, 0.30f, 0.44f };
|
||||||
@ -2479,7 +2552,7 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Demonstrate creating a simple static window with no decoration + a context-menu to choose which corner of the screen to use.
|
// Demonstrate creating a simple static window with no decoration + a context-menu to choose which corner of the screen to use.
|
||||||
static void ShowExampleAppFixedOverlay(bool* p_open)
|
static void ShowExampleAppSimpleOverlay(bool* p_open)
|
||||||
{
|
{
|
||||||
// FIXME-VIEWPORT-ABS: Select a default viewport
|
// FIXME-VIEWPORT-ABS: Select a default viewport
|
||||||
const float DISTANCE = 10.0f;
|
const float DISTANCE = 10.0f;
|
||||||
@ -2493,7 +2566,7 @@ static void ShowExampleAppFixedOverlay(bool* p_open)
|
|||||||
ImGui::SetNextWindowViewport(viewport->ID);
|
ImGui::SetNextWindowViewport(viewport->ID);
|
||||||
}
|
}
|
||||||
ImGui::SetNextWindowBgAlpha(0.3f); // Transparent background
|
ImGui::SetNextWindowBgAlpha(0.3f); // Transparent background
|
||||||
if (ImGui::Begin("Example: Fixed Overlay", p_open, (corner != -1 ? ImGuiWindowFlags_NoMove : 0) | ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_NoFocusOnAppearing|ImGuiWindowFlags_NoNav))
|
if (ImGui::Begin("Example: Simple Overlay", p_open, (corner != -1 ? ImGuiWindowFlags_NoMove : 0) | ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_NoFocusOnAppearing|ImGuiWindowFlags_NoNav))
|
||||||
{
|
{
|
||||||
ImGui::Text("Simple overlay\n" "in the corner of the screen.\n" "(right-click to change position)");
|
ImGui::Text("Simple overlay\n" "in the corner of the screen.\n" "(right-click to change position)");
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
@ -2561,8 +2634,10 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|||||||
// Primitives
|
// Primitives
|
||||||
ImGui::Text("Primitives");
|
ImGui::Text("Primitives");
|
||||||
static float sz = 36.0f;
|
static float sz = 36.0f;
|
||||||
|
static float thickness = 4.0f;
|
||||||
static ImVec4 col = ImVec4(1.0f,1.0f,0.4f,1.0f);
|
static ImVec4 col = ImVec4(1.0f,1.0f,0.4f,1.0f);
|
||||||
ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 72.0f, "%.0f");
|
ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 72.0f, "%.0f");
|
||||||
|
ImGui::DragFloat("Thickness", &thickness, 0.05f, 1.0f, 8.0f, "%.02f");
|
||||||
ImGui::ColorEdit3("Color", &col.x);
|
ImGui::ColorEdit3("Color", &col.x);
|
||||||
{
|
{
|
||||||
const ImVec2 p = ImGui::GetCursorScreenPos();
|
const ImVec2 p = ImGui::GetCursorScreenPos();
|
||||||
@ -2570,16 +2645,16 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|||||||
float x = p.x + 4.0f, y = p.y + 4.0f, spacing = 8.0f;
|
float x = p.x + 4.0f, y = p.y + 4.0f, spacing = 8.0f;
|
||||||
for (int n = 0; n < 2; n++)
|
for (int n = 0; n < 2; n++)
|
||||||
{
|
{
|
||||||
float thickness = (n == 0) ? 1.0f : 4.0f;
|
float curr_thickness = (n == 0) ? 1.0f : thickness;
|
||||||
draw_list->AddCircle(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 20, thickness); x += sz+spacing;
|
draw_list->AddCircle(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 20, curr_thickness); x += sz+spacing;
|
||||||
draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 0.0f, ImDrawCornerFlags_All, thickness); x += sz+spacing;
|
draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 0.0f, ImDrawCornerFlags_All, curr_thickness); x += sz+spacing;
|
||||||
draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_All, thickness); x += sz+spacing;
|
draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_All, curr_thickness); x += sz+spacing;
|
||||||
draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_TopLeft|ImDrawCornerFlags_BotRight, thickness); x += sz+spacing;
|
draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_TopLeft|ImDrawCornerFlags_BotRight, curr_thickness); x += sz+spacing;
|
||||||
draw_list->AddTriangle(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32, thickness); x += sz+spacing;
|
draw_list->AddTriangle(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32, curr_thickness); x += sz+spacing;
|
||||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y ), col32, thickness); x += sz+spacing;
|
draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y ), col32, curr_thickness); x += sz+spacing; // Horizontal line (note: drawing a filled rectangle will be faster!)
|
||||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, thickness); x += sz+spacing;
|
draw_list->AddLine(ImVec2(x, y), ImVec2(x, y+sz), col32, curr_thickness); x += spacing; // Vertical line (note: drawing a filled rectangle will be faster!)
|
||||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x, y+sz), col32, thickness); x += spacing;
|
draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, curr_thickness); x += sz+spacing; // Diagonal line
|
||||||
draw_list->AddBezierCurve(ImVec2(x, y), ImVec2(x+sz*1.3f,y+sz*0.3f), ImVec2(x+sz-sz*1.3f,y+sz-sz*0.3f), ImVec2(x+sz, y+sz), col32, thickness);
|
draw_list->AddBezierCurve(ImVec2(x, y), ImVec2(x+sz*1.3f,y+sz*0.3f), ImVec2(x+sz-sz*1.3f,y+sz-sz*0.3f), ImVec2(x+sz, y+sz), col32, curr_thickness);
|
||||||
x = p.x + 4;
|
x = p.x + 4;
|
||||||
y += sz+spacing;
|
y += sz+spacing;
|
||||||
}
|
}
|
||||||
@ -2588,6 +2663,9 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|||||||
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f); x += sz+spacing;
|
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f); x += sz+spacing;
|
||||||
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_TopLeft|ImDrawCornerFlags_BotRight); x += sz+spacing;
|
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_TopLeft|ImDrawCornerFlags_BotRight); x += sz+spacing;
|
||||||
draw_list->AddTriangleFilled(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32); x += sz+spacing;
|
draw_list->AddTriangleFilled(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32); x += sz+spacing;
|
||||||
|
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+thickness), col32); x += sz+spacing; // Horizontal line (faster than AddLine, but only handle integer thickness)
|
||||||
|
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+thickness, y+sz), col32); x += spacing+spacing; // Vertical line (faster than AddLine, but only handle integer thickness)
|
||||||
|
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+1, y+1), col32); x += sz; // Pixel (faster than AddLine)
|
||||||
draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x+sz, y+sz), IM_COL32(0,0,0,255), IM_COL32(255,0,0,255), IM_COL32(255,255,0,255), IM_COL32(0,255,0,255));
|
draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x+sz, y+sz), IM_COL32(0,0,0,255), IM_COL32(255,0,0,255), IM_COL32(255,255,0,255), IM_COL32(0,255,0,255));
|
||||||
ImGui::Dummy(ImVec2((sz+spacing)*8, (sz+spacing)*3));
|
ImGui::Dummy(ImVec2((sz+spacing)*8, (sz+spacing)*3));
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.61 WIP
|
// dear imgui, v1.61
|
||||||
// (drawing and font code)
|
// (drawing and font code)
|
||||||
|
|
||||||
// Contains implementation for
|
// Contains implementation for
|
||||||
@ -106,9 +106,15 @@ namespace IMGUI_STB_NAMESPACE
|
|||||||
|
|
||||||
#ifndef STB_TRUETYPE_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds)
|
#ifndef STB_TRUETYPE_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds)
|
||||||
#ifndef IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
|
#ifndef IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
|
||||||
#define STBTT_malloc(x,u) ((void)(u), ImGui::MemAlloc(x))
|
#define STBTT_malloc(x,u) ((void)(u), ImGui::MemAlloc(x))
|
||||||
#define STBTT_free(x,u) ((void)(u), ImGui::MemFree(x))
|
#define STBTT_free(x,u) ((void)(u), ImGui::MemFree(x))
|
||||||
#define STBTT_assert(x) IM_ASSERT(x)
|
#define STBTT_assert(x) IM_ASSERT(x)
|
||||||
|
#define STBTT_fmod(x,y) ImFmod(x,y)
|
||||||
|
#define STBTT_sqrt(x) ImSqrt(x)
|
||||||
|
#define STBTT_pow(x,y) ImPow(x,y)
|
||||||
|
#define STBTT_fabs(x) ImFabs(x)
|
||||||
|
#define STBTT_ifloor(x) ((int)ImFloorStd(x))
|
||||||
|
#define STBTT_iceil(x) ((int)ImCeil(x))
|
||||||
#define STBTT_STATIC
|
#define STBTT_STATIC
|
||||||
#define STB_TRUETYPE_IMPLEMENTATION
|
#define STB_TRUETYPE_IMPLEMENTATION
|
||||||
#else
|
#else
|
||||||
@ -305,7 +311,7 @@ ImDrawListSharedData::ImDrawListSharedData()
|
|||||||
for (int i = 0; i < IM_ARRAYSIZE(CircleVtx12); i++)
|
for (int i = 0; i < IM_ARRAYSIZE(CircleVtx12); i++)
|
||||||
{
|
{
|
||||||
const float a = ((float)i * 2 * IM_PI) / (float)IM_ARRAYSIZE(CircleVtx12);
|
const float a = ((float)i * 2 * IM_PI) / (float)IM_ARRAYSIZE(CircleVtx12);
|
||||||
CircleVtx12[i] = ImVec2(cosf(a), sinf(a));
|
CircleVtx12[i] = ImVec2(ImCos(a), ImSin(a));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -903,7 +909,7 @@ void ImDrawList::PathArcTo(const ImVec2& centre, float radius, float a_min, floa
|
|||||||
for (int i = 0; i <= num_segments; i++)
|
for (int i = 0; i <= num_segments; i++)
|
||||||
{
|
{
|
||||||
const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min);
|
const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min);
|
||||||
_Path.push_back(ImVec2(centre.x + cosf(a) * radius, centre.y + sinf(a) * radius));
|
_Path.push_back(ImVec2(centre.x + ImCos(a) * radius, centre.y + ImSin(a) * radius));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -959,8 +965,8 @@ void ImDrawList::PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImV
|
|||||||
|
|
||||||
void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, int rounding_corners)
|
void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, int rounding_corners)
|
||||||
{
|
{
|
||||||
rounding = ImMin(rounding, fabsf(b.x - a.x) * ( ((rounding_corners & ImDrawCornerFlags_Top) == ImDrawCornerFlags_Top) || ((rounding_corners & ImDrawCornerFlags_Bot) == ImDrawCornerFlags_Bot) ? 0.5f : 1.0f ) - 1.0f);
|
rounding = ImMin(rounding, ImFabs(b.x - a.x) * ( ((rounding_corners & ImDrawCornerFlags_Top) == ImDrawCornerFlags_Top) || ((rounding_corners & ImDrawCornerFlags_Bot) == ImDrawCornerFlags_Bot) ? 0.5f : 1.0f ) - 1.0f);
|
||||||
rounding = ImMin(rounding, fabsf(b.y - a.y) * ( ((rounding_corners & ImDrawCornerFlags_Left) == ImDrawCornerFlags_Left) || ((rounding_corners & ImDrawCornerFlags_Right) == ImDrawCornerFlags_Right) ? 0.5f : 1.0f ) - 1.0f);
|
rounding = ImMin(rounding, ImFabs(b.y - a.y) * ( ((rounding_corners & ImDrawCornerFlags_Left) == ImDrawCornerFlags_Left) || ((rounding_corners & ImDrawCornerFlags_Right) == ImDrawCornerFlags_Right) ? 0.5f : 1.0f ) - 1.0f);
|
||||||
|
|
||||||
if (rounding <= 0.0f || rounding_corners == 0)
|
if (rounding <= 0.0f || rounding_corners == 0)
|
||||||
{
|
{
|
||||||
@ -2702,7 +2708,7 @@ static inline float ImAcos01(float x)
|
|||||||
{
|
{
|
||||||
if (x <= 0.0f) return IM_PI * 0.5f;
|
if (x <= 0.0f) return IM_PI * 0.5f;
|
||||||
if (x >= 1.0f) return 0.0f;
|
if (x >= 1.0f) return 0.0f;
|
||||||
return acosf(x);
|
return ImAcos(x);
|
||||||
//return (-0.69813170079773212f * x * x - 0.87266462599716477f) * x + 1.5707963267948966f; // Cheap approximation, may be enough for what we do.
|
//return (-0.69813170079773212f * x * x - 0.87266462599716477f) * x + 1.5707963267948966f; // Cheap approximation, may be enough for what we do.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.61 WIP
|
// dear imgui, v1.61
|
||||||
// (internals)
|
// (internals)
|
||||||
|
|
||||||
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
||||||
@ -13,6 +13,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h> // FILE*
|
#include <stdio.h> // FILE*
|
||||||
|
#include <stdlib.h> // NULL, malloc, free, qsort, atoi, atof
|
||||||
#include <math.h> // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf
|
#include <math.h> // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf
|
||||||
#include <limits.h> // INT_MIN, INT_MAX
|
#include <limits.h> // INT_MIN, INT_MAX
|
||||||
|
|
||||||
@ -146,11 +147,29 @@ static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Helpers: Maths
|
// Helpers: Maths
|
||||||
|
// - Wrapper for standard libs functions. (Note that imgui_demo.cpp does _not_ use them to keep the code easy to copy)
|
||||||
|
#ifndef IMGUI_DISABLE_MATH_FUNCTIONS
|
||||||
|
static inline float ImFabs(float x) { return fabsf(x); }
|
||||||
|
static inline float ImSqrt(float x) { return sqrtf(x); }
|
||||||
|
static inline float ImPow(float x, float y) { return powf(x, y); }
|
||||||
|
static inline double ImPow(double x, double y) { return pow(x, y); }
|
||||||
|
static inline float ImFmod(float x, float y) { return fmodf(x, y); }
|
||||||
|
static inline double ImFmod(double x, double y) { return fmod(x, y); }
|
||||||
|
static inline float ImCos(float x) { return cosf(x); }
|
||||||
|
static inline float ImSin(float x) { return sinf(x); }
|
||||||
|
static inline float ImAcos(float x) { return acosf(x); }
|
||||||
|
static inline float ImAtan2(float y, float x) { return atan2f(y, x); }
|
||||||
|
static inline double ImAtof(const char* s) { return atof(s); }
|
||||||
|
static inline float ImFloorStd(float x) { return floorf(x); } // we already uses our own ImFloor() { return (float)(int)v } internally so the standard one wrapper is named differently (it's used by stb_truetype)
|
||||||
|
static inline float ImCeil(float x) { return ceilf(x); }
|
||||||
|
#endif
|
||||||
|
// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support for variety of types: signed/unsigned int/long long float/double, using templates here but we could also redefine them 6 times
|
||||||
template<typename T> static inline T ImMin(T lhs, T rhs) { return lhs < rhs ? lhs : rhs; }
|
template<typename T> static inline T ImMin(T lhs, T rhs) { return lhs < rhs ? lhs : rhs; }
|
||||||
template<typename T> static inline T ImMax(T lhs, T rhs) { return lhs >= rhs ? lhs : rhs; }
|
template<typename T> static inline T ImMax(T lhs, T rhs) { return lhs >= rhs ? lhs : rhs; }
|
||||||
template<typename T> static inline T ImClamp(T v, T mn, T mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
|
template<typename T> static inline T ImClamp(T v, T mn, T mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
|
||||||
template<typename T> static inline T ImLerp(T a, T b, float t) { return (T)(a + (b - a) * t); }
|
template<typename T> static inline T ImLerp(T a, T b, float t) { return (T)(a + (b - a) * t); }
|
||||||
template<typename T> static inline void ImSwap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
|
template<typename T> static inline void ImSwap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
|
||||||
|
// - Misc maths helpers
|
||||||
static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); }
|
static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); }
|
||||||
static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); }
|
static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); }
|
||||||
static inline ImVec2 ImClamp(const ImVec2& v, const ImVec2& mn, ImVec2 mx) { return ImVec2((v.x < mn.x) ? mn.x : (v.x > mx.x) ? mx.x : v.x, (v.y < mn.y) ? mn.y : (v.y > mx.y) ? mx.y : v.y); }
|
static inline ImVec2 ImClamp(const ImVec2& v, const ImVec2& mn, ImVec2 mx) { return ImVec2((v.x < mn.x) ? mn.x : (v.x > mx.x) ? mx.x : v.x, (v.y < mn.y) ? mn.y : (v.y > mx.y) ? mx.y : v.y); }
|
||||||
@ -160,17 +179,13 @@ static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t)
|
|||||||
static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
|
static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
|
||||||
static inline float ImLengthSqr(const ImVec2& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y; }
|
static inline float ImLengthSqr(const ImVec2& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y; }
|
||||||
static inline float ImLengthSqr(const ImVec4& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; }
|
static inline float ImLengthSqr(const ImVec4& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; }
|
||||||
static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / sqrtf(d); return fail_value; }
|
static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / ImSqrt(d); return fail_value; }
|
||||||
static inline float ImFloor(float f) { return (float)(int)f; }
|
static inline float ImFloor(float f) { return (float)(int)f; }
|
||||||
static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)v.x, (float)(int)v.y); }
|
static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)v.x, (float)(int)v.y); }
|
||||||
static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; }
|
static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; }
|
||||||
static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
|
static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
|
||||||
static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; }
|
static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; }
|
||||||
static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
|
static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
|
||||||
static inline float ImPow(float x, float y) { return powf(x, y); }
|
|
||||||
static inline double ImPow(double x, double y) { return pow(x, y); }
|
|
||||||
static inline float ImFmod(float x, float y) { return fmodf(x, y); }
|
|
||||||
static inline double ImFmod(double x, double y) { return fmod(x, y); }
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Types
|
// Types
|
||||||
|
Loading…
Reference in New Issue
Block a user