mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-13 16:29:54 +02:00
Compare commits
158 Commits
Author | SHA1 | Date | |
---|---|---|---|
e5cb04b132 | |||
c6f9c558ec | |||
ae5b4991be | |||
03b1e643b4 | |||
12d9505534 | |||
4fd43a8b64 | |||
014e5078a8 | |||
01cc666039 | |||
6469b94304 | |||
7b1ab5b275 | |||
5f336ce8f8 | |||
3be352fc80 | |||
179dc04d8a | |||
52c0b1a340 | |||
324e0310ad | |||
fbabf651f4 | |||
1ec464eb9a | |||
6b76781c66 | |||
99f69eb185 | |||
205874f5b1 | |||
3422cb1308 | |||
5e5f25e2dd | |||
7ac16c02cc | |||
f23c39c395 | |||
4a57a982be | |||
29836412e1 | |||
27d0c3afa9 | |||
afc1099fb5 | |||
795cf6fcb5 | |||
a58a727781 | |||
ec945f44b5 | |||
8eca736a7a | |||
c206a19373 | |||
fbf70070bb | |||
c47bcb25ed | |||
b7b08f52a4 | |||
825f699bde | |||
2460f2abe3 | |||
645a6e0342 | |||
d2939ce0a1 | |||
a1597cff08 | |||
a8f409a848 | |||
e8447dea45 | |||
d8d58b038e | |||
41e2aa2e7a | |||
6a546a500f | |||
8a9ee9cded | |||
206d78a524 | |||
36af398056 | |||
b2039aac67 | |||
6461fd40ab | |||
b25756be4a | |||
751d153ca9 | |||
70289ab42c | |||
8db94cd992 | |||
b73305be11 | |||
9a9ee7f813 | |||
f4d062fa11 | |||
a456d17dfc | |||
ce230fc370 | |||
13f718337a | |||
901d432cb7 | |||
302896d488 | |||
093afd4f7f | |||
45499b8f2f | |||
8c80d533d9 | |||
b30d33378d | |||
8d71bc2132 | |||
833eb771f2 | |||
1e8b9f84da | |||
4448734041 | |||
32be6c064b | |||
5919a6fa89 | |||
021c28ae39 | |||
08108cf9ee | |||
2e50d0706b | |||
d451f6cc30 | |||
7b0570d6ba | |||
fdf952108d | |||
df89a16d26 | |||
9b50e691ed | |||
97dad66516 | |||
9262609eaf | |||
05a25e5f36 | |||
fc9ccad6b9 | |||
024993adf9 | |||
4c201994d4 | |||
5dc5610ad5 | |||
95c99aaa4b | |||
c6b01e8e1d | |||
14539b3ed2 | |||
d3fcc37e9e | |||
3c65b650e8 | |||
f32663b33c | |||
7f8f0096d8 | |||
fb0f2ebd41 | |||
fa279a6aa0 | |||
f75b29e7be | |||
8018623c5b | |||
170d02bd99 | |||
7607aea018 | |||
43c099f31e | |||
152dae9e2a | |||
9f98b4e7f2 | |||
a252a287bf | |||
46d75202b8 | |||
0e5b1ea297 | |||
214dd68ec1 | |||
a4dd4d60b4 | |||
8241cd6284 | |||
009276b6cb | |||
209a6a751c | |||
89ac87cd91 | |||
90b152f265 | |||
ede8825fb2 | |||
b15b25bccd | |||
8074b49148 | |||
fc61018b1c | |||
473a01adb0 | |||
a24578ec09 | |||
db886f3953 | |||
963839373c | |||
55041ac3be | |||
912c45ab23 | |||
4929a8e4a5 | |||
a876ad877d | |||
5d87941451 | |||
76ddacd2a1 | |||
218ff3a2a5 | |||
c7f5876f8a | |||
bbd061538c | |||
b8c22bdb28 | |||
fdc526e8f8 | |||
b335225caa | |||
e223bd8177 | |||
4be8155002 | |||
825f2ae455 | |||
eefae08261 | |||
550f110354 | |||
fb7f6cab8c | |||
06f7854b16 | |||
89685b346c | |||
66336528c8 | |||
3a6c9907cd | |||
b5bae9781d | |||
78d6bdf080 | |||
a07c8b6999 | |||
21d9e8e1f4 | |||
403bf45245 | |||
222b7ddbfa | |||
741ab74b55 | |||
1d3c3070d8 | |||
8e4046e13b | |||
0d03e1fafa | |||
a1d2c6fad9 | |||
ab4ef822f0 | |||
0738611559 | |||
dca7c3c629 |
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
custom: ['https://github.com/ocornut/imgui/wiki/Sponsors']
|
70
.github/workflows/build.yml
vendored
70
.github/workflows/build.yml
vendored
@ -180,7 +180,7 @@ jobs:
|
|||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx12/example_win32_directx12.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx12/example_win32_directx12.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
|
||||||
Linux:
|
Linux:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
with:
|
with:
|
||||||
@ -389,45 +389,43 @@ jobs:
|
|||||||
wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
|
wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
|
||||||
tar -xvf master.tar.gz
|
tar -xvf master.tar.gz
|
||||||
emsdk-master/emsdk update
|
emsdk-master/emsdk update
|
||||||
emsdk-master/emsdk install latest-fastcomp
|
emsdk-master/emsdk install latest
|
||||||
emsdk-master/emsdk activate latest-fastcomp
|
emsdk-master/emsdk activate latest
|
||||||
|
|
||||||
- name: Build example_emscripten
|
- name: Build example_emscripten
|
||||||
run: |
|
run: |
|
||||||
source emsdk-master/emsdk_env.sh
|
pushd emsdk-master
|
||||||
|
source ./emsdk_env.sh
|
||||||
|
popd
|
||||||
make -C examples/example_emscripten
|
make -C examples/example_emscripten
|
||||||
|
|
||||||
Static-Analysis:
|
Discord-CI:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
|
if: always()
|
||||||
|
needs: [Windows, Linux, MacOS, iOS, Emscripten]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: dearimgui/github_discord_notifier@latest
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
discord-webhook: ${{ secrets.DISCORD_CI_WEBHOOK }}
|
||||||
|
github-token: ${{ github.token }}
|
||||||
- name: Install Dependencies
|
action-task: discord-jobs
|
||||||
env:
|
discord-filter: "'{{ github.branch }}'.match(/master|docking|tables/g) != null && '{{ run.conclusion }}' != '{{ last_run.conclusion }}'"
|
||||||
PVS_STUDIO_LICENSE: ${{ secrets.PVS_STUDIO_LICENSE }}
|
discord-username: GitHub Actions
|
||||||
run: |
|
discord-job-new-failure-message: ''
|
||||||
if [[ "$PVS_STUDIO_LICENSE" != "" ]];
|
discord-job-fixed-failure-message: ''
|
||||||
then
|
discord-job-new-failure-embed: |
|
||||||
echo "$PVS_STUDIO_LICENSE" > pvs-studio.lic
|
{
|
||||||
wget -q https://files.viva64.com/etc/pubkey.txt
|
"title": "`{{ job.name }}` job is failing on `{{ github.branch }}`!",
|
||||||
sudo apt-key add pubkey.txt
|
"description": "Commit [{{ github.context.payload.head_commit.title }}]({{ github.context.payload.head_commit.url }}) pushed to [{{ github.branch }}]({{ github.branch_url }}) broke [{{ job.name }}]({{ job.url }}) build job.\nFailing steps: {{ failing_steps }}",
|
||||||
sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.viva64.com/etc/viva64.list
|
"url": "{{ job.url }}",
|
||||||
sudo apt-get update
|
"color": "0xFF0000",
|
||||||
sudo apt-get install -y pvs-studio
|
"timestamp": "{{ run.updated_at }}"
|
||||||
fi
|
}
|
||||||
|
discord-job-fixed-failure-embed: |
|
||||||
- name: PVS-Studio static analysis
|
{
|
||||||
run: |
|
"title": "`{{ github.branch }}` branch is no longer failing!",
|
||||||
if [[ ! -f pvs-studio.lic ]];
|
"description": "Build failures were fixed on [{{ github.branch }}]({{ github.branch_url }}) branch.",
|
||||||
then
|
"color": "0x00FF00",
|
||||||
echo "PVS Studio license is missing. No analysis will be performed."
|
"url": "{{ github.context.payload.head_commit.url }}",
|
||||||
echo "If you have a PVS Studio license please create a project secret named PVS_STUDIO_LICENSE with your license."
|
"timestamp": "{{ run.completed_at }}"
|
||||||
echo "You may use a free license. More information at https://www.viva64.com/en/b/0457/"
|
}
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
cd examples/example_null
|
|
||||||
pvs-studio-analyzer trace -- make WITH_EXTRA_WARNINGS=1
|
|
||||||
pvs-studio-analyzer analyze -e ../../imstb_rectpack.h -e ../../imstb_textedit.h -e ../../imstb_truetype.h -l ../../pvs-studio.lic -o pvs-studio.log
|
|
||||||
plog-converter -a 'GA:1,2;OP:1' -t errorfile -w pvs-studio.log
|
|
||||||
|
74
.github/workflows/static-analysis.yml
vendored
Normal file
74
.github/workflows/static-analysis.yml
vendored
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
name: static-analysis
|
||||||
|
|
||||||
|
on:
|
||||||
|
push: {}
|
||||||
|
pull_request: {}
|
||||||
|
schedule:
|
||||||
|
- cron: '0 9 * * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
PVS-Studio:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
env:
|
||||||
|
PVS_STUDIO_LICENSE: ${{ secrets.PVS_STUDIO_LICENSE }}
|
||||||
|
run: |
|
||||||
|
if [[ "$PVS_STUDIO_LICENSE" != "" ]];
|
||||||
|
then
|
||||||
|
echo "$PVS_STUDIO_LICENSE" > pvs-studio.lic
|
||||||
|
wget -q https://files.viva64.com/etc/pubkey.txt
|
||||||
|
sudo apt-key add pubkey.txt
|
||||||
|
sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.viva64.com/etc/viva64.list
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y pvs-studio
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: PVS-Studio static analysis
|
||||||
|
run: |
|
||||||
|
if [[ ! -f pvs-studio.lic ]];
|
||||||
|
then
|
||||||
|
echo "PVS Studio license is missing. No analysis will be performed."
|
||||||
|
echo "If you have a PVS Studio license please create a project secret named PVS_STUDIO_LICENSE with your license."
|
||||||
|
echo "You may use a free license. More information at https://www.viva64.com/en/b/0457/"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
cd examples/example_null
|
||||||
|
pvs-studio-analyzer trace -- make WITH_EXTRA_WARNINGS=1
|
||||||
|
pvs-studio-analyzer analyze -e ../../imstb_rectpack.h -e ../../imstb_textedit.h -e ../../imstb_truetype.h -l ../../pvs-studio.lic -o pvs-studio.log
|
||||||
|
plog-converter -a 'GA:1,2;OP:1' -t errorfile -w pvs-studio.log
|
||||||
|
|
||||||
|
Discord-CI:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
needs: [PVS-Studio]
|
||||||
|
if: always()
|
||||||
|
steps:
|
||||||
|
- uses: dearimgui/github_discord_notifier@latest
|
||||||
|
with:
|
||||||
|
discord-webhook: ${{ secrets.DISCORD_CI_WEBHOOK }}
|
||||||
|
github-token: ${{ github.token }}
|
||||||
|
action-task: discord-jobs
|
||||||
|
discord-filter: "'{{ github.branch }}'.match(/master|docking|tables/g) != null && '{{ run.conclusion }}' != '{{ last_run.conclusion }}'"
|
||||||
|
discord-username: GitHub Actions
|
||||||
|
discord-job-new-failure-message: ''
|
||||||
|
discord-job-fixed-failure-message: ''
|
||||||
|
discord-job-new-failure-embed: |
|
||||||
|
{
|
||||||
|
"title": "`{{ job.name }}` job is failing on `{{ github.branch }}`!",
|
||||||
|
"description": "Commit [{{ github.context.payload.head_commit.title }}]({{ github.context.payload.head_commit.url }}) pushed to [{{ github.branch }}]({{ github.branch_url }}) broke static analysis [{{ job.name }}]({{ job.url }}) job.\nFailing steps: {{ failing_steps }}",
|
||||||
|
"url": "{{ job.url }}",
|
||||||
|
"color": "0xFF0000",
|
||||||
|
"timestamp": "{{ run.updated_at }}"
|
||||||
|
}
|
||||||
|
discord-job-fixed-failure-embed: |
|
||||||
|
{
|
||||||
|
"title": "`{{ github.branch }}` branch is no longer failing!",
|
||||||
|
"description": "Static analysis failures were fixed on [{{ github.branch }}]({{ github.branch_url }}) branch.",
|
||||||
|
"color": "0x00FF00",
|
||||||
|
"url": "{{ github.context.payload.head_commit.url }}",
|
||||||
|
"timestamp": "{{ run.completed_at }}"
|
||||||
|
}
|
@ -31,6 +31,197 @@ HOW TO UPDATE?
|
|||||||
- Please report any issue!
|
- Please report any issue!
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
VERSION 1.79 (Released 2020-10-08)
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Breaking Changes:
|
||||||
|
|
||||||
|
- Fonts: Removed ImFont::DisplayOffset in favor of ImFontConfig::GlyphOffset. DisplayOffset was applied
|
||||||
|
after scaling and not very meaningful/useful outside of being needed by the default ProggyClean font.
|
||||||
|
It was also getting in the way of better font scaling, so let's get rid of it now!
|
||||||
|
If you used DisplayOffset it was probably in association to rasterizing a font at a specific size,
|
||||||
|
in which case the corresponding offset may be reported into GlyphOffset. (#1619)
|
||||||
|
If you scaled this value after calling AddFontDefault(), this is now done automatically.
|
||||||
|
- ImGuiListClipper: Renamed constructor parameters which created an ambiguous alternative to using
|
||||||
|
the ImGuiListClipper::Begin() function, with misleading edge cases. Always use ImGuiListClipper::Begin()!
|
||||||
|
Kept inline redirection function (will obsolete).
|
||||||
|
(note: imgui_memory_editor <0.40 from imgui_club/ used this old clipper API. Update your copy if needed).
|
||||||
|
- Style: Renamed style.TabMinWidthForUnselectedCloseButton to style.TabMinWidthForCloseButton.
|
||||||
|
- Renamed ImGuiSliderFlags_ClampOnInput to ImGuiSliderFlags_AlwaysClamp. Kept redirection enum (will obsolete).
|
||||||
|
- Renamed OpenPopupContextItem() back to OpenPopupOnItemClick(), REVERTED CHANGE FROM 1.77.
|
||||||
|
For variety of reason this is more self-explanatory and less error-prone. Kept inline redirection function.
|
||||||
|
- Removed return value from OpenPopupOnItemClick() - returned true on mouse release on item - because it
|
||||||
|
is inconsistent with other popups API and makes others misleading. It's also and unnecessary: you can
|
||||||
|
use IsWindowAppearing() after BeginPopup() for a similar result.
|
||||||
|
|
||||||
|
Other Changes:
|
||||||
|
|
||||||
|
- Window: Fixed using non-zero pivot in SetNextWindowPos() when the window is collapsed. (#3433)
|
||||||
|
- Nav: Fixed navigation resuming on first visible item when using gamepad. [@rokups]
|
||||||
|
- Nav: Fixed using Alt to toggle the Menu layer when inside a Modal window. (#787)
|
||||||
|
- Scrolling: Fixed SetScrollHere(0) functions edge snapping when called during a frame where
|
||||||
|
ContentSize is changing (issue introduced in 1.78). (#3452).
|
||||||
|
- InputText: Added support for Page Up/Down in InputTextMultiline(). (#3430) [@Xipiryon]
|
||||||
|
- InputText: Added selection helpers in ImGuiInputTextCallbackData().
|
||||||
|
- InputText: Added ImGuiInputTextFlags_CallbackEdit to modify internally owned buffer after an edit.
|
||||||
|
(note that InputText() already returns true on edit, the callback is useful mainly to manipulate the
|
||||||
|
underlying buffer while focus is active).
|
||||||
|
- InputText: Fixed using ImGuiInputTextFlags_Password with InputTextMultiline(). (#3427, #3428)
|
||||||
|
It is a rather unusual or useless combination of features but no reason it shouldn't work!
|
||||||
|
- InputText: Fixed minor scrolling glitch when erasing trailing lines in InputTextMultiline().
|
||||||
|
- InputText: Fixed cursor being partially covered after using Ctrl+End key.
|
||||||
|
- InputText: Fixed callback's helper DeleteChars() function when cursor is inside the deleted block. (#3454)
|
||||||
|
- InputText: Made pressing Down arrow on the last line when it doesn't have a carriage return not move to
|
||||||
|
the end of the line (so it is consistent with Up arrow, and behave same as Notepad and Visual Studio.
|
||||||
|
Note that some other text editors instead would move the crusor to the end of the line). [@Xipiryon]
|
||||||
|
- DragFloat, DragScalar: Fixed ImGuiSliderFlags_ClampOnInput not being honored in the special case
|
||||||
|
where v_min == v_max. (#3361)
|
||||||
|
- SliderInt, SliderScalar: Fixed reaching of maximum value with inverted integer min/max ranges, both
|
||||||
|
with signed and unsigned types. Added reverse Sliders to Demo. (#3432, #3449) [@rokups]
|
||||||
|
- Text: Bypass unnecessary formatting when using the TextColored()/TextWrapped()/TextDisabled() helpers
|
||||||
|
with a "%s" format string. (#3466)
|
||||||
|
- CheckboxFlags: Display mixed-value/tristate marker when passed flags that have multiple bits set and
|
||||||
|
stored value matches neither zero neither the full set.
|
||||||
|
- BeginMenuBar: Fixed minor bug where CursorPosMax gets pushed to CursorPos prior to calling BeginMenuBar(),
|
||||||
|
so e.g. calling the function at the end of a window would often add +ItemSpacing.y to scrolling range.
|
||||||
|
- TreeNode, CollapsingHeader: Made clicking on arrow toggle toggle the open state on the Mouse Down event
|
||||||
|
rather than the Mouse Down+Up sequence, even if the _OpenOnArrow flag isn't set. This is standard behavior
|
||||||
|
and amends the change done in 1.76 which only affected cases were _OpenOnArrow flag was set.
|
||||||
|
(This is also necessary to support full multi/range-select/drag and drop operations.)
|
||||||
|
- Tab Bar: Added TabItemButton() to submit tab that behave like a button. (#3291) [@Xipiryon]
|
||||||
|
- Tab Bar: Added ImGuiTabItemFlags_Leading and ImGuiTabItemFlags_Trailing flags to position tabs or button
|
||||||
|
at either end of the tab bar. Those tabs won't be part of the scrolling region, and when reordering cannot
|
||||||
|
be moving outside of their section. Most often used with TabItemButton(). (#3291) [@Xipiryon]
|
||||||
|
- Tab Bar: Added ImGuiTabItemFlags_NoReorder flag to disable reordering a given tab.
|
||||||
|
- Tab Bar: Keep tab item close button visible while dragging a tab (independent of hovering state).
|
||||||
|
- Tab Bar: Fixed a small bug where closing a tab that is not selected would leave a tab hole for a frame.
|
||||||
|
- Tab Bar: Fixed a small bug where scrolling buttons (with ImGuiTabBarFlags_FittingPolicyScroll) would
|
||||||
|
generate an unnecessary extra draw call.
|
||||||
|
- Tab Bar: Fixed a small bug where toggling a tab bar from Reorderable to not Reorderable would leave
|
||||||
|
tabs reordered in the tab list popup. [@Xipiryon]
|
||||||
|
- Columns: Fix inverted ClipRect being passed to renderer when using certain primitives inside of
|
||||||
|
a fully clipped column. (#3475) [@szreder]
|
||||||
|
- Popups, Tooltips: Fix edge cases issues with positionning popups and tooltips when they are larger than
|
||||||
|
viewport on either or both axises. [@Rokups]
|
||||||
|
- Fonts: AddFontDefault() adjust its vertical offset based on floor(size/13) instead of always +1.
|
||||||
|
Was previously done by altering DisplayOffset.y but wouldn't work for DPI scaled font.
|
||||||
|
- Metrics: Various tweaks, listing windows front-to-back, greying inactive items when possible.
|
||||||
|
- Demo: Add simple InputText() callbacks demo (aside from the more elaborate ones in 'Examples->Console').
|
||||||
|
- Backends: OpenGL3: Fix to avoid compiling/calling glBindSampler() on ES or pre 3.3 contexts which have
|
||||||
|
the defines set by a loader. (#3467, #1985) [@jjwebb]
|
||||||
|
- Backends: Vulkan: Some internal refactor aimed at allowing multi-viewport feature to create their
|
||||||
|
own render pass. (#3455, #3459) [@FunMiles]
|
||||||
|
- Backends: DX12: Clarified that imgui_impl_dx12 can be compiled on 32-bit systems by redefining
|
||||||
|
the ImTextureID to be 64-bit (e.g. '#define ImTextureID ImU64' in imconfig.h). (#301)
|
||||||
|
- Backends: DX12: Fix debug layer warning when scissor rect is zero-sized. (#3472, #3462) [@StoneWolf]
|
||||||
|
- Examples: Vulkan: Reworked buffer resize handling, fix for Linux/X11. (#3390, #2626) [@RoryO]
|
||||||
|
- Examples: Vulkan: Switch validation layer to use "VK_LAYER_KHRONOS_validation" instead of
|
||||||
|
"VK_LAYER_LUNARG_standard_validation" which is deprecated (#3459) [@FunMiles]
|
||||||
|
- Examples: DX12: Enable breaking on any warning/error when debug interface is enabled.
|
||||||
|
- Examples: DX12: Added '#define ImTextureID ImU64' in project and build files to also allow building
|
||||||
|
on 32-bit systems. Added project to default Visual Studio solution file. (#301)
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
VERSION 1.78 (Released 2020-08-18)
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Breaking Changes:
|
||||||
|
|
||||||
|
- Obsoleted use of the trailing 'float power=1.0f' parameter for those functions: [@Shironekoben, @ocornut]
|
||||||
|
- DragFloat(), DragFloat2(), DragFloat3(), DragFloat4(), DragFloatRange2(), DragScalar(), DragScalarN()
|
||||||
|
- SliderFloat(), SliderFloat2(), SliderFloat3(), SliderFloat4(), SliderScalar(), SliderScalarN()
|
||||||
|
- VSliderFloat(), VSliderScalar()
|
||||||
|
Replaced the final 'float power=1.0f' argument with ImGuiSliderFlags defaulting to 0 (as with all our flags).
|
||||||
|
Worked out a backward-compatibility scheme so hopefully most C++ codebase should not be affected.
|
||||||
|
In short, when calling those functions:
|
||||||
|
- If you omitted the 'power' parameter (likely!), you are not affected.
|
||||||
|
- If you set the 'power' parameter to 1.0f (same as previous default value):
|
||||||
|
- Your compiler may warn on float>int conversion.
|
||||||
|
- Everything else will work (but will assert if IMGUI_DISABLE_OBSOLETE_FUNCTIONS is defined).
|
||||||
|
- You can replace the 1.0f value with 0 to fix the warning, and be technically correct.
|
||||||
|
- If you set the 'power' parameter to >1.0f (to enable non-linear editing):
|
||||||
|
- Your compiler may warn on float>int conversion.
|
||||||
|
- Code will assert at runtime for IM_ASSERT(power == 1.0f) with the following assert description:
|
||||||
|
"Call Drag function with ImGuiSliderFlags_Logarithmic instead of using the old 'float power' function!".
|
||||||
|
- In case asserts are disabled, the code will not crash and enable the _Logarithmic flag.
|
||||||
|
- You can replace the >1.0f value with ImGuiSliderFlags_Logarithmic to fix the warning/assert
|
||||||
|
and get a _similar_ effect as previous uses of power >1.0f.
|
||||||
|
See https://github.com/ocornut/imgui/issues/3361 for all details.
|
||||||
|
For shared code, you can version check at compile-time with `#if IMGUI_VERSION_NUM >= 17704`.
|
||||||
|
Kept inline redirection functions (will obsolete) apart for: DragFloatRange2(), VSliderFloat(), VSliderScalar().
|
||||||
|
For those three the 'float power=1.0f' version was removed directly as they were most unlikely ever used.
|
||||||
|
- DragInt, DragFloat, DragScalar: Obsoleted use of v_min > v_max to lock edits (introduced in 1.73, this was not
|
||||||
|
demoed nor documented much, will be replaced a more generic ReadOnly feature).
|
||||||
|
|
||||||
|
Other Changes:
|
||||||
|
|
||||||
|
- Nav: Fixed clicking on void (behind any windows) from not clearing the focused window.
|
||||||
|
This would be problematic e.g. in situation where the application relies on io.WantCaptureKeyboard
|
||||||
|
flag being cleared accordingly. (bug introduced in 1.77 WIP on 2020/06/16) (#3344, #2880)
|
||||||
|
- Window: Fixed clicking over an item which hovering has been disabled (e.g inhibited by a popup)
|
||||||
|
from marking the window as moved.
|
||||||
|
- Drag, Slider: Added ImGuiSliderFlags parameters.
|
||||||
|
- For float functions they replace the old trailing 'float power=1.0' parameter.
|
||||||
|
(See #3361 and the "Breaking Changes" block above for all details).
|
||||||
|
- Added ImGuiSliderFlags_Logarithmic flag to enable logarithmic editing
|
||||||
|
(generally more precision around zero), as a replacement to the old 'float power' parameter
|
||||||
|
which was obsoleted. (#1823, #1316, #642) [@Shironekoben, @AndrewBelt]
|
||||||
|
- Added ImGuiSliderFlags_ClampOnInput flag to force clamping value when using
|
||||||
|
CTRL+Click to type in a value manually. (#1829, #3209, #946, #413).
|
||||||
|
[note: RENAMED to ImGuiSliderFlags_AlwaysClamp in 1.79].
|
||||||
|
- Added ImGuiSliderFlags_NoRoundToFormat flag to disable rounding underlying
|
||||||
|
value to match precision of the display format string. (#642)
|
||||||
|
- Added ImGuiSliderFlags_NoInput flag to disable turning widget into a text input
|
||||||
|
with CTRL+Click or Nav Enter.
|
||||||
|
- Nav, Slider: Fix using keyboard/gamepad controls with certain logarithmic sliders where
|
||||||
|
pushing a direction near zero values would be cancelled out. [@Shironekoben]
|
||||||
|
- DragFloatRange2, DragIntRange2: Fixed an issue allowing to drag out of bounds when both
|
||||||
|
min and max value are on the same value. (#1441)
|
||||||
|
- InputText, ImDrawList: Fixed assert triggering when drawing single line of text with more
|
||||||
|
than ~16 KB characters. (Note that current code is going to show corrupted display if after
|
||||||
|
clipping, more than 16 KB characters are visible in the same low-level ImDrawList::RenderText()
|
||||||
|
call. ImGui-level functions such as TextUnformatted() are not affected. This is quite rare
|
||||||
|
but it will be addressed later). (#3349)
|
||||||
|
- Selectable: Fixed highlight/hit extent when used with horizontal scrolling (in or outside columns).
|
||||||
|
Also fixed related text clipping when used in a column after the first one. (#3187, #3386)
|
||||||
|
- Scrolling: Avoid SetScroll, SetScrollFromPos functions from snapping on the edge of scroll
|
||||||
|
limits when close-enough by (WindowPadding - ItemPadding), which was a tweak with too many
|
||||||
|
side-effects. The behavior is still present in SetScrollHere functions as they are more explicitly
|
||||||
|
aiming at making widgets visible. May later be moved to a flag.
|
||||||
|
- Tab Bar: Allow calling SetTabItemClosed() after a tab has been submitted (will process next frame).
|
||||||
|
- InvisibleButton: Made public a small selection of ImGuiButtonFlags (previously in imgui_internal.h)
|
||||||
|
and allowed to pass them to InvisibleButton(): ImGuiButtonFlags_MouseButtonLeft/Right/Middle.
|
||||||
|
This is a small but rather important change because lots of multi-button behaviors could previously
|
||||||
|
only be achieved using lower-level/internal API. Now also available via high-level InvisibleButton()
|
||||||
|
with is a de-facto versatile building block to creating custom widgets with the public API.
|
||||||
|
- Fonts: Fixed ImFontConfig::GlyphExtraSpacing and ImFontConfig::PixelSnapH settings being pulled
|
||||||
|
from the merged/target font settings when merging fonts, instead of being pulled from the source
|
||||||
|
font settings.
|
||||||
|
- ImDrawList: Thick anti-aliased strokes (> 1.0f) with integer thickness now use a texture-based
|
||||||
|
path, reducing the amount of vertices/indices and CPU/GPU usage. (#3245) [@Shironekoben]
|
||||||
|
- This change will facilitate the wider use of thick borders in future style changes.
|
||||||
|
- Requires an extra bit of texture space (~64x64 by default), relies on GPU bilinear filtering.
|
||||||
|
- Set `io.AntiAliasedLinesUseTex = false` to disable rendering using this method.
|
||||||
|
- Clear `ImFontAtlasFlags_NoBakedLines` in ImFontAtlas::Flags to disable baking data in texture.
|
||||||
|
- ImDrawList: changed AddCircle(), AddCircleFilled() default num_segments from 12 to 0, effectively
|
||||||
|
enabling auto-tessellation by default. Tweak tessellation in Style Editor->Rendering section, or
|
||||||
|
by modifying the 'style.CircleSegmentMaxError' value. [@ShironekoBen]
|
||||||
|
- ImDrawList: Fixed minor bug introduced in 1.75 where AddCircle() with 12 segments would generate
|
||||||
|
an extra vertex. (This bug was mistakenly marked as fixed in earlier 1.77 release). [@ShironekoBen]
|
||||||
|
- Demo: Improved "Custom Rendering"->"Canvas" demo with a grid, scrolling and context menu.
|
||||||
|
Also showcase using InvisibleButton() with multiple mouse buttons flags.
|
||||||
|
- Demo: Improved "Layout & Scrolling" -> "Clipping" section.
|
||||||
|
- Demo: Improved "Layout & Scrolling" -> "Child Windows" section.
|
||||||
|
- Style Editor: Added preview of circle auto-tessellation when editing the corresponding value.
|
||||||
|
- Backends: OpenGL3: Added support for glad2 loader. (#3330) [@moritz-h]
|
||||||
|
- Backends: Allegro 5: Fixed horizontal scrolling direction with mouse wheel / touch pads (it seems
|
||||||
|
like Allegro 5 reports it differently from GLFW and SDL). (#3394, #2424, #1463) [@nobody-special666]
|
||||||
|
- Examples: Vulkan: Fixed GLFW+Vulkan and SDL+Vulkan clear color not being set. (#3390) [@RoryO]
|
||||||
|
- CI: Emscripten has stopped their support for their fastcomp backend, switching to latest sdk [@Xipiryon]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.77 (Released 2020-06-29)
|
VERSION 1.77 (Released 2020-06-29)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
@ -40,9 +231,10 @@ Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.77
|
|||||||
Breaking Changes:
|
Breaking Changes:
|
||||||
|
|
||||||
- Removed unnecessary ID (first arg) of ImFontAtlas::AddCustomRectRegular() function. Please
|
- Removed unnecessary ID (first arg) of ImFontAtlas::AddCustomRectRegular() function. Please
|
||||||
note that this is a Beta api and will likely be reworked in order to support multi-DPI accross
|
note that this is a Beta api and will likely be reworked in order to support multi-DPI across
|
||||||
multiple monitors.
|
multiple monitors.
|
||||||
- Renamed OpenPopupOnItemClick() to OpenPopupContextItem(). Kept inline redirection function (will obsolete).
|
- Renamed OpenPopupOnItemClick() to OpenPopupContextItem(). Kept inline redirection function (will obsolete).
|
||||||
|
[NOTE: THIS WAS REVERTED IN 1.79]
|
||||||
- Removed BeginPopupContextWindow(const char*, int mouse_button, bool also_over_items) in favor
|
- Removed BeginPopupContextWindow(const char*, int mouse_button, bool also_over_items) in favor
|
||||||
of BeginPopupContextWindow(const char*, ImGuiPopupFlags flags) with ImGuiPopupFlags_NoOverItems.
|
of BeginPopupContextWindow(const char*, ImGuiPopupFlags flags) with ImGuiPopupFlags_NoOverItems.
|
||||||
Kept inline redirection function (will obsolete).
|
Kept inline redirection function (will obsolete).
|
||||||
@ -98,14 +290,12 @@ Other Changes:
|
|||||||
VtxOffset was not zero would lead to draw commands with wrong VtxOffset. (#2591)
|
VtxOffset was not zero would lead to draw commands with wrong VtxOffset. (#2591)
|
||||||
- ImDrawList, ImDrawListSplitter, Columns: Fixed an issue where starting a split right after
|
- ImDrawList, ImDrawListSplitter, Columns: Fixed an issue where starting a split right after
|
||||||
a callback draw command would incorrectly override the callback draw command.
|
a callback draw command would incorrectly override the callback draw command.
|
||||||
- ImDrawList: Fixed minor bug introduced in 1.75 where AddCircle() with 12 segments would
|
|
||||||
generate an extra unrequired vertex. [@ShironekoBen]
|
|
||||||
- Misc, Freetype: Fix for rare case where FT_Get_Char_Index() succeeds but FT_Load_Glyph() fails.
|
- Misc, Freetype: Fix for rare case where FT_Get_Char_Index() succeeds but FT_Load_Glyph() fails.
|
||||||
- Docs: Improved and moved font documentation to docs/FONTS.md so it can be readable on the web.
|
- Docs: Improved and moved font documentation to docs/FONTS.md so it can be readable on the web.
|
||||||
Updated various links/wiki accordingly. Added FAQ entry about DPI. (#2861) [@ButternCream, @ocornut]
|
Updated various links/wiki accordingly. Added FAQ entry about DPI. (#2861) [@ButternCream, @ocornut]
|
||||||
- CI: Added CI test to verify we're never accidentally dragging libstdc++ (on some compiler setups,
|
- CI: Added CI test to verify we're never accidentally dragging libstdc++ (on some compiler setups,
|
||||||
static constructors for non-pod data seems to drag in libstdc++ due to thread-safety concerns).
|
static constructors for non-pod data seems to drag in libstdc++ due to thread-safety concerns).
|
||||||
Fixed a static constructor which led to this dependency on some compiler setups.
|
Fixed a static constructor which led to this dependency on some compiler setups. [@rokups]
|
||||||
- Backends: Win32: Support for #define NOGDI, won't try to call GetDeviceCaps(). (#3137, #2327)
|
- Backends: Win32: Support for #define NOGDI, won't try to call GetDeviceCaps(). (#3137, #2327)
|
||||||
- Backends: Win32: Fix _WIN32_WINNT < 0x0600 (MinGW defaults to 0x502 == Windows 2003). (#3183)
|
- Backends: Win32: Fix _WIN32_WINNT < 0x0600 (MinGW defaults to 0x502 == Windows 2003). (#3183)
|
||||||
- Backends: SDL: Report a zero display-size when window is minimized, consistent with other backends,
|
- Backends: SDL: Report a zero display-size when window is minimized, consistent with other backends,
|
||||||
@ -531,7 +721,7 @@ Other Changes:
|
|||||||
because it needs application to be linked with '-framework ApplicationServices'. It can be explicitly
|
because it needs application to be linked with '-framework ApplicationServices'. It can be explicitly
|
||||||
enabled back by using '#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS' in imconfig.h. Re-added
|
enabled back by using '#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS' in imconfig.h. Re-added
|
||||||
equivalent using NSPasteboard api in the imgui_impl_osx.mm experimental back-end. (#2546)
|
equivalent using NSPasteboard api in the imgui_impl_osx.mm experimental back-end. (#2546)
|
||||||
- Backends: SDL2: Added dummy ImGui_ImplSDL2_InitForD3D() function to make D3D support more visible.
|
- Backends: SDL2: Added ImGui_ImplSDL2_InitForD3D() function to make D3D support more visible.
|
||||||
(#2482, #2632) [@josiahmanson]
|
(#2482, #2632) [@josiahmanson]
|
||||||
- Examples: Added SDL2+DirectX11 example application. (#2632, #2612, #2482) [@vincenthamm]
|
- Examples: Added SDL2+DirectX11 example application. (#2632, #2612, #2482) [@vincenthamm]
|
||||||
|
|
||||||
@ -691,7 +881,7 @@ Other Changes:
|
|||||||
- Misc: Made IMGUI_CHECKVERSION() macro also check for matching size of ImDrawIdx.
|
- Misc: Made IMGUI_CHECKVERSION() macro also check for matching size of ImDrawIdx.
|
||||||
- Metrics: Added "Show windows rectangles" tool to visualize the different rectangles.
|
- Metrics: Added "Show windows rectangles" tool to visualize the different rectangles.
|
||||||
- Demo: Improved trees in columns demo.
|
- Demo: Improved trees in columns demo.
|
||||||
- Examples: OpenGL: Added a dummy GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized
|
- Examples: OpenGL: Added a test GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized
|
||||||
GL function loaders early, and help users understand what they are missing. (#2421)
|
GL function loaders early, and help users understand what they are missing. (#2421)
|
||||||
- Examples: SDL: Added support for SDL_GameController gamepads (enable with ImGuiConfigFlags_NavEnableGamepad). (#2509) [@DJLink]
|
- Examples: SDL: Added support for SDL_GameController gamepads (enable with ImGuiConfigFlags_NavEnableGamepad). (#2509) [@DJLink]
|
||||||
- Examples: Emscripten: Added Emscripten+SDL+GLES2 example. (#2494, #2492, #2351, #336) [@nicolasnoble, @redblobgames]
|
- Examples: Emscripten: Added Emscripten+SDL+GLES2 example. (#2494, #2492, #2351, #336) [@nicolasnoble, @redblobgames]
|
||||||
@ -799,7 +989,7 @@ Breaking Changes:
|
|||||||
|
|
||||||
- Removed io.DisplayVisibleMin/DisplayVisibleMax (which were marked obsolete and removed from viewport/docking branch already).
|
- Removed io.DisplayVisibleMin/DisplayVisibleMax (which were marked obsolete and removed from viewport/docking branch already).
|
||||||
- Made it illegal/assert when io.DisplayTime == 0.0f (with an exception for the first frame).
|
- Made it illegal/assert when io.DisplayTime == 0.0f (with an exception for the first frame).
|
||||||
If for some reason your time step calculation gives you a zero value, replace it with a dummy small value!
|
If for some reason your time step calculation gives you a zero value, replace it with a arbitrary small value!
|
||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
|
|
||||||
@ -1290,7 +1480,7 @@ Other Changes:
|
|||||||
- ColorEdit: Fixed not being able to pass the ImGuiColorEditFlags_NoAlpha or ImGuiColorEditFlags_HDR flags to SetColorEditOptions().
|
- 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 the 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: Added IMGUI_DISABLE_MATH_FUNCTIONS in imconfig.h to make it easier to redefine wrappers for std/crt math functions.
|
||||||
@ -1327,7 +1517,7 @@ Breaking Changes:
|
|||||||
- removed the default global context and font atlas instance, which were confusing for users of DLL reloading and users of multiple contexts.
|
- removed the default global context and font atlas instance, which were confusing for users of DLL reloading and users of multiple contexts.
|
||||||
- Renamed ImGuiStyleVar_Count_ to ImGuiStyleVar_COUNT and ImGuiMouseCursor_Count_ to ImGuiMouseCursor_COUNT for consistency with other public enums.
|
- Renamed ImGuiStyleVar_Count_ to ImGuiStyleVar_COUNT and ImGuiMouseCursor_Count_ to ImGuiMouseCursor_COUNT for consistency with other public enums.
|
||||||
- Fonts: Moved sample TTF files from extra_fonts/ to misc/fonts/. If you loaded files directly from the imgui repo you may need to update your paths.
|
- Fonts: Moved sample TTF files from extra_fonts/ to misc/fonts/. If you loaded files directly from the imgui repo you may need to update your paths.
|
||||||
- Fonts: changed ImFont::DisplayOffset.y to defaults to 0 instead of +1. Fixed vertical rounding of Ascent/Descent to match TrueType renderer.
|
- Fonts: Changed ImFont::DisplayOffset.y to defaults to 0 instead of +1. Fixed vertical rounding of Ascent/Descent to match TrueType renderer.
|
||||||
If you were adding or subtracting (not assigning) to ImFont::DisplayOffset check if your fonts are correctly aligned vertically. (#1619)
|
If you were adding or subtracting (not assigning) to ImFont::DisplayOffset check if your fonts are correctly aligned vertically. (#1619)
|
||||||
- BeginDragDropSource(): temporarily removed the optional mouse_button=0 parameter because it is not really usable in many situations at the moment.
|
- BeginDragDropSource(): temporarily removed the optional mouse_button=0 parameter because it is not really usable in many situations at the moment.
|
||||||
- Obsoleted IsAnyWindowHovered() in favor of IsWindowHovered(ImGuiHoveredFlags_AnyWindow). Kept redirection function (will obsolete).
|
- Obsoleted IsAnyWindowHovered() in favor of IsWindowHovered(ImGuiHoveredFlags_AnyWindow). Kept redirection function (will obsolete).
|
||||||
|
18
docs/FAQ.md
18
docs/FAQ.md
@ -23,7 +23,7 @@ or view this file with any Markdown viewer.
|
|||||||
| [I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around..](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-clipping-or-disappearing-when-i-move-windows-around) |
|
| [I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around..](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-clipping-or-disappearing-when-i-move-windows-around) |
|
||||||
| [I integrated Dear ImGui in my engine and some elements are displaying outside their expected windows boundaries..](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-displaying-outside-their-expected-windows-boundaries) |
|
| [I integrated Dear ImGui in my engine and some elements are displaying outside their expected windows boundaries..](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-displaying-outside-their-expected-windows-boundaries) |
|
||||||
| **Q&A: Usage** |
|
| **Q&A: Usage** |
|
||||||
| **[How can I have widgets with an empty label?<br>How can I have multiple widgets with the same label?<br>Why are multiple widgets reacting when I interact with one?](#q-how-can-i-have-widgets-with-an-empty-label)** |
|
| **[Why is my widget not reacting when I click on it?<br>How can I have multiple widgets with the same label?<br>Why are multiple widgets reacting when I interact with one?](#q-why-is-my-widget-not-reacting-when-i-click-on-it)** |
|
||||||
| [How can I display an image? What is ImTextureID, how does it work?](#q-how-can-i-display-an-image-what-is-imtextureid-how-does-it-work)|
|
| [How can I display an image? What is ImTextureID, how does it work?](#q-how-can-i-display-an-image-what-is-imtextureid-how-does-it-work)|
|
||||||
| [How can I use my own math types instead of ImVec2/ImVec4?](#q-how-can-i-use-my-own-math-types-instead-of-imvec2imvec4) |
|
| [How can I use my own math types instead of ImVec2/ImVec4?](#q-how-can-i-use-my-own-math-types-instead-of-imvec2imvec4) |
|
||||||
| [How can I interact with standard C++ types (such as std::string and std::vector)?](#q-how-can-i-interact-with-standard-c-types-such-as-stdstring-and-stdvector) |
|
| [How can I interact with standard C++ types (such as std::string and std::vector)?](#q-how-can-i-interact-with-standard-c-types-such-as-stdstring-and-stdvector) |
|
||||||
@ -111,11 +111,11 @@ e.g. `if (ImGui::GetIO().WantCaptureMouse) { ... }`
|
|||||||
**Note:** You should always pass your mouse/keyboard inputs to Dear ImGui, even when the io.WantCaptureXXX flag are set false.
|
**Note:** You should always pass your mouse/keyboard inputs to Dear ImGui, even when the io.WantCaptureXXX flag are set false.
|
||||||
This is because imgui needs to detect that you clicked in the void to unfocus its own windows.
|
This is because imgui needs to detect that you clicked in the void to unfocus its own windows.
|
||||||
|
|
||||||
**Note:** The `io.WantCaptureMouse` is more correct that any manual attempt to "check if the mouse is hovering a window" (don't do that!). It handle mouse dragging correctly (both dragging that started over your application or over a Dear ImGui window) and handle e.g. popup and modal windows blocking inputs.
|
**Note:** The `io.WantCaptureMouse` is more correct that any manual attempt to "check if the mouse is hovering a window" (don't do that!). It handle mouse dragging correctly (both dragging that started over your application or over a Dear ImGui window) and handle e.g. popup and modal windows blocking inputs.
|
||||||
|
|
||||||
**Note:** Those flags are updated by `ImGui::NewFrame()`. However it is generally more correct and easier that you poll flags from the previous frame, then submit your inputs, then call `NewFrame()`. If you attempt to do the opposite (which is generally harder) you are likely going to submit your inputs after `NewFrame()`, and therefore too late.
|
**Note:** Those flags are updated by `ImGui::NewFrame()`. However it is generally more correct and easier that you poll flags from the previous frame, then submit your inputs, then call `NewFrame()`. If you attempt to do the opposite (which is generally harder) you are likely going to submit your inputs after `NewFrame()`, and therefore too late.
|
||||||
|
|
||||||
**Note:** If you are using a touch device, you may find use for an early call to `UpdateHoveredWindowAndCaptureFlags()` to correctly dispatch your initial touch. We will work on better out-of-the-box touch support in the future.
|
**Note:** If you are using a touch device, you may find use for an early call to `UpdateHoveredWindowAndCaptureFlags()` to correctly dispatch your initial touch. We will work on better out-of-the-box touch support in the future.
|
||||||
|
|
||||||
**Note:** Text input widget releases focus on the "KeyDown" event of the Return key, so the subsequent "KeyUp" event that your application receive will typically have `io.WantCaptureKeyboard == false`. Depending on your application logic it may or not be inconvenient to receive that KeyUp event. You might want to track which key-downs were targeted for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.)
|
**Note:** Text input widget releases focus on the "KeyDown" event of the Return key, so the subsequent "KeyUp" event that your application receive will typically have `io.WantCaptureKeyboard == false`. Depending on your application logic it may or not be inconvenient to receive that KeyUp event. You might want to track which key-downs were targeted for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.)
|
||||||
|
|
||||||
@ -173,9 +173,9 @@ Refer to rendering back-ends in the [examples/](https://github.com/ocornut/imgui
|
|||||||
|
|
||||||
# Q&A: Usage
|
# Q&A: Usage
|
||||||
|
|
||||||
|
### Q: Why is my widget not reacting when I click on it?
|
||||||
### Q: How can I have widgets with an empty label?
|
### Q: How can I have widgets with an empty label?
|
||||||
### Q: How can I have multiple widgets with the same label?
|
### Q: How can I have multiple widgets with the same label?
|
||||||
### Q: Why are multiple widgets reacting when I interact with one?
|
|
||||||
|
|
||||||
A primer on labels and the ID Stack...
|
A primer on labels and the ID Stack...
|
||||||
|
|
||||||
@ -453,7 +453,7 @@ ImGui::End();
|
|||||||
- To generate colors: you can use the macro `IM_COL32(255,255,255,255)` to generate them at compile time, or use `ImGui::GetColorU32(IM_COL32(255,255,255,255))` or `ImGui::GetColorU32(ImVec4(1.0f,1.0f,1.0f,1.0f))` to generate a color that is multiplied by the current value of `style.Alpha`.
|
- To generate colors: you can use the macro `IM_COL32(255,255,255,255)` to generate them at compile time, or use `ImGui::GetColorU32(IM_COL32(255,255,255,255))` or `ImGui::GetColorU32(ImVec4(1.0f,1.0f,1.0f,1.0f))` to generate a color that is multiplied by the current value of `style.Alpha`.
|
||||||
- Math operators: if you have setup `IM_VEC2_CLASS_EXTRA` in `imconfig.h` to bind your own math types, you can use your own math types and their natural operators instead of ImVec2. ImVec2 by default doesn't export any math operators in the public API. You may use `#define IMGUI_DEFINE_MATH_OPERATORS` `#include "imgui_internal.h"` to use the internally defined math operators, but instead prefer using your own math library and set it up in `imconfig.h`.
|
- Math operators: if you have setup `IM_VEC2_CLASS_EXTRA` in `imconfig.h` to bind your own math types, you can use your own math types and their natural operators instead of ImVec2. ImVec2 by default doesn't export any math operators in the public API. You may use `#define IMGUI_DEFINE_MATH_OPERATORS` `#include "imgui_internal.h"` to use the internally defined math operators, but instead prefer using your own math library and set it up in `imconfig.h`.
|
||||||
- You can use `ImGui::GetBackgroundDrawList()` or `ImGui::GetForegroundDrawList()` to access draw lists which will be displayed behind and over every other dear imgui windows (one bg/fg drawlist per viewport). This is very convenient if you need to quickly display something on the screen that is not associated to a dear imgui window.
|
- You can use `ImGui::GetBackgroundDrawList()` or `ImGui::GetForegroundDrawList()` to access draw lists which will be displayed behind and over every other dear imgui windows (one bg/fg drawlist per viewport). This is very convenient if you need to quickly display something on the screen that is not associated to a dear imgui window.
|
||||||
- You can also create your own dummy window and draw inside it. Call Begin() with the NoBackground | NoDecoration | NoSavedSettings | NoInputs flags (The `ImGuiWindowFlags_NoDecoration` flag itself is a shortcut for NoTitleBar | NoResize | NoScrollbar | NoCollapse). Then you can retrieve the ImDrawList* via GetWindowDrawList() and draw to it in any way you like.
|
- You can also create your own empty window and draw inside it. Call Begin() with the NoBackground | NoDecoration | NoSavedSettings | NoInputs flags (The `ImGuiWindowFlags_NoDecoration` flag itself is a shortcut for NoTitleBar | NoResize | NoScrollbar | NoCollapse). Then you can retrieve the ImDrawList* via GetWindowDrawList() and draw to it in any way you like.
|
||||||
- You can create your own ImDrawList instance. You'll need to initialize them with `ImGui::GetDrawListSharedData()`, or create your own instancing ImDrawListSharedData, and then call your renderer function with your own ImDrawList or ImDrawData data.
|
- You can create your own ImDrawList instance. You'll need to initialize them with `ImGui::GetDrawListSharedData()`, or create your own instancing ImDrawListSharedData, and then call your renderer function with your own ImDrawList or ImDrawData data.
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
@ -464,7 +464,7 @@ ImGui::End();
|
|||||||
|
|
||||||
### Q: How should I handle DPI in my application?
|
### Q: How should I handle DPI in my application?
|
||||||
|
|
||||||
The short answer is: obtain the desired DPI scale, load a suitable font resized with that scale (always round down font size to nearest integer), and scale your Style structure accordingly using `style.ScaleAllSizes()`.
|
The short answer is: obtain the desired DPI scale, load a suitable font resized with that scale (always round down font size to nearest integer), and scale your Style structure accordingly using `style.ScaleAllSizes()`.
|
||||||
|
|
||||||
Your application may want to detect DPI change and reload the font and reset style being frames.
|
Your application may want to detect DPI change and reload the font and reset style being frames.
|
||||||
|
|
||||||
@ -600,7 +600,7 @@ You may take a look at:
|
|||||||
|
|
||||||
- [Quotes](https://github.com/ocornut/imgui/wiki/Quotes)
|
- [Quotes](https://github.com/ocornut/imgui/wiki/Quotes)
|
||||||
- [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui)
|
- [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui)
|
||||||
- [Gallery](https://github.com/ocornut/imgui/issues/3075)
|
- [Gallery](https://github.com/ocornut/imgui/issues/3488)
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
@ -646,7 +646,7 @@ There is an auto-generated [c-api for Dear ImGui (cimgui)](https://github.com/ci
|
|||||||
- Individuals: you can support continued maintenance and development via PayPal donations. See [README](https://github.com/ocornut/imgui/blob/master/docs/README.md).
|
- Individuals: you can support continued maintenance and development via PayPal donations. See [README](https://github.com/ocornut/imgui/blob/master/docs/README.md).
|
||||||
- If you are experienced with Dear ImGui and C++, look at the [GitHub Issues](https://github.com/ocornut/imgui/issues), look at the [Wiki](https://github.com/ocornut/imgui/wiki), read [docs/TODO.txt](https://github.com/ocornut/imgui/blob/master/docs/TODO.txt) and see how you want to help and can help!
|
- If you are experienced with Dear ImGui and C++, look at the [GitHub Issues](https://github.com/ocornut/imgui/issues), look at the [Wiki](https://github.com/ocornut/imgui/wiki), read [docs/TODO.txt](https://github.com/ocornut/imgui/blob/master/docs/TODO.txt) and see how you want to help and can help!
|
||||||
- Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere etc.
|
- Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere etc.
|
||||||
You may post screenshot or links in the [gallery threads](https://github.com/ocornut/imgui/issues/3075). Visuals are ideal as they inspire other programmers. Disclosing your use of dear imgui help the library grow credibility, and help other teams and programmers with taking decisions.
|
You may post screenshot or links in the [gallery threads](https://github.com/ocornut/imgui/issues/3488). Visuals are ideal as they inspire other programmers. Disclosing your use of dear imgui help the library grow credibility, and help other teams and programmers with taking decisions.
|
||||||
- If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues or sometimes incomplete PR.
|
- If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues or sometimes incomplete PR.
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
@ -142,13 +142,6 @@ ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
|||||||

|

|
||||||
<br>_(settings: Dark style (left), Light style (right) / Font: NotoSansCJKjp-Medium, 20px / Rounding: 5)_
|
<br>_(settings: Dark style (left), Light style (right) / Font: NotoSansCJKjp-Medium, 20px / Rounding: 5)_
|
||||||
|
|
||||||
|
|
||||||
**Offset font vertically by altering the `io.Font->DisplayOffset` value:**
|
|
||||||
```cpp
|
|
||||||
ImFont* font = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
|
|
||||||
font->DisplayOffset.y = 1; // Render 1 pixel down
|
|
||||||
```
|
|
||||||
|
|
||||||
**Font Atlas too large?**
|
**Font Atlas too large?**
|
||||||
|
|
||||||
- If you have very large number of glyphs or multiple fonts, the texture may become too big for your graphics API. The typical result of failing to upload a texture is if every glyphs appears as white rectangles.
|
- If you have very large number of glyphs or multiple fonts, the texture may become too big for your graphics API. The typical result of failing to upload a texture is if every glyphs appears as white rectangles.
|
||||||
@ -337,13 +330,13 @@ DroidSans.ttf
|
|||||||
ProggyClean.ttf
|
ProggyClean.ttf
|
||||||
Copyright (c) 2004, 2005 Tristan Grimmer
|
Copyright (c) 2004, 2005 Tristan Grimmer
|
||||||
MIT License
|
MIT License
|
||||||
recommended loading setting: Size = 13.0, DisplayOffset.Y = +1
|
recommended loading setting: Size = 13.0, GlyphOffset.y = +1
|
||||||
http://www.proggyfonts.net/
|
http://www.proggyfonts.net/
|
||||||
|
|
||||||
ProggyTiny.ttf
|
ProggyTiny.ttf
|
||||||
Copyright (c) 2004, 2005 Tristan Grimmer
|
Copyright (c) 2004, 2005 Tristan Grimmer
|
||||||
MIT License
|
MIT License
|
||||||
recommended loading setting: Size = 10.0, DisplayOffset.Y = +1
|
recommended loading setting: Size = 10.0, GlyphOffset.y = +1
|
||||||
http://www.proggyfonts.net/
|
http://www.proggyfonts.net/
|
||||||
|
|
||||||
Karla-Regular.ttf
|
Karla-Regular.ttf
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
Dear ImGui
|
Dear ImGui
|
||||||
=====
|
=====
|
||||||
[](https://github.com/ocornut/imgui/actions?workflow=build)
|
[](https://github.com/ocornut/imgui/actions?workflow=build) [](https://github.com/ocornut/imgui/actions?workflow=static-analysis)
|
||||||
|
|
||||||
|
|
||||||
<sub>(This library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using Dear ImGui, please consider reaching out.)</sub>
|
<sub>(This library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using Dear ImGui, please consider reaching out.)</sub>
|
||||||
|
|
||||||
Businesses: support continued development via invoiced technical support, maintenance, sponsoring contracts:
|
Businesses: support continued development and maintenance via invoiced technical support, maintenance, sponsoring contracts:
|
||||||
<br> _E-mail: contact @ dearimgui dot com_
|
<br> _E-mail: contact @ dearimgui dot com_
|
||||||
|
|
||||||
Individuals: support continued maintenance and development with [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S).
|
Individuals: support continued development and maintenance [here](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S).
|
||||||
|
|
||||||
|
Also see [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors) page.
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
@ -17,7 +20,7 @@ Dear ImGui is designed to **enable fast iterations** and to **empower programmer
|
|||||||
|
|
||||||
Dear ImGui is particularly suited to integration in games engine (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on consoles platforms where operating system features are non-standard.
|
Dear ImGui is particularly suited to integration in games engine (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on consoles platforms where operating system features are non-standard.
|
||||||
|
|
||||||
| [Usage](#usage) - [How it works](#how-it-works) - [Demo](#demo) - [Integration](#integration) |
|
| [Usage](#usage) - [How it works](#how-it-works) - [Releases](#releases) - [Demo](#demo) - [Integration](#integration) |
|
||||||
:----------------------------------------------------------: |
|
:----------------------------------------------------------: |
|
||||||
| [Upcoming changes](#upcoming-changes) - [Gallery](#gallery) - [Support, FAQ](#support-frequently-asked-questions-faq) - [How to help](#how-to-help) - [Sponsors](#sponsors) - [Credits](#credits) - [License](#license) |
|
| [Upcoming changes](#upcoming-changes) - [Gallery](#gallery) - [Support, FAQ](#support-frequently-asked-questions-faq) - [How to help](#how-to-help) - [Sponsors](#sponsors) - [Credits](#credits) - [License](#license) |
|
||||||
| [Wiki](https://github.com/ocornut/imgui/wiki) - [Language & frameworks bindings](https://github.com/ocornut/imgui/wiki/Bindings) - [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) - [User quotes](https://github.com/ocornut/imgui/wiki/Quotes) |
|
| [Wiki](https://github.com/ocornut/imgui/wiki) - [Language & frameworks bindings](https://github.com/ocornut/imgui/wiki/Bindings) - [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) - [User quotes](https://github.com/ocornut/imgui/wiki/Quotes) |
|
||||||
@ -35,7 +38,7 @@ You will need a backend to integrate Dear ImGui in your app. The backend passes
|
|||||||
After Dear ImGui is setup in your application, you can use it from \_anywhere\_ in your program loop:
|
After Dear ImGui is setup in your application, you can use it from \_anywhere\_ in your program loop:
|
||||||
|
|
||||||
Code:
|
Code:
|
||||||
```cp
|
```cpp
|
||||||
ImGui::Text("Hello, world %d", 123);
|
ImGui::Text("Hello, world %d", 123);
|
||||||
if (ImGui::Button("Save"))
|
if (ImGui::Button("Save"))
|
||||||
MySaveFunction();
|
MySaveFunction();
|
||||||
@ -44,7 +47,7 @@ ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
|||||||
```
|
```
|
||||||
Result:
|
Result:
|
||||||
<br> 
|
<br> 
|
||||||
<br>_(settings: Dark style (left), Light style (right) / Font: Roboto-Medium, 16px / Rounding: 5)_
|
<br>_(settings: Dark style (left), Light style (right) / Font: Roboto-Medium, 16px)_
|
||||||
|
|
||||||
Code:
|
Code:
|
||||||
```cpp
|
```cpp
|
||||||
@ -84,12 +87,16 @@ Dear ImGui allows you to **create elaborate tools** as well as very short-lived
|
|||||||
|
|
||||||
### How it works
|
### How it works
|
||||||
|
|
||||||
Check out the Wiki's [About the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#About-the-IMGUI-paradigm) section if you want to understand the core principles behind the IMGUI paradigm. An IMGUI tries to minimize superfluous state duplication, state synchronization and state retention from the user's point of view. It is less error prone (less code and less bugs) than traditional retained-mode interfaces, and lends itself to create dynamic user interfaces.
|
Check out the Wiki's [About the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#about-the-imgui-paradigm) section if you want to understand the core principles behind the IMGUI paradigm. An IMGUI tries to minimize superfluous state duplication, state synchronization and state retention from the user's point of view. It is less error prone (less code and less bugs) than traditional retained-mode interfaces, and lends itself to create dynamic user interfaces.
|
||||||
|
|
||||||
Dear ImGui outputs vertex buffers and command lists that you can easily render in your application. The number of draw calls and state changes required to render them is fairly small. Because Dear ImGui doesn't know or touch graphics state directly, you can call its functions anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate Dear ImGui with your existing codebase.
|
Dear ImGui outputs vertex buffers and command lists that you can easily render in your application. The number of draw calls and state changes required to render them is fairly small. Because Dear ImGui doesn't know or touch graphics state directly, you can call its functions anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate Dear ImGui with your existing codebase.
|
||||||
|
|
||||||
_A common misunderstanding is to mistake immediate mode gui for immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes as the gui functions are called. This is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are decently optimal and you can render them later, in your app or even remotely._
|
_A common misunderstanding is to mistake immediate mode gui for immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes as the gui functions are called. This is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are decently optimal and you can render them later, in your app or even remotely._
|
||||||
|
|
||||||
|
### Releases
|
||||||
|
|
||||||
|
See [Releases](https://github.com/ocornut/imgui/releases) page.
|
||||||
|
|
||||||
### Demo
|
### Demo
|
||||||
|
|
||||||
Calling the `ImGui::ShowDemoWindow()` function will create a demo window showcasing variety of features and examples. The code is always available for reference in `imgui_demo.cpp`.
|
Calling the `ImGui::ShowDemoWindow()` function will create a demo window showcasing variety of features and examples. The code is always available for reference in `imgui_demo.cpp`.
|
||||||
@ -97,7 +104,7 @@ Calling the `ImGui::ShowDemoWindow()` function will create a demo window showcas
|
|||||||

|

|
||||||
|
|
||||||
You should be able to build the examples from sources (tested on Windows/Mac/Linux). If you don't, let us 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 us 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-20190715.zip](http://www.dearimgui.org/binaries/imgui-demo-binaries-20200412.zip) (Windows binaries, 1.76, built 2020/04/12, master branch) or [older demo binaries](http://www.dearimgui.org/binaries).
|
- [imgui-demo-binaries-20200918.zip](https://www.dearimgui.org/binaries/imgui-demo-binaries-20200918.zip) (Windows, 1.78 WIP, built 2020/09/18, master branch) or [older demo binaries](https://www.dearimgui.org/binaries).
|
||||||
|
|
||||||
The demo applications are not DPI aware so expect some blurriness on a 4K screen. For DPI awareness in your application, you can load/reload your font at different scale, and scale your style with `style.ScaleAllSizes()` (see [FAQ](https://www.dearimgui.org/faq)).
|
The demo applications are not DPI aware so expect some blurriness on a 4K screen. For DPI awareness in your application, you can load/reload your font at different scale, and scale your style with `style.ScaleAllSizes()` (see [FAQ](https://www.dearimgui.org/faq)).
|
||||||
|
|
||||||
@ -113,8 +120,8 @@ Officially maintained bindings (in repository):
|
|||||||
- Frameworks: Emscripten, Allegro5, Marmalade.
|
- Frameworks: Emscripten, Allegro5, Marmalade.
|
||||||
|
|
||||||
Third-party bindings (see [Bindings](https://github.com/ocornut/imgui/wiki/Bindings/) page):
|
Third-party bindings (see [Bindings](https://github.com/ocornut/imgui/wiki/Bindings/) page):
|
||||||
- Languages: C, C#/.Net, ChaiScript, D, Go, Haskell, Haxe/hxcpp, Java, JavaScript, Julia, Kotlin, Lua, Odin, Pascal, PureBasic, Python, Ruby, Rust, Swift...
|
- Languages: C, C# and: Beef, ChaiScript, Crystal, D, Go, Haskell, Haxe/hxcpp, Java, JavaScript, Julia, Kotlin, Lua, Odin, Pascal, PureBasic, Python, Ruby, Rust, Swift...
|
||||||
- Frameworks: AGS/Adventure Game Studio, Amethyst, bsf, Cinder, Cocos2d-x, Diligent Engine, Flexium, GML/Game Maker Studio2, GTK3+OpenGL3, Irrlicht Engine, LÖVE+LUA, Magnum, NanoRT, Nim Game Lib, Ogre, openFrameworks, OSG/OpenSceneGraph, Orx, Photoshop, px_render, Qt/QtDirect3D, SFML, Sokol, Unity, Unreal Engine 4, vtk, Win32 GDI, WxWidgets.
|
- Frameworks: AGS/Adventure Game Studio, Amethyst, bsf, Cinder, Cocos2d-x, Diligent Engine, Flexium, GML/Game Maker Studio2, Godot, GTK3+OpenGL3, Irrlicht Engine, LÖVE+LUA, Magnum, NanoRT, nCine, Nim Game Lib, Ogre, openFrameworks, OSG/OpenSceneGraph, Orx, Photoshop, px_render, Qt/QtDirect3D, SFML, Sokol, Unity, Unreal Engine 4, vtk, Win32 GDI, WxWidgets.
|
||||||
- Note that C bindings ([cimgui](https://github.com/cimgui/cimgui)) are auto-generated, you can use its json/lua output to generate bindings for other languages.
|
- Note that C bindings ([cimgui](https://github.com/cimgui/cimgui)) are auto-generated, you can use its json/lua output to generate bindings for other languages.
|
||||||
|
|
||||||
Also see [Wiki](https://github.com/ocornut/imgui/wiki) for more links and ideas.
|
Also see [Wiki](https://github.com/ocornut/imgui/wiki) for more links and ideas.
|
||||||
@ -125,13 +132,13 @@ Some of the goals for 2020 are:
|
|||||||
- Work on docking. (see [#2109](https://github.com/ocornut/imgui/issues/2109), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch)
|
- Work on docking. (see [#2109](https://github.com/ocornut/imgui/issues/2109), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch)
|
||||||
- Work on multiple viewports / multiple OS windows. (see [#1542](https://github.com/ocornut/imgui/issues/1542), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch looking for feedback)
|
- Work on multiple viewports / multiple OS windows. (see [#1542](https://github.com/ocornut/imgui/issues/1542), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch looking for feedback)
|
||||||
- Work on gamepad/keyboard controls. (see [#787](https://github.com/ocornut/imgui/issues/787))
|
- Work on gamepad/keyboard controls. (see [#787](https://github.com/ocornut/imgui/issues/787))
|
||||||
- Work on new Tables API (to replace Columns). (see [#2957](https://github.com/ocornut/imgui/issues/2957))
|
- Work on new Tables API (to replace Columns). (see [#2957](https://github.com/ocornut/imgui/issues/2957), in public [tables](https://github.com/ocornut/imgui/tree/tables) branch looking for feedback)
|
||||||
- Work on automation and testing system, both to test the library and end-user apps. (see [#435](https://github.com/ocornut/imgui/issues/435))
|
- Work on automation and testing system, both to test the library and end-user apps. (see [#435](https://github.com/ocornut/imgui/issues/435))
|
||||||
- Make the examples look better, improve styles, improve font support, make the examples hi-DPI and multi-DPI aware.
|
- Make the examples look better, improve styles, improve font support, make the examples hi-DPI and multi-DPI aware.
|
||||||
|
|
||||||
### Gallery
|
### Gallery
|
||||||
|
|
||||||
For more user-submitted screenshots of projects using Dear ImGui, check out the [Gallery Threads](https://github.com/ocornut/imgui/issues/3075)!
|
For more user-submitted screenshots of projects using Dear ImGui, check out the [Gallery Threads](https://github.com/ocornut/imgui/issues/3488)!
|
||||||
|
|
||||||
Custom engine
|
Custom engine
|
||||||
[](https://cloud.githubusercontent.com/assets/8225057/20628927/33e14cac-b329-11e6-80f6-9524e93b048a.png)
|
[](https://cloud.githubusercontent.com/assets/8225057/20628927/33e14cac-b329-11e6-80f6-9524e93b048a.png)
|
||||||
@ -144,11 +151,11 @@ Custom engine
|
|||||||
|
|
||||||
### Support, Frequently Asked Questions (FAQ)
|
### Support, Frequently Asked Questions (FAQ)
|
||||||
|
|
||||||
Most common questions will be answered by the [Frequently Asked Questions (FAQ)](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md) page.
|
See: [Frequently Asked Questions (FAQ)](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md) where common questions are answered.
|
||||||
|
|
||||||
See: [Wiki](https://github.com/ocornut/imgui/wiki) for many links, references, articles.
|
See: [Wiki](https://github.com/ocornut/imgui/wiki) for many links, references, articles.
|
||||||
|
|
||||||
See: [Articles about the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#Articles-about-the-IMGUI-paradigm) to read/learn about the Immediate Mode GUI paradigm.
|
See: [Articles about the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#about-the-imgui-paradigm) to read/learn about the Immediate Mode GUI paradigm.
|
||||||
|
|
||||||
If you are new to Dear ImGui and have issues with: compiling, linking, adding fonts, wiring inputs, running or displaying Dear ImGui: you can use [Discord server](http://discord.dearimgui.org).
|
If you are new to Dear ImGui and have issues with: compiling, linking, adding fonts, wiring inputs, running or displaying Dear ImGui: you can use [Discord server](http://discord.dearimgui.org).
|
||||||
|
|
||||||
@ -160,11 +167,11 @@ Private support is available for paying business customers (E-mail: _contact @ d
|
|||||||
|
|
||||||
We occasionally tag [Releases](https://github.com/ocornut/imgui/releases) but it is generally safe and recommended to sync to master/latest. The library is fairly stable and regressions tend to be fixed fast when reported.
|
We occasionally tag [Releases](https://github.com/ocornut/imgui/releases) but it is generally safe and recommended to sync to master/latest. The library is fairly stable and regressions tend to be fixed fast when reported.
|
||||||
|
|
||||||
You may also peak at the [Multi-Viewport](https://github.com/ocornut/imgui/issues/1542) and [Docking](https://github.com/ocornut/imgui/issues/2109) features in the `docking` branch. Many projects are using this branch and it is kept in sync with master regularly.
|
Advanced users may want to use the `docking` branch with [Multi-Viewport](https://github.com/ocornut/imgui/issues/1542) and [Docking](https://github.com/ocornut/imgui/issues/2109) features. This branch is kept in sync with master regularly.
|
||||||
|
|
||||||
**Who uses Dear ImGui?**
|
**Who uses Dear ImGui?**
|
||||||
|
|
||||||
See the [Quotes](https://github.com/ocornut/imgui/wiki/Quotes), [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors), [Software using dear imgui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) Wiki pages for an idea of who is using Dear ImGui. Please add your game/software if you can! Also see the [Gallery Threads](https://github.com/ocornut/imgui/issues/3075)!
|
See the [Quotes](https://github.com/ocornut/imgui/wiki/Quotes), [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors), [Software using dear imgui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) Wiki pages for an idea of who is using Dear ImGui. Please add your game/software if you can! Also see the [Gallery Threads](https://github.com/ocornut/imgui/issues/3488)!
|
||||||
|
|
||||||
How to help
|
How to help
|
||||||
-----------
|
-----------
|
||||||
@ -178,12 +185,7 @@ How to help
|
|||||||
|
|
||||||
**How can I help financing further development of Dear ImGui?**
|
**How can I help financing further development of Dear ImGui?**
|
||||||
|
|
||||||
Your contributions are keeping this project alive. The library is available under a free and permissive license, but continued maintenance and development are a full-time endeavor and I would like to grow the team. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using Dear ImGui, please consider reaching out for invoiced technical support and maintenance contracts. Thank you!
|
See [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors) page.
|
||||||
|
|
||||||
Businesses: support continued development via invoiced technical support, maintenance, sponsoring contracts:
|
|
||||||
<br> _E-mail: contact @ dearimgui.com_
|
|
||||||
|
|
||||||
Individuals: support continued maintenance and development with [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S).
|
|
||||||
|
|
||||||
Sponsors
|
Sponsors
|
||||||
--------
|
--------
|
||||||
@ -213,13 +215,13 @@ Developed by [Omar Cornut](http://www.miracleworld.net) and every direct or indi
|
|||||||
Recurring contributors (2020): Omar Cornut [@ocornut](https://github.com/ocornut), Rokas Kupstys [@rokups](https://github.com/rokups), Ben Carter [@ShironekoBen](https://github.com/ShironekoBen).
|
Recurring contributors (2020): Omar Cornut [@ocornut](https://github.com/ocornut), Rokas Kupstys [@rokups](https://github.com/rokups), Ben Carter [@ShironekoBen](https://github.com/ShironekoBen).
|
||||||
A large portion of work on automation systems, regression tests and other features are currently unpublished.
|
A large portion of work on automation systems, regression tests and other features are currently unpublished.
|
||||||
|
|
||||||
"I first discovered the IMGUI paradigm at [Q-Games](http://www.q-games.com) where Atman Binstock had dropped his own simple implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating and improving it."
|
Omar: "I first discovered the IMGUI paradigm at [Q-Games](http://www.q-games.com) where Atman Binstock had dropped his own simple implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating and improving it."
|
||||||
|
|
||||||
Embeds [ProggyClean.ttf](http://upperbounds.net) font by Tristan Grimmer (MIT license).
|
Embeds [ProggyClean.ttf](http://upperbounds.net) font by Tristan Grimmer (MIT license).
|
||||||
|
|
||||||
Embeds [stb_textedit.h, stb_truetype.h, stb_rect_pack.h](https://github.com/nothings/stb/) by Sean Barrett (public domain).
|
Embeds [stb_textedit.h, stb_truetype.h, stb_rect_pack.h](https://github.com/nothings/stb/) by Sean Barrett (public domain).
|
||||||
|
|
||||||
Inspiration, feedback, and testing for early versions: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. And everybody posting feedback, questions and patches on the GitHub.
|
Inspiration, feedback, and testing for early versions: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. Also thank you to everyone posting feedback, questions and patches on GitHub.
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
@ -27,6 +27,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- window: investigate better auto-positioning for new windows.
|
- window: investigate better auto-positioning for new windows.
|
||||||
- window: top most window flag? (#2574)
|
- window: top most window flag? (#2574)
|
||||||
- window/size: manually triggered auto-fit (double-click on grip) shouldn't resize window down to viewport size?
|
- window/size: manually triggered auto-fit (double-click on grip) shouldn't resize window down to viewport size?
|
||||||
|
- window/size: how to allow to e.g. auto-size vertically to fit contents, but be horizontally resizable? Assuming SetNextWindowSize() is modified to treat -1.0f on each axis as "keep as-is" (would be good but might break erroneous code): Problem is UpdateWindowManualResize() and lots of code treat (window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0) together.
|
||||||
- window/opt: freeze window flag: if not focused/hovered, return false, render with previous ImDrawList. and/or reduce refresh rate. -> this may require enforcing that it is illegal to submit contents if Begin returns false.
|
- window/opt: freeze window flag: if not focused/hovered, return false, render with previous ImDrawList. and/or reduce refresh rate. -> this may require enforcing that it is illegal to submit contents if Begin returns false.
|
||||||
- window/child: background options for child windows, border option (disable rounding).
|
- window/child: background options for child windows, border option (disable rounding).
|
||||||
- window/child: allow resizing of child windows (possibly given min/max for each axis?.)
|
- window/child: allow resizing of child windows (possibly given min/max for each axis?.)
|
||||||
@ -35,6 +36,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- window/child: allow SetNextWindowContentSize() to work on child windows.
|
- window/child: allow SetNextWindowContentSize() to work on child windows.
|
||||||
- window/clipping: some form of clipping when DisplaySize (or corresponding viewport) is zero.
|
- window/clipping: some form of clipping when DisplaySize (or corresponding viewport) is zero.
|
||||||
- window/tabbing: add a way to signify that a window or docked window requires attention (e.g. blinking title bar).
|
- window/tabbing: add a way to signify that a window or docked window requires attention (e.g. blinking title bar).
|
||||||
|
- window/id_stack: add e.g. window->GetIDFromPath() with support for leading / and ../ (#1390, #331)
|
||||||
! scrolling: exposing horizontal scrolling with Shift+Wheel even when scrollbar is disabled expose lots of issues (#2424, #1463)
|
! scrolling: exposing horizontal scrolling with Shift+Wheel even when scrollbar is disabled expose lots of issues (#2424, #1463)
|
||||||
- scrolling: while holding down a scrollbar, try to keep the same contents visible (at least while not moving mouse)
|
- scrolling: while holding down a scrollbar, try to keep the same contents visible (at least while not moving mouse)
|
||||||
- scrolling: allow immediately effective change of scroll after Begin() if we haven't appended items yet.
|
- scrolling: allow immediately effective change of scroll after Begin() if we haven't appended items yet.
|
||||||
@ -54,6 +56,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- drawlist: callback: add an extra void* in ImDrawCallback to allow passing render-local data to the callback (would break API).
|
- drawlist: callback: add an extra void* in ImDrawCallback to allow passing render-local data to the callback (would break API).
|
||||||
- drawlist: AddRect vs AddLine position confusing (#2441)
|
- drawlist: AddRect vs AddLine position confusing (#2441)
|
||||||
- drawlist: channel splitter should be external helper and not stored in ImDrawList.
|
- drawlist: channel splitter should be external helper and not stored in ImDrawList.
|
||||||
|
- drawlist: Add quadratic bezier curves? (#3127)
|
||||||
- drawlist/opt: store rounded corners in texture to use 1 quad per corner (filled and wireframe) to lower the cost of rounding. (#1962)
|
- drawlist/opt: store rounded corners in texture to use 1 quad per corner (filled and wireframe) to lower the cost of rounding. (#1962)
|
||||||
- drawlist/opt: AddRect() axis aligned pixel aligned (no-aa) could use 8 triangles instead of 16 and no normal calculation.
|
- drawlist/opt: AddRect() axis aligned pixel aligned (no-aa) could use 8 triangles instead of 16 and no normal calculation.
|
||||||
- drawlist/opt: thick AA line could be doable in same number of triangles as 1.0 AA line by storing gradient+full color in atlas.
|
- drawlist/opt: thick AA line could be doable in same number of triangles as 1.0 AA line by storing gradient+full color in atlas.
|
||||||
@ -78,6 +81,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- selectable: a way to visualize partial/mixed selection (e.g. parent tree node has children with mixed selection)
|
- selectable: a way to visualize partial/mixed selection (e.g. parent tree node has children with mixed selection)
|
||||||
|
|
||||||
- input text: clean up the mess caused by converting UTF-8 <> wchar. the code is rather inefficient right now and super fragile.
|
- input text: clean up the mess caused by converting UTF-8 <> wchar. the code is rather inefficient right now and super fragile.
|
||||||
|
- input text: preserve scrolling when unfocused?
|
||||||
- input text: reorganize event handling, allow CharFilter to modify buffers, allow multiple events? (#541)
|
- input text: reorganize event handling, allow CharFilter to modify buffers, allow multiple events? (#541)
|
||||||
- input text: expose CursorPos in char filter event (#816)
|
- input text: expose CursorPos in char filter event (#816)
|
||||||
- input text: try usage idiom of using InputText with data only exposed through get/set accessors, without extraneous copy/alloc. (#3009)
|
- input text: try usage idiom of using InputText with data only exposed through get/set accessors, without extraneous copy/alloc. (#3009)
|
||||||
@ -134,7 +138,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- columns: allow a same columns set to be interrupted by e.g. CollapsingHeader and resume with columns in sync when moving them.
|
- columns: allow a same columns set to be interrupted by e.g. CollapsingHeader and resume with columns in sync when moving them.
|
||||||
- columns: sizing is lossy when columns width is very small (default width may turn negative etc.)
|
- columns: sizing is lossy when columns width is very small (default width may turn negative etc.)
|
||||||
- columns: separator function or parameter that works within the column (currently Separator() bypass all columns) (#125)
|
- columns: separator function or parameter that works within the column (currently Separator() bypass all columns) (#125)
|
||||||
- columns: flag to add horizontal separator above/below?
|
- columns: flag to add horizontal separator above/below)
|
||||||
- columns/layout: setup minimum line height (equivalent of automatically calling AlignFirstTextHeightToWidgets)
|
- columns/layout: setup minimum line height (equivalent of automatically calling AlignFirstTextHeightToWidgets)
|
||||||
|
|
||||||
!- color: the color conversion helpers/types are a mess and needs sorting out.
|
!- color: the color conversion helpers/types are a mess and needs sorting out.
|
||||||
@ -155,12 +159,16 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- clipper: horizontal clipping support. (#2580)
|
- clipper: horizontal clipping support. (#2580)
|
||||||
|
|
||||||
- separator: expose flags (#759)
|
- separator: expose flags (#759)
|
||||||
|
- separator: take indent into consideration (optional)
|
||||||
- separator: width, thickness, centering (#1643)
|
- separator: width, thickness, centering (#1643)
|
||||||
- splitter: formalize the splitter idiom into an official api (we want to handle n-way split) (#319)
|
- splitter: formalize the splitter idiom into an official api (we want to handle n-way split) (#319)
|
||||||
|
|
||||||
- dock: merge docking branch (#2109)
|
- dock: merge docking branch (#2109)
|
||||||
- dock: dock out from a collapsing header? would work nicely but need emitting window to keep submitting the code.
|
- dock: dock out from a collapsing header? would work nicely but need emitting window to keep submitting the code.
|
||||||
|
|
||||||
|
- tabs: "there is currently a problem because TabItem() will try to submit their own tooltip after 0.50 second, and this will have the effect of making your tooltip flicker once." -> tooltip priority work
|
||||||
|
- tabs: close button tends to overlap unsaved-document star
|
||||||
|
- tabs: consider showing the star at the same spot as the close button, like VS Code does.
|
||||||
- tabs: make EndTabBar fail if users doesn't respect BeginTabBar return value, for consistency/future-proofing.
|
- tabs: make EndTabBar fail if users doesn't respect BeginTabBar return value, for consistency/future-proofing.
|
||||||
- tabs: persistent order/focus in BeginTabBar() api (#261, #351)
|
- tabs: persistent order/focus in BeginTabBar() api (#261, #351)
|
||||||
- tabs: TabItem could honor SetNextItemWidth()?
|
- tabs: TabItem could honor SetNextItemWidth()?
|
||||||
@ -178,9 +186,9 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- slider: tint background based on value (e.g. v_min -> v_max, or use 0.0f either side of the sign)
|
- slider: tint background based on value (e.g. v_min -> v_max, or use 0.0f either side of the sign)
|
||||||
- slider: relative dragging? + precision dragging
|
- slider: relative dragging? + precision dragging
|
||||||
- slider: step option (#1183)
|
- slider: step option (#1183)
|
||||||
- slider style: fill % of the bar instead of positioning a drag.
|
- slider: style: fill % of the bar instead of positioning a drag.
|
||||||
- knob: rotating knob widget (#942)
|
- knob: rotating knob widget (#942)
|
||||||
- drag float: power/logarithmic slider and drags are weird. (#1316)
|
- drag float: support for reversed drags (min > max) (removed is_locked, also see fdc526e)
|
||||||
- drag float: up/down axis
|
- drag float: up/down axis
|
||||||
- drag float: power != 0.0f with current value being outside the range keeps the value stuck.
|
- drag float: power != 0.0f with current value being outside the range keeps the value stuck.
|
||||||
- drag float: added leeway on edge (e.g. a few invisible steps past the clamp limits)
|
- drag float: added leeway on edge (e.g. a few invisible steps past the clamp limits)
|
||||||
@ -207,10 +215,10 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- popups: clicking outside (to close popup) and holding shouldn't drag window below.
|
- popups: clicking outside (to close popup) and holding shouldn't drag window below.
|
||||||
- popups: add variant using global identifier similar to Begin/End (#402)
|
- popups: add variant using global identifier similar to Begin/End (#402)
|
||||||
- popups: border options. richer api like BeginChild() perhaps? (#197)
|
- popups: border options. richer api like BeginChild() perhaps? (#197)
|
||||||
|
- popups: flags could be reworked to allow both mouse buttons as index (0..5 and as flags using higher-bit) allowing to or them.
|
||||||
- popups/modals: although it is sometimes convenient that popups/modals lifetime is owned by imgui, we could also a bool-owned-by-user api as long as Begin() return value testing is enforced.
|
- popups/modals: although it is sometimes convenient that popups/modals lifetime is owned by imgui, we could also a bool-owned-by-user api as long as Begin() return value testing is enforced.
|
||||||
|
|
||||||
- tooltip: drag and drop with tooltip near monitor edges lose/changes its last direction instead of locking one. The drag and drop tooltip should always follow without changing direction.
|
- tooltip: drag and drop with tooltip near monitor edges lose/changes its last direction instead of locking one. The drag and drop tooltip should always follow without changing direction.
|
||||||
- tooltip: tooltip that doesn't fit in entire screen seems to lose their "last preferred direction" and may teleport when moving mouse.
|
|
||||||
- tooltip: allow to set the width of a tooltip to allow TextWrapped() etc. while keeping the height automatic.
|
- tooltip: allow to set the width of a tooltip to allow TextWrapped() etc. while keeping the height automatic.
|
||||||
- tooltip: tooltips with delay timers? or general timer policy? (instantaneous vs timed): IsItemHovered() with timer + implicit aabb-id for items with no ID. (#1485)
|
- tooltip: tooltips with delay timers? or general timer policy? (instantaneous vs timed): IsItemHovered() with timer + implicit aabb-id for items with no ID. (#1485)
|
||||||
- tooltip: drag tooltip hovering over source widget with IsItemHovered/SetTooltip flickers.
|
- tooltip: drag tooltip hovering over source widget with IsItemHovered/SetTooltip flickers.
|
||||||
@ -230,13 +238,15 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- tree node / selectable render mismatch which is visible if you use them both next to each other (e.g. cf. property viewer)
|
- tree node / selectable render mismatch which is visible if you use them both next to each other (e.g. cf. property viewer)
|
||||||
- tree node: tweak color scheme to distinguish headers from selected tree node (#581)
|
- tree node: tweak color scheme to distinguish headers from selected tree node (#581)
|
||||||
- tree node: leaf/non-leaf highlight mismatch.
|
- tree node: leaf/non-leaf highlight mismatch.
|
||||||
- tree node/opt: could avoid formatting when clipped (flag assuming we don't care about width/height, assume single line height?)
|
- tree node: flag to disable formatting and/or detect "%s"
|
||||||
|
- tree node/opt: could avoid formatting when clipped (flag assuming we don't care about width/height, assume single line height? format only %s/%c to be able to count height?)
|
||||||
|
|
||||||
- settings: write more decent code to allow saving/loading new fields: columns, selected tree nodes?
|
- settings: write more decent code to allow saving/loading new fields: columns, selected tree nodes?
|
||||||
- settings: api for per-tool simple persistent data (bool,int,float,columns sizes,etc.) in .ini file (#437)
|
- settings: api for per-tool simple persistent data (bool,int,float,columns sizes,etc.) in .ini file (#437)
|
||||||
- settings/persistence: helpers to make TreeNodeBehavior persist (even during dev!) - may need to store some semantic and/or data type in ImGuiStoragePair
|
- settings/persistence: helpers to make TreeNodeBehavior persist (even during dev!) - may need to store some semantic and/or data type in ImGuiStoragePair
|
||||||
|
|
||||||
- style: better default styles. (#707)
|
- style: better default styles. (#707)
|
||||||
|
- style: PushStyleVar: allow direct access to individual float X/Y elements.
|
||||||
- style: add a highlighted text color (for headers, etc.)
|
- style: add a highlighted text color (for headers, etc.)
|
||||||
- style: border types: out-screen, in-screen, etc. (#447)
|
- style: border types: out-screen, in-screen, etc. (#447)
|
||||||
- style: add window shadow (fading away from the window. Paint-style calculation of vertices alpha after drawlist would be easier)
|
- style: add window shadow (fading away from the window. Paint-style calculation of vertices alpha after drawlist would be easier)
|
||||||
@ -283,6 +293,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- text: it's currently impossible to have a window title with "##". perhaps an official workaround would be nice. \ style inhibitor? non-visible ascii code to insert between #?
|
- text: it's currently impossible to have a window title with "##". perhaps an official workaround would be nice. \ style inhibitor? non-visible ascii code to insert between #?
|
||||||
- text: provided a framed text helper, e.g. https://pastebin.com/1Laxy8bT
|
- text: provided a framed text helper, e.g. https://pastebin.com/1Laxy8bT
|
||||||
- text: refactor TextUnformatted (or underlying function) to more explicitly request if we need width measurement or not
|
- text: refactor TextUnformatted (or underlying function) to more explicitly request if we need width measurement or not
|
||||||
|
- text/layout/tabs: \t pulling position from base pos + step, or offset array (e.g. could be used in text edit, menus for simple icon+text alignment, etc.)
|
||||||
- text link/url button: underlined. should api expose an ID or use text contents as ID? which colors enum to use?
|
- text link/url button: underlined. should api expose an ID or use text contents as ID? which colors enum to use?
|
||||||
- text/wrapped: should be a more first-class citizen, e.g. wrapped text within a Selectable with known width.
|
- text/wrapped: should be a more first-class citizen, e.g. wrapped text within a Selectable with known width.
|
||||||
- text/wrapped: custom separator for text wrapping. (#3002)
|
- text/wrapped: custom separator for text wrapping. (#3002)
|
||||||
@ -308,7 +319,8 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- font/atlas: dynamic font atlas to avoid baking huge ranges into bitmap and make scaling easier.
|
- font/atlas: dynamic font atlas to avoid baking huge ranges into bitmap and make scaling easier.
|
||||||
- font/draw: vertical and/or rotated text renderer (#705) - vertical is easier clipping wise
|
- font/draw: vertical and/or rotated text renderer (#705) - vertical is easier clipping wise
|
||||||
- font/draw: need to be able to specify wrap start position.
|
- font/draw: need to be able to specify wrap start position.
|
||||||
- font/draw: better reserve policy for large horizontal block of text (shouldn't reserve for all clipped lines)
|
- font/draw: better reserve policy for large horizontal block of text (shouldn't reserve for all clipped lines). also see #3349.
|
||||||
|
- font/draw: fix for drawing 16k+ visible characters in same call.
|
||||||
- font/draw: underline, squiggle line rendering helpers.
|
- font/draw: underline, squiggle line rendering helpers.
|
||||||
- font: optimization: for monospace font (like the default one) we can trim IndexXAdvance as long as trailing value is == FallbackXAdvance (need to make sure TAB is still correct), would save on cache line.
|
- font: optimization: for monospace font (like the default one) we can trim IndexXAdvance as long as trailing value is == FallbackXAdvance (need to make sure TAB is still correct), would save on cache line.
|
||||||
- font: add support for kerning, probably optional. A) perhaps default to (32..128)^2 matrix ~ 9K entries = 36KB, then hash for non-ascii?. B) or sparse lookup into per-char list?
|
- font: add support for kerning, probably optional. A) perhaps default to (32..128)^2 matrix ~ 9K entries = 36KB, then hash for non-ascii?. B) or sparse lookup into per-char list?
|
||||||
@ -320,20 +332,24 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- font/opt: Glyph currently 40 bytes (2+9*4). Consider storing UV as 16 bits integer? (->32 bytes). X0/Y0/X1/Y1 as 16 fixed-point integers? Or X0/Y0 as float and X1/Y1 as fixed8_8?
|
- font/opt: Glyph currently 40 bytes (2+9*4). Consider storing UV as 16 bits integer? (->32 bytes). X0/Y0/X1/Y1 as 16 fixed-point integers? Or X0/Y0 as float and X1/Y1 as fixed8_8?
|
||||||
|
|
||||||
- nav: some features such as PageUp/Down/Home/End should probably work without ImGuiConfigFlags_NavEnableKeyboard? (where do we draw the line?)
|
- nav: some features such as PageUp/Down/Home/End should probably work without ImGuiConfigFlags_NavEnableKeyboard? (where do we draw the line?)
|
||||||
! nav: never clear NavId on some setup (e.g. gamepad centric)
|
|
||||||
- nav: code to focus child-window on restoring NavId appears to have issue: e.g. when focus change is implicit because of window closure.
|
|
||||||
- nav: configuration flag to disable global shortcuts (currently only CTRL-Tab) ?
|
- nav: configuration flag to disable global shortcuts (currently only CTRL-Tab) ?
|
||||||
|
! nav: never clear NavId on some setup (e.g. gamepad centric)
|
||||||
|
- nav: there's currently no way to completely clear focus with the keyboard. depending on patterns used by the application to dispatch inputs, it may be desirable.
|
||||||
|
- nav: code to focus child-window on restoring NavId appears to have issue: e.g. when focus change is implicit because of window closure.
|
||||||
- nav: Home/End behavior when navigable item is not fully visible at the edge of scrolling? should be backtrack to keep item into view?
|
- nav: Home/End behavior when navigable item is not fully visible at the edge of scrolling? should be backtrack to keep item into view?
|
||||||
- nav: NavScrollToBringItemIntoView() with item bigger than view should focus top-right? Repro: using Nav in "About Window"
|
- nav: NavScrollToBringItemIntoView() with item bigger than view should focus top-right? Repro: using Nav in "About Window"
|
||||||
- nav: wrap around logic to allow e.g. grid based layout (pressing NavRight on the right-most element would go to the next row, etc.). see internal's NavMoveRequestTryWrapping().
|
- nav: wrap around logic to allow e.g. grid based layout (pressing NavRight on the right-most element would go to the next row, etc.). see internal's NavMoveRequestTryWrapping().
|
||||||
- nav: patterns to make it possible for arrows key to update selection
|
- nav: patterns to make it possible for arrows key to update selection (see JustMovedTo in range_select branch)
|
||||||
- nav: restore/find nearest NavId when current one disappear (e.g. pressed a button that disappear, or perhaps auto restoring when current button change name)
|
- nav: restore/find nearest NavId when current one disappear (e.g. pressed a button that disappear, or perhaps auto restoring when current button change name)
|
||||||
- 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: NavFlattened: ESC on a flattened child should select something.
|
- nav: NavFlattened: ESC on a flattened child should select something.
|
||||||
- nav: NavFlattened: broken: in typical usage scenario, the items of a fully clipped child are currently not considered to enter into a NavFlattened child.
|
- nav: NavFlattened: broken: in typical usage scenario, the items of a fully clipped child are currently not considered to enter into a NavFlattened child.
|
||||||
- nav: NavFlattened: init request doesn't select items that are part of a NavFlattened child
|
- nav: NavFlattened: init request doesn't select items that are part of a NavFlattened child
|
||||||
- nav: NavFlattened: cannot access menu-bar of a flattened child window with Alt/menu key (not a very common use case..).
|
- nav: NavFlattened: cannot access menu-bar of a flattened child window with Alt/menu key (not a very common use case..).
|
||||||
- nav/treenode: Left within a tree node block as a fallback (ImGuiTreeNodeFlags_NavLeftJumpsBackHere by default?)
|
- nav: simulate right-click or context activation? (SHIFT+F10)
|
||||||
|
- nav/tabbing: refactor old tabbing system and turn into navigation, should pass through all widgets (in submission order?).
|
||||||
|
- nav/popup: esc/enter default behavior for popups, e.g. be able to mark an "ok" or "cancel" button that would get triggered by those keys, default validation button, etc.
|
||||||
|
- nav/treenode: 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.
|
||||||
- nav/menus: allow pressing Menu to leave a sub-menu.
|
- nav/menus: allow pressing Menu to leave a sub-menu.
|
||||||
- nav/menus: a way to access the main menu bar with Alt? (currently needs CTRL+TAB) or last focused window menu bar?
|
- nav/menus: a way to access the main menu bar with Alt? (currently needs CTRL+TAB) or last focused window menu bar?
|
||||||
@ -342,11 +358,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- nav/menus: Alt,Up could open the first menu (e.g. "File") currently it tends to nav into the window/collapse menu. Do do that we would need custom transition?
|
- nav/menus: Alt,Up could open the first menu (e.g. "File") currently it tends to nav into the window/collapse menu. Do do that we would need custom transition?
|
||||||
- nav/windowing: configure fade-in/fade-out delay on Ctrl+Tab?
|
- nav/windowing: configure fade-in/fade-out delay on Ctrl+Tab?
|
||||||
- nav/windowing: when CTRL-Tab/windowing is active, the HoveredWindow detection doesn't take account of the window display re-ordering.
|
- nav/windowing: when CTRL-Tab/windowing is active, the HoveredWindow detection doesn't take account of the window display re-ordering.
|
||||||
- nav: simulate right-click or context activation? (SHIFT+F10)
|
- nav/windowing: Resizing window will currently fail with certain types of resizing constraints/callback applied
|
||||||
- nav: tabs should go through most/all widgets (in submission order?).
|
|
||||||
- nav: esc/enter default behavior for popups, e.g. be able to mark an "ok" or "cancel" button that would get triggered by those keys.
|
|
||||||
- nav: when activating a button that changes label (without a static ID) or disappear, can we somehow automatically recover into a nearest highlight item?
|
|
||||||
- nav: there's currently no way to completely clear focus with the keyboard. depending on patterns used by the application to dispatch inputs, it may be desirable.
|
|
||||||
- focus: preserve ActiveId/focus stack state, e.g. when opening a menu and close it, previously selected InputText() focus gets restored (#622)
|
- focus: preserve ActiveId/focus stack state, e.g. when opening a menu and close it, previously selected InputText() focus gets restored (#622)
|
||||||
- focus: SetKeyboardFocusHere() on with >= 0 offset could be done on same frame (else latch and modulate on beginning of next frame)
|
- focus: SetKeyboardFocusHere() on with >= 0 offset could be done on same frame (else latch and modulate on beginning of next frame)
|
||||||
- focus: unable to use SetKeyboardFocusHere() on clipped widgets. (#787)
|
- focus: unable to use SetKeyboardFocusHere() on clipped widgets. (#787)
|
||||||
@ -363,7 +375,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- misc: idle: if cursor blink if the _only_ visible animation, could even expose a dirty rectangle that optionally can be leverage by some app to render in a smaller viewport, getting rid of much pixel shading cost.
|
- misc: idle: if cursor blink if the _only_ visible animation, could even expose a dirty rectangle that optionally can be leverage by some app to render in a smaller viewport, getting rid of much pixel shading cost.
|
||||||
- misc: no way to run a root-most GetID() with ImGui:: api since there's always a Debug window in the stack. (mentioned in #2960)
|
- misc: no way to run a root-most GetID() with ImGui:: api since there's always a Debug window in the stack. (mentioned in #2960)
|
||||||
- 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?)
|
||||||
- misc: provide a way to compile out the entire implementation while providing a dummy API (e.g. #define IMGUI_DUMMY_IMPL)
|
|
||||||
- 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: possible compile-time support for string view/range instead of char* would e.g. facilitate usage with Rust (#683)
|
- misc: possible compile-time support for string view/range instead of char* would e.g. facilitate usage with Rust (#683)
|
||||||
@ -381,6 +392,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- examples: window minimize, maximize (#583)
|
- examples: window minimize, maximize (#583)
|
||||||
- examples: provide a zero frame-rate/idle example.
|
- examples: provide a zero frame-rate/idle example.
|
||||||
- examples: dx11/dx12: try to use new swapchain blit models (#2970)
|
- examples: dx11/dx12: try to use new swapchain blit models (#2970)
|
||||||
|
- backends: move to backends/ folder?
|
||||||
- backends: report it better when not able to create texture?
|
- backends: report it better when not able to create texture?
|
||||||
- backends: apple: example_apple should be using modern GL3.
|
- backends: apple: example_apple should be using modern GL3.
|
||||||
- backends: glfw: could go idle when minimized? if (glfwGetWindowAttrib(window, GLFW_ICONIFIED)) { glfwWaitEvents(); continue; } // issue: DeltaTime will be super high on resume, perhaps provide a way to let impl know (#440)
|
- backends: glfw: could go idle when minimized? if (glfwGetWindowAttrib(window, GLFW_ICONIFIED)) { glfwWaitEvents(); continue; } // issue: DeltaTime will be super high on resume, perhaps provide a way to let impl know (#440)
|
||||||
@ -392,6 +404,8 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- backends: bgfx: https://gist.github.com/RichardGale/6e2b74bc42b3005e08397236e4be0fd0
|
- backends: bgfx: https://gist.github.com/RichardGale/6e2b74bc42b3005e08397236e4be0fd0
|
||||||
- backends: mscriptem: with refactored examples, we could provide a direct imgui_impl_emscripten platform layer (see eg. https://github.com/floooh/sokol-samples/blob/master/html5/imgui-emsc.cc#L42)
|
- backends: mscriptem: with refactored examples, we could provide a direct imgui_impl_emscripten platform layer (see eg. https://github.com/floooh/sokol-samples/blob/master/html5/imgui-emsc.cc#L42)
|
||||||
|
|
||||||
|
- bindings: ways to use clang ast dump to generate bindings or helpers for bindings? (e.g. clang++ -Xclang -ast-dump=json imgui.h)
|
||||||
|
|
||||||
- optimization: replace vsnprintf with stb_printf? using IMGUI_USE_STB_SPRINTF.(#1038)
|
- optimization: replace vsnprintf with stb_printf? using IMGUI_USE_STB_SPRINTF.(#1038)
|
||||||
- optimization: add clipping for multi-component widgets (SliderFloatX, ColorEditX, etc.). one problem is that nav branch can't easily clip parent group when there is a move request.
|
- optimization: add clipping for multi-component widgets (SliderFloatX, ColorEditX, etc.). one problem is that nav branch can't easily clip parent group when there is a move request.
|
||||||
- optimization: add a flag to disable most of rendering, for the case where the user expect to skip it (#335)
|
- optimization: add a flag to disable most of rendering, for the case where the user expect to skip it (#335)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
dear imgui, v1.77
|
dear imgui, v1.79
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
examples/README.txt
|
examples/README.txt
|
||||||
(This is the README file for the examples/ folder. See docs/ for more documentation)
|
(This is the README file for the examples/ folder. See docs/ for more documentation)
|
||||||
@ -204,7 +204,7 @@ example_glfw_opengl2/
|
|||||||
GLFW + OpenGL2 example (legacy, fixed pipeline).
|
GLFW + OpenGL2 example (legacy, fixed pipeline).
|
||||||
= main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp
|
= main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp
|
||||||
**DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
**DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
**Prefer using OPENGL3 code (with gl3w/glew/glad/glbinding, you can replace the OpenGL function loader)**
|
**Prefer using OPENGL3 code (with gl3w/glew/glad/glad2/glbinding, you can replace the OpenGL function loader)**
|
||||||
This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter.
|
This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter.
|
||||||
If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to
|
If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to
|
||||||
make things more complicated, will require your code to reset many OpenGL attributes to their initial
|
make things more complicated, will require your code to reset many OpenGL attributes to their initial
|
||||||
@ -253,7 +253,7 @@ example_sdl_opengl2/
|
|||||||
SDL2 (Win32, Mac, Linux etc.) + OpenGL example (legacy, fixed pipeline).
|
SDL2 (Win32, Mac, Linux etc.) + OpenGL example (legacy, fixed pipeline).
|
||||||
= main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl2.cpp
|
= main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl2.cpp
|
||||||
**DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
**DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
**Prefer using OPENGL3 code (with gl3w/glew/glad/glbinding, you can replace the OpenGL function loader)**
|
**Prefer using OPENGL3 code (with gl3w/glew/glad/glad2/glbinding, you can replace the OpenGL function loader)**
|
||||||
This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter.
|
This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter.
|
||||||
If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to
|
If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to
|
||||||
make things more complicated, will require your code to reset many OpenGL attributes to their initial
|
make things more complicated, will require your code to reset many OpenGL attributes to their initial
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{2AE17FDE-F7F3-4CAC-ADAB-0710EDA4F741}</ProjectGuid>
|
<ProjectGuid>{73F235B5-7D31-4FC6-8682-DDC5A097B9C1}</ProjectGuid>
|
||||||
<RootNamespace>example_allegro5</RootNamespace>
|
<RootNamespace>example_allegro5</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -4,5 +4,7 @@
|
|||||||
|
|
||||||
This example shows how to integrate Dear ImGui with Metal. It is based on the "cross-platform" game template provided with Xcode as of Xcode 9.
|
This example shows how to integrate Dear ImGui with Metal. It is based on the "cross-platform" game template provided with Xcode as of Xcode 9.
|
||||||
|
|
||||||
(NB: you may still want to use GLFW or SDL which will also support Windows, Linux along with OSX.)
|
Consider basing your work off the example_glfw_metal/ or example_sdl_metal/ examples. They are better supported and will be portable unlike this one.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
@implementation Renderer
|
@implementation Renderer
|
||||||
|
|
||||||
-(nonnull instancetype)initWithView:(nonnull MTKView *)view;
|
-(nonnull instancetype)initWithView:(nonnull MTKView*)view;
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if(self)
|
if(self)
|
||||||
@ -23,17 +23,41 @@
|
|||||||
_device = view.device;
|
_device = view.device;
|
||||||
_commandQueue = [_device newCommandQueue];
|
_commandQueue = [_device newCommandQueue];
|
||||||
|
|
||||||
|
// Setup Dear ImGui context
|
||||||
|
// FIXME: This example doesn't have proper cleanup...
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGui::StyleColorsDark();
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
|
||||||
|
// Setup Dear ImGui style
|
||||||
|
ImGui::StyleColorsDark();
|
||||||
|
//ImGui::StyleColorsClassic();
|
||||||
|
|
||||||
|
// Setup Renderer bindings
|
||||||
ImGui_ImplMetal_Init(_device);
|
ImGui_ImplMetal_Init(_device);
|
||||||
|
|
||||||
|
// Load Fonts
|
||||||
|
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
|
//io.Fonts->AddFontDefault();
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
|
||||||
|
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
||||||
|
//IM_ASSERT(font != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawInMTKView:(MTKView *)view
|
- (void)drawInMTKView:(MTKView*)view
|
||||||
{
|
{
|
||||||
ImGuiIO &io = ImGui::GetIO();
|
ImGuiIO &io = ImGui::GetIO();
|
||||||
io.DisplaySize.x = view.bounds.size.width;
|
io.DisplaySize.x = view.bounds.size.width;
|
||||||
@ -50,11 +74,12 @@
|
|||||||
|
|
||||||
id<MTLCommandBuffer> commandBuffer = [self.commandQueue commandBuffer];
|
id<MTLCommandBuffer> commandBuffer = [self.commandQueue commandBuffer];
|
||||||
|
|
||||||
|
// Our state (make them static = more or less global) as a convenience to keep the example terse.
|
||||||
static bool show_demo_window = true;
|
static bool show_demo_window = true;
|
||||||
static bool show_another_window = false;
|
static bool show_another_window = false;
|
||||||
static float clear_color[4] = { 0.28f, 0.36f, 0.5f, 1.0f };
|
static float clear_color[4] = { 0.28f, 0.36f, 0.5f, 1.0f };
|
||||||
|
|
||||||
MTLRenderPassDescriptor *renderPassDescriptor = view.currentRenderPassDescriptor;
|
MTLRenderPassDescriptor* renderPassDescriptor = view.currentRenderPassDescriptor;
|
||||||
if (renderPassDescriptor != nil)
|
if (renderPassDescriptor != nil)
|
||||||
{
|
{
|
||||||
renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color[0], clear_color[1], clear_color[2], clear_color[3]);
|
renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color[0], clear_color[1], clear_color[2], clear_color[3]);
|
||||||
@ -110,7 +135,7 @@
|
|||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImDrawData *drawData = ImGui::GetDrawData();
|
ImDrawData* drawData = ImGui::GetDrawData();
|
||||||
ImGui_ImplMetal_RenderDrawData(drawData, commandBuffer, renderEncoder);
|
ImGui_ImplMetal_RenderDrawData(drawData, commandBuffer, renderEncoder);
|
||||||
|
|
||||||
[renderEncoder popDebugGroup];
|
[renderEncoder popDebugGroup];
|
||||||
@ -122,7 +147,7 @@
|
|||||||
[commandBuffer commit];
|
[commandBuffer commit];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size
|
- (void)mtkView:(MTKView*)view drawableSizeWillChange:(CGSize)size
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
ImGui_ImplOSX_NewFrame(self);
|
ImGui_ImplOSX_NewFrame(self);
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
// Global data for the demo
|
// Our state (make them static = more or less global) as a convenience to keep the example terse.
|
||||||
static bool show_demo_window = true;
|
static bool show_demo_window = true;
|
||||||
static bool show_another_window = false;
|
static bool show_another_window = false;
|
||||||
static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
@ -243,10 +243,12 @@
|
|||||||
NSLog(@"No OpenGL Context!");
|
NSLog(@"No OpenGL Context!");
|
||||||
|
|
||||||
// Setup Dear ImGui context
|
// Setup Dear ImGui context
|
||||||
|
// FIXME: This example doesn't have proper cleanup...
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
|
|
||||||
# How to Build
|
## How to Build
|
||||||
|
|
||||||
- You need to install Emscripten from https://emscripten.org/docs/getting_started/downloads.html, and have the environment variables set, as described in https://emscripten.org/docs/getting_started/downloads.html#installation-instructions
|
- You need to install Emscripten from https://emscripten.org/docs/getting_started/downloads.html, and have the environment variables set, as described in https://emscripten.org/docs/getting_started/downloads.html#installation-instructions
|
||||||
|
- You may also refer to our [Continuous Integration setup](https://github.com/ocornut/imgui/tree/master/.github/workflows) for Emscripten setup.
|
||||||
- Depending on your configuration, in Windows you may need to run `emsdk/emsdk_env.bat` in your console to access the Emscripten command-line tools.
|
- Depending on your configuration, in Windows you may need to run `emsdk/emsdk_env.bat` in your console to access the Emscripten command-line tools.
|
||||||
|
|
||||||
- Then build using `make` while in the `example_emscripten/` directory.
|
- Then build using `make` while in the `example_emscripten/` directory.
|
||||||
|
|
||||||
- Note that Emscripten 1.39.0 (October 2019) obsoleted the `BINARYEN_TRAP_MODE=clamp` compilation flag which was required with version older than 1.39.0 to avoid rendering artefacts. See [#2877](https://github.com/ocornut/imgui/issues/2877) for details. If you use an older version, uncomment this line in the Makefile:
|
## How to Run
|
||||||
|
|
||||||
`#EMS += -s BINARYEN_TRAP_MODE=clamp`
|
To run on a local machine:
|
||||||
|
- Generally you may need a local webserver. Quoting [https://emscripten.org/docs/getting_started](https://emscripten.org/docs/getting_started/Tutorial.html#generating-html):<br>
|
||||||
|
_"Unfortunately several browsers (including Chrome, Safari, and Internet Explorer) do not support file:// [XHR](https://emscripten.org/docs/site/glossary.html#term-xhr) requests, and can’t load extra files needed by the HTML (like a .wasm file, or packaged file data as mentioned lower down). For these browsers you’ll need to serve the files using a [local webserver](https://emscripten.org/docs/getting_started/FAQ.html#faq-local-webserver) and then open http://localhost:8000/hello.html."_
|
||||||
|
- Emscripten SDK has a handy `emrun` command: `emrun example_emscripten.html` which will spawn a temporary local webserver. See https://emscripten.org/docs/compiling/Running-html-files-with-emrun.html for details.
|
||||||
|
- Otherwise you may use Python builtin webserver: `python -m http.server` in Python 3 or `python -m SimpleHTTPServer` in Python 2. After doing that, you can visit http://localhost:8000/.
|
||||||
|
|
||||||
|
## Obsolete features:
|
||||||
|
|
||||||
|
- Emscripten 2.0 (August 2020) obsoleted the fastcomp back-end, only llvm is supported.
|
||||||
|
- Emscripten 1.39.0 (October 2019) obsoleted the `BINARYEN_TRAP_MODE=clamp` compilation flag which was required with version older than 1.39.0 to avoid rendering artefacts. See [#2877](https://github.com/ocornut/imgui/issues/2877) for details. If you use an older version, uncomment this line in the Makefile: `#EMS += -s BINARYEN_TRAP_MODE=clamp`
|
||||||
|
@ -42,6 +42,10 @@ CXXFLAGS += -I../libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W
|
|||||||
# SOURCES += ../libs/glad/src/glad.c
|
# SOURCES += ../libs/glad/src/glad.c
|
||||||
# CXXFLAGS += -I../libs/glad/include -DIMGUI_IMPL_OPENGL_LOADER_GLAD
|
# CXXFLAGS += -I../libs/glad/include -DIMGUI_IMPL_OPENGL_LOADER_GLAD
|
||||||
|
|
||||||
|
## Using OpenGL loader: glad2
|
||||||
|
# SOURCES += ../libs/glad/src/gl.c
|
||||||
|
# CXXFLAGS += -I../libs/glad/include -DIMGUI_IMPL_OPENGL_LOADER_GLAD2
|
||||||
|
|
||||||
## Using OpenGL loader: glbinding
|
## Using OpenGL loader: glbinding
|
||||||
## This assumes a system-wide installation
|
## This assumes a system-wide installation
|
||||||
## of either version 3.0.0 (or newer)
|
## of either version 3.0.0 (or newer)
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#include <GL/glew.h> // Initialize with glewInit()
|
#include <GL/glew.h> // Initialize with glewInit()
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||||
#include <glad/glad.h> // Initialize with gladLoadGL()
|
#include <glad/glad.h> // Initialize with gladLoadGL()
|
||||||
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD2)
|
||||||
|
#include <glad/gl.h> // Initialize with gladLoadGL(...) or gladLoaderLoadGL()
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
||||||
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
||||||
#include <glbinding/Binding.h> // Initialize with glbinding::Binding::initialize()
|
#include <glbinding/Binding.h> // Initialize with glbinding::Binding::initialize()
|
||||||
@ -54,7 +56,7 @@ int main(int, char**)
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
// Decide GL+GLSL versions
|
// Decide GL+GLSL versions
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
// GL 3.2 + GLSL 150
|
// GL 3.2 + GLSL 150
|
||||||
const char* glsl_version = "#version 150";
|
const char* glsl_version = "#version 150";
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
@ -84,6 +86,8 @@ int main(int, char**)
|
|||||||
bool err = glewInit() != GLEW_OK;
|
bool err = glewInit() != GLEW_OK;
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||||
bool err = gladLoadGL() == 0;
|
bool err = gladLoadGL() == 0;
|
||||||
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD2)
|
||||||
|
bool err = gladLoadGL(glfwGetProcAddress) == 0; // glad2 recommend using the windowing library loader instead of the (optionally) bundled one.
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
||||||
bool err = false;
|
bool err = false;
|
||||||
glbinding::Binding::initialize();
|
glbinding::Binding::initialize();
|
||||||
|
@ -28,9 +28,11 @@ set(IMGUI_DIR ../../)
|
|||||||
include_directories(${IMGUI_DIR} ..)
|
include_directories(${IMGUI_DIR} ..)
|
||||||
|
|
||||||
# Libraries
|
# Libraries
|
||||||
find_library(VULKAN_LIBRARY
|
find_package(Vulkan REQUIRED)
|
||||||
NAMES vulkan vulkan-1)
|
#find_library(VULKAN_LIBRARY
|
||||||
set(LIBRARIES "glfw;${VULKAN_LIBRARY}")
|
#NAMES vulkan vulkan-1)
|
||||||
|
#set(LIBRARIES "glfw;${VULKAN_LIBRARY}")
|
||||||
|
set(LIBRARIES "glfw;Vulkan::Vulkan")
|
||||||
|
|
||||||
# Use vulkan headers from glfw:
|
# Use vulkan headers from glfw:
|
||||||
include_directories(${GLFW_DIR}/deps)
|
include_directories(${GLFW_DIR}/deps)
|
||||||
|
@ -43,8 +43,6 @@ static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE;
|
|||||||
static ImGui_ImplVulkanH_Window g_MainWindowData;
|
static ImGui_ImplVulkanH_Window g_MainWindowData;
|
||||||
static int g_MinImageCount = 2;
|
static int g_MinImageCount = 2;
|
||||||
static bool g_SwapChainRebuild = false;
|
static bool g_SwapChainRebuild = false;
|
||||||
static int g_SwapChainResizeWidth = 0;
|
|
||||||
static int g_SwapChainResizeHeight = 0;
|
|
||||||
|
|
||||||
static void check_vk_result(VkResult err)
|
static void check_vk_result(VkResult err)
|
||||||
{
|
{
|
||||||
@ -74,10 +72,9 @@ static void SetupVulkan(const char** extensions, uint32_t extensions_count)
|
|||||||
create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||||
create_info.enabledExtensionCount = extensions_count;
|
create_info.enabledExtensionCount = extensions_count;
|
||||||
create_info.ppEnabledExtensionNames = extensions;
|
create_info.ppEnabledExtensionNames = extensions;
|
||||||
|
|
||||||
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
||||||
// Enabling multiple validation layers grouped as LunarG standard validation
|
// Enabling validation layers
|
||||||
const char* layers[] = { "VK_LAYER_LUNARG_standard_validation" };
|
const char* layers[] = { "VK_LAYER_KHRONOS_validation" };
|
||||||
create_info.enabledLayerCount = 1;
|
create_info.enabledLayerCount = 1;
|
||||||
create_info.ppEnabledLayerNames = layers;
|
create_info.ppEnabledLayerNames = layers;
|
||||||
|
|
||||||
@ -255,6 +252,11 @@ static void FrameRender(ImGui_ImplVulkanH_Window* wd, ImDrawData* draw_data)
|
|||||||
VkSemaphore image_acquired_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].ImageAcquiredSemaphore;
|
VkSemaphore image_acquired_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].ImageAcquiredSemaphore;
|
||||||
VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore;
|
VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore;
|
||||||
err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
|
err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
|
||||||
|
if (err == VK_ERROR_OUT_OF_DATE_KHR)
|
||||||
|
{
|
||||||
|
g_SwapChainRebuild = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
|
|
||||||
ImGui_ImplVulkanH_Frame* fd = &wd->Frames[wd->FrameIndex];
|
ImGui_ImplVulkanH_Frame* fd = &wd->Frames[wd->FrameIndex];
|
||||||
@ -312,6 +314,8 @@ static void FrameRender(ImGui_ImplVulkanH_Window* wd, ImDrawData* draw_data)
|
|||||||
|
|
||||||
static void FramePresent(ImGui_ImplVulkanH_Window* wd)
|
static void FramePresent(ImGui_ImplVulkanH_Window* wd)
|
||||||
{
|
{
|
||||||
|
if (g_SwapChainRebuild)
|
||||||
|
return;
|
||||||
VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore;
|
VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore;
|
||||||
VkPresentInfoKHR info = {};
|
VkPresentInfoKHR info = {};
|
||||||
info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
||||||
@ -321,6 +325,11 @@ static void FramePresent(ImGui_ImplVulkanH_Window* wd)
|
|||||||
info.pSwapchains = &wd->Swapchain;
|
info.pSwapchains = &wd->Swapchain;
|
||||||
info.pImageIndices = &wd->FrameIndex;
|
info.pImageIndices = &wd->FrameIndex;
|
||||||
VkResult err = vkQueuePresentKHR(g_Queue, &info);
|
VkResult err = vkQueuePresentKHR(g_Queue, &info);
|
||||||
|
if (err == VK_ERROR_OUT_OF_DATE_KHR)
|
||||||
|
{
|
||||||
|
g_SwapChainRebuild = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->ImageCount; // Now we can use the next set of semaphores
|
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->ImageCount; // Now we can use the next set of semaphores
|
||||||
}
|
}
|
||||||
@ -330,13 +339,6 @@ static void glfw_error_callback(int error, const char* description)
|
|||||||
fprintf(stderr, "Glfw Error %d: %s\n", error, description);
|
fprintf(stderr, "Glfw Error %d: %s\n", error, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void glfw_resize_callback(GLFWwindow*, int w, int h)
|
|
||||||
{
|
|
||||||
g_SwapChainRebuild = true;
|
|
||||||
g_SwapChainResizeWidth = w;
|
|
||||||
g_SwapChainResizeHeight = h;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
// Setup GLFW window
|
// Setup GLFW window
|
||||||
@ -365,7 +367,6 @@ int main(int, char**)
|
|||||||
// Create Framebuffers
|
// Create Framebuffers
|
||||||
int w, h;
|
int w, h;
|
||||||
glfwGetFramebufferSize(window, &w, &h);
|
glfwGetFramebufferSize(window, &w, &h);
|
||||||
glfwSetFramebufferSizeCallback(window, glfw_resize_callback);
|
|
||||||
ImGui_ImplVulkanH_Window* wd = &g_MainWindowData;
|
ImGui_ImplVulkanH_Window* wd = &g_MainWindowData;
|
||||||
SetupVulkanWindow(wd, surface, w, h);
|
SetupVulkanWindow(wd, surface, w, h);
|
||||||
|
|
||||||
@ -457,12 +458,17 @@ int main(int, char**)
|
|||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
||||||
// Resize swap chain?
|
// Resize swap chain?
|
||||||
if (g_SwapChainRebuild && g_SwapChainResizeWidth > 0 && g_SwapChainResizeHeight > 0)
|
if (g_SwapChainRebuild)
|
||||||
{
|
{
|
||||||
g_SwapChainRebuild = false;
|
int width, height;
|
||||||
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
|
glfwGetFramebufferSize(window, &width, &height);
|
||||||
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, g_SwapChainResizeWidth, g_SwapChainResizeHeight, g_MinImageCount);
|
if (width > 0 && height > 0)
|
||||||
g_MainWindowData.FrameIndex = 0;
|
{
|
||||||
|
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
|
||||||
|
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, width, height, g_MinImageCount);
|
||||||
|
g_MainWindowData.FrameIndex = 0;
|
||||||
|
g_SwapChainRebuild = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the Dear ImGui frame
|
// Start the Dear ImGui frame
|
||||||
@ -513,6 +519,7 @@ int main(int, char**)
|
|||||||
const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f);
|
const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f);
|
||||||
if (!is_minimized)
|
if (!is_minimized)
|
||||||
{
|
{
|
||||||
|
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
||||||
FrameRender(wd, draw_data);
|
FrameRender(wd, draw_data);
|
||||||
FramePresent(wd);
|
FramePresent(wd);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui: null/dummy example application
|
// dear imgui: "null" example application
|
||||||
// (compile and link imgui, create context, run headless with NO INPUTS, NO GRAPHICS OUTPUT)
|
// (compile and link imgui, create context, run headless with NO INPUTS, NO GRAPHICS OUTPUT)
|
||||||
// This is useful to test building, but you cannot interact with anything here!
|
// This is useful to test building, but you cannot interact with anything here!
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
@ -87,6 +87,8 @@ int main(int, char**)
|
|||||||
ImGui_ImplSDL2_ProcessEvent(&event);
|
ImGui_ImplSDL2_ProcessEvent(&event);
|
||||||
if (event.type == SDL_QUIT)
|
if (event.type == SDL_QUIT)
|
||||||
done = true;
|
done = true;
|
||||||
|
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window))
|
||||||
|
done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the Dear ImGui frame
|
// Start the Dear ImGui frame
|
||||||
|
@ -42,6 +42,10 @@ CXXFLAGS += -I../libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W
|
|||||||
# SOURCES += ../libs/glad/src/glad.c
|
# SOURCES += ../libs/glad/src/glad.c
|
||||||
# CXXFLAGS += -I../libs/glad/include -DIMGUI_IMPL_OPENGL_LOADER_GLAD
|
# CXXFLAGS += -I../libs/glad/include -DIMGUI_IMPL_OPENGL_LOADER_GLAD
|
||||||
|
|
||||||
|
## Using OpenGL loader: glad2
|
||||||
|
# SOURCES += ../libs/glad/src/gl.c
|
||||||
|
# CXXFLAGS += -I../libs/glad/include -DIMGUI_IMPL_OPENGL_LOADER_GLAD2
|
||||||
|
|
||||||
## Using OpenGL loader: glbinding
|
## Using OpenGL loader: glbinding
|
||||||
## This assumes a system-wide installation
|
## This assumes a system-wide installation
|
||||||
## of either version 3.0.0 (or newer)
|
## of either version 3.0.0 (or newer)
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include <GL/glew.h> // Initialize with glewInit()
|
#include <GL/glew.h> // Initialize with glewInit()
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||||
#include <glad/glad.h> // Initialize with gladLoadGL()
|
#include <glad/glad.h> // Initialize with gladLoadGL()
|
||||||
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD2)
|
||||||
|
#include <glad/gl.h> // Initialize with gladLoadGL(...) or gladLoaderLoadGL()
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
||||||
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
||||||
#include <glbinding/Binding.h> // Initialize with glbinding::Binding::initialize()
|
#include <glbinding/Binding.h> // Initialize with glbinding::Binding::initialize()
|
||||||
@ -46,7 +48,7 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Decide GL+GLSL versions
|
// Decide GL+GLSL versions
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
// GL 3.2 Core + GLSL 150
|
// GL 3.2 Core + GLSL 150
|
||||||
const char* glsl_version = "#version 150";
|
const char* glsl_version = "#version 150";
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG); // Always required on Mac
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG); // Always required on Mac
|
||||||
@ -79,6 +81,8 @@ int main(int, char**)
|
|||||||
bool err = glewInit() != GLEW_OK;
|
bool err = glewInit() != GLEW_OK;
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||||
bool err = gladLoadGL() == 0;
|
bool err = gladLoadGL() == 0;
|
||||||
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD2)
|
||||||
|
bool err = gladLoadGL((GLADloadfunc)SDL_GL_GetProcAddress) == 0; // glad2 recommend using the windowing library loader instead of the (optionally) bundled one.
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
||||||
bool err = false;
|
bool err = false;
|
||||||
glbinding::Binding::initialize();
|
glbinding::Binding::initialize();
|
||||||
|
@ -35,8 +35,6 @@ static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE;
|
|||||||
static ImGui_ImplVulkanH_Window g_MainWindowData;
|
static ImGui_ImplVulkanH_Window g_MainWindowData;
|
||||||
static uint32_t g_MinImageCount = 2;
|
static uint32_t g_MinImageCount = 2;
|
||||||
static bool g_SwapChainRebuild = false;
|
static bool g_SwapChainRebuild = false;
|
||||||
static int g_SwapChainResizeWidth = 0;
|
|
||||||
static int g_SwapChainResizeHeight = 0;
|
|
||||||
|
|
||||||
static void check_vk_result(VkResult err)
|
static void check_vk_result(VkResult err)
|
||||||
{
|
{
|
||||||
@ -66,10 +64,9 @@ static void SetupVulkan(const char** extensions, uint32_t extensions_count)
|
|||||||
create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||||
create_info.enabledExtensionCount = extensions_count;
|
create_info.enabledExtensionCount = extensions_count;
|
||||||
create_info.ppEnabledExtensionNames = extensions;
|
create_info.ppEnabledExtensionNames = extensions;
|
||||||
|
|
||||||
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
||||||
// Enabling multiple validation layers grouped as LunarG standard validation
|
// Enabling validation layers
|
||||||
const char* layers[] = { "VK_LAYER_LUNARG_standard_validation" };
|
const char* layers[] = { "VK_LAYER_KHRONOS_validation" };
|
||||||
create_info.enabledLayerCount = 1;
|
create_info.enabledLayerCount = 1;
|
||||||
create_info.ppEnabledLayerNames = layers;
|
create_info.ppEnabledLayerNames = layers;
|
||||||
|
|
||||||
@ -247,6 +244,11 @@ static void FrameRender(ImGui_ImplVulkanH_Window* wd, ImDrawData* draw_data)
|
|||||||
VkSemaphore image_acquired_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].ImageAcquiredSemaphore;
|
VkSemaphore image_acquired_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].ImageAcquiredSemaphore;
|
||||||
VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore;
|
VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore;
|
||||||
err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
|
err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
|
||||||
|
if (err == VK_ERROR_OUT_OF_DATE_KHR)
|
||||||
|
{
|
||||||
|
g_SwapChainRebuild = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
|
|
||||||
ImGui_ImplVulkanH_Frame* fd = &wd->Frames[wd->FrameIndex];
|
ImGui_ImplVulkanH_Frame* fd = &wd->Frames[wd->FrameIndex];
|
||||||
@ -304,6 +306,8 @@ static void FrameRender(ImGui_ImplVulkanH_Window* wd, ImDrawData* draw_data)
|
|||||||
|
|
||||||
static void FramePresent(ImGui_ImplVulkanH_Window* wd)
|
static void FramePresent(ImGui_ImplVulkanH_Window* wd)
|
||||||
{
|
{
|
||||||
|
if (g_SwapChainRebuild)
|
||||||
|
return;
|
||||||
VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore;
|
VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore;
|
||||||
VkPresentInfoKHR info = {};
|
VkPresentInfoKHR info = {};
|
||||||
info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
||||||
@ -313,6 +317,11 @@ static void FramePresent(ImGui_ImplVulkanH_Window* wd)
|
|||||||
info.pSwapchains = &wd->Swapchain;
|
info.pSwapchains = &wd->Swapchain;
|
||||||
info.pImageIndices = &wd->FrameIndex;
|
info.pImageIndices = &wd->FrameIndex;
|
||||||
VkResult err = vkQueuePresentKHR(g_Queue, &info);
|
VkResult err = vkQueuePresentKHR(g_Queue, &info);
|
||||||
|
if (err == VK_ERROR_OUT_OF_DATE_KHR)
|
||||||
|
{
|
||||||
|
g_SwapChainRebuild = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->ImageCount; // Now we can use the next set of semaphores
|
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->ImageCount; // Now we can use the next set of semaphores
|
||||||
}
|
}
|
||||||
@ -445,24 +454,22 @@ int main(int, char**)
|
|||||||
ImGui_ImplSDL2_ProcessEvent(&event);
|
ImGui_ImplSDL2_ProcessEvent(&event);
|
||||||
if (event.type == SDL_QUIT)
|
if (event.type == SDL_QUIT)
|
||||||
done = true;
|
done = true;
|
||||||
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_RESIZED && event.window.windowID == SDL_GetWindowID(window))
|
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window))
|
||||||
{
|
done = true;
|
||||||
// Note: your own application may rely on SDL_WINDOWEVENT_MINIMIZED/SDL_WINDOWEVENT_RESTORED to skip updating all-together.
|
|
||||||
// Here ImGui_ImplSDL2_NewFrame() will set io.DisplaySize to zero which will disable rendering but let application run.
|
|
||||||
// Please note that you can't Present into a minimized window.
|
|
||||||
g_SwapChainResizeWidth = (int)event.window.data1;
|
|
||||||
g_SwapChainResizeHeight = (int)event.window.data2;
|
|
||||||
g_SwapChainRebuild = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resize swap chain?
|
// Resize swap chain?
|
||||||
if (g_SwapChainRebuild && g_SwapChainResizeWidth > 0 && g_SwapChainResizeHeight > 0)
|
if (g_SwapChainRebuild)
|
||||||
{
|
{
|
||||||
g_SwapChainRebuild = false;
|
int width, height;
|
||||||
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
|
SDL_GetWindowSize(window, &width, &height);
|
||||||
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, g_SwapChainResizeWidth, g_SwapChainResizeHeight, g_MinImageCount);
|
if (width > 0 && height > 0)
|
||||||
g_MainWindowData.FrameIndex = 0;
|
{
|
||||||
|
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
|
||||||
|
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, width, height, g_MinImageCount);
|
||||||
|
g_MainWindowData.FrameIndex = 0;
|
||||||
|
g_SwapChainRebuild = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the Dear ImGui frame
|
// Start the Dear ImGui frame
|
||||||
@ -513,6 +520,7 @@ int main(int, char**)
|
|||||||
const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f);
|
const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f);
|
||||||
if (!is_minimized)
|
if (!is_minimized)
|
||||||
{
|
{
|
||||||
|
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
||||||
FrameRender(wd, draw_data);
|
FrameRender(wd, draw_data);
|
||||||
FramePresent(wd);
|
FramePresent(wd);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
// Create application window
|
// Create application window
|
||||||
|
//ImGui_ImplWin32_EnableDpiAwareness();
|
||||||
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL };
|
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL };
|
||||||
::RegisterClassEx(&wc);
|
::RegisterClassEx(&wc);
|
||||||
HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX10 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
|
HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX10 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
|
||||||
|
@ -26,6 +26,7 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
// Create application window
|
// Create application window
|
||||||
|
//ImGui_ImplWin32_EnableDpiAwareness();
|
||||||
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL };
|
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL };
|
||||||
::RegisterClassEx(&wc);
|
::RegisterClassEx(&wc);
|
||||||
HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX11 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
|
HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX11 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
|
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
|
||||||
|
@REM Important: to build on 32-bit systems, the DX12 back-ends needs '#define ImTextureID ImU64', so we pass it here.
|
||||||
mkdir Debug
|
mkdir Debug
|
||||||
cl /nologo /Zi /MD /I .. /I ..\.. /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /D UNICODE /D _UNICODE *.cpp ..\imgui_impl_dx12.cpp ..\imgui_impl_win32.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx12.exe /FoDebug/ /link d3d12.lib d3dcompiler.lib dxgi.lib
|
cl /nologo /Zi /MD /I .. /I ..\.. /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /D ImTextureID=ImU64 /D UNICODE /D _UNICODE *.cpp ..\imgui_impl_dx12.cpp ..\imgui_impl_win32.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx12.exe /FoDebug/ /link d3d12.lib d3dcompiler.lib dxgi.lib
|
||||||
|
|
||||||
|
@ -87,6 +87,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>ImTextureID=ImU64;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@ -100,6 +101,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>ImTextureID=ImU64;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@ -115,6 +117,7 @@
|
|||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>ImTextureID=ImU64;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@ -132,6 +135,7 @@
|
|||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>ImTextureID=ImU64;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
@ -57,6 +57,7 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
// Create application window
|
// Create application window
|
||||||
|
//ImGui_ImplWin32_EnableDpiAwareness();
|
||||||
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL };
|
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL };
|
||||||
::RegisterClassEx(&wc);
|
::RegisterClassEx(&wc);
|
||||||
HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX12 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
|
HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX12 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
|
||||||
@ -240,19 +241,32 @@ bool CreateDeviceD3D(HWND hWnd)
|
|||||||
sd.Stereo = FALSE;
|
sd.Stereo = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// [DEBUG] Enable debug interface
|
||||||
#ifdef DX12_ENABLE_DEBUG_LAYER
|
#ifdef DX12_ENABLE_DEBUG_LAYER
|
||||||
ID3D12Debug* pdx12Debug = NULL;
|
ID3D12Debug* pdx12Debug = NULL;
|
||||||
if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&pdx12Debug))))
|
if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&pdx12Debug))))
|
||||||
{
|
|
||||||
pdx12Debug->EnableDebugLayer();
|
pdx12Debug->EnableDebugLayer();
|
||||||
pdx12Debug->Release();
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Create device
|
||||||
D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0;
|
D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0;
|
||||||
if (D3D12CreateDevice(NULL, featureLevel, IID_PPV_ARGS(&g_pd3dDevice)) != S_OK)
|
if (D3D12CreateDevice(NULL, featureLevel, IID_PPV_ARGS(&g_pd3dDevice)) != S_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// [DEBUG] Setup debug interface to break on any warnings/errors
|
||||||
|
#ifdef DX12_ENABLE_DEBUG_LAYER
|
||||||
|
if (pdx12Debug != NULL)
|
||||||
|
{
|
||||||
|
ID3D12InfoQueue* pInfoQueue = NULL;
|
||||||
|
g_pd3dDevice->QueryInterface(IID_PPV_ARGS(&pInfoQueue));
|
||||||
|
pInfoQueue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_ERROR, true);
|
||||||
|
pInfoQueue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_CORRUPTION, true);
|
||||||
|
pInfoQueue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_WARNING, true);
|
||||||
|
pInfoQueue->Release();
|
||||||
|
pdx12Debug->Release();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
D3D12_DESCRIPTOR_HEAP_DESC desc = {};
|
D3D12_DESCRIPTOR_HEAP_DESC desc = {};
|
||||||
desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
|
desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
|
||||||
|
@ -24,6 +24,7 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
// Create application window
|
// Create application window
|
||||||
|
//ImGui_ImplWin32_EnableDpiAwareness();
|
||||||
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL };
|
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL };
|
||||||
::RegisterClassEx(&wc);
|
::RegisterClassEx(&wc);
|
||||||
HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX9 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
|
HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX9 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
|
||||||
|
@ -13,6 +13,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_glfw_opengl2", "exa
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_glfw_opengl3", "example_glfw_opengl3\example_glfw_opengl3.vcxproj", "{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_glfw_opengl3", "example_glfw_opengl3\example_glfw_opengl3.vcxproj", "{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_win32_directx12", "example_win32_directx12\example_win32_directx12.vcxproj", "{B4CF9797-519D-4AFE-A8F4-5141A6B521D3}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Win32 = Debug|Win32
|
Debug|Win32 = Debug|Win32
|
||||||
@ -21,14 +23,6 @@ Global
|
|||||||
Release|x64 = Release|x64
|
Release|x64 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{9CDA7840-B7A5-496D-A527-E95571496D18}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{9CDA7840-B7A5-496D-A527-E95571496D18}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{9CDA7840-B7A5-496D-A527-E95571496D18}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{9CDA7840-B7A5-496D-A527-E95571496D18}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{9CDA7840-B7A5-496D-A527-E95571496D18}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{9CDA7840-B7A5-496D-A527-E95571496D18}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{9CDA7840-B7A5-496D-A527-E95571496D18}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{9CDA7840-B7A5-496D-A527-E95571496D18}.Release|x64.Build.0 = Release|x64
|
|
||||||
{4165A294-21F2-44CA-9B38-E3F935ABADF5}.Debug|Win32.ActiveCfg = Debug|Win32
|
{4165A294-21F2-44CA-9B38-E3F935ABADF5}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{4165A294-21F2-44CA-9B38-E3F935ABADF5}.Debug|Win32.Build.0 = Debug|Win32
|
{4165A294-21F2-44CA-9B38-E3F935ABADF5}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{4165A294-21F2-44CA-9B38-E3F935ABADF5}.Debug|x64.ActiveCfg = Debug|x64
|
{4165A294-21F2-44CA-9B38-E3F935ABADF5}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
@ -37,22 +31,6 @@ Global
|
|||||||
{4165A294-21F2-44CA-9B38-E3F935ABADF5}.Release|Win32.Build.0 = Release|Win32
|
{4165A294-21F2-44CA-9B38-E3F935ABADF5}.Release|Win32.Build.0 = Release|Win32
|
||||||
{4165A294-21F2-44CA-9B38-E3F935ABADF5}.Release|x64.ActiveCfg = Release|x64
|
{4165A294-21F2-44CA-9B38-E3F935ABADF5}.Release|x64.ActiveCfg = Release|x64
|
||||||
{4165A294-21F2-44CA-9B38-E3F935ABADF5}.Release|x64.Build.0 = Release|x64
|
{4165A294-21F2-44CA-9B38-E3F935ABADF5}.Release|x64.Build.0 = Release|x64
|
||||||
{9F316E83-5AE5-4939-A723-305A94F48005}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{9F316E83-5AE5-4939-A723-305A94F48005}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{9F316E83-5AE5-4939-A723-305A94F48005}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{9F316E83-5AE5-4939-A723-305A94F48005}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{9F316E83-5AE5-4939-A723-305A94F48005}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{9F316E83-5AE5-4939-A723-305A94F48005}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{9F316E83-5AE5-4939-A723-305A94F48005}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{9F316E83-5AE5-4939-A723-305A94F48005}.Release|x64.Build.0 = Release|x64
|
|
||||||
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|x64.Build.0 = Release|x64
|
|
||||||
{345A953E-A004-4648-B442-DC5F9F11068C}.Debug|Win32.ActiveCfg = Debug|Win32
|
{345A953E-A004-4648-B442-DC5F9F11068C}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{345A953E-A004-4648-B442-DC5F9F11068C}.Debug|Win32.Build.0 = Debug|Win32
|
{345A953E-A004-4648-B442-DC5F9F11068C}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{345A953E-A004-4648-B442-DC5F9F11068C}.Debug|x64.ActiveCfg = Debug|x64
|
{345A953E-A004-4648-B442-DC5F9F11068C}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
@ -61,6 +39,38 @@ Global
|
|||||||
{345A953E-A004-4648-B442-DC5F9F11068C}.Release|Win32.Build.0 = Release|Win32
|
{345A953E-A004-4648-B442-DC5F9F11068C}.Release|Win32.Build.0 = Release|Win32
|
||||||
{345A953E-A004-4648-B442-DC5F9F11068C}.Release|x64.ActiveCfg = Release|x64
|
{345A953E-A004-4648-B442-DC5F9F11068C}.Release|x64.ActiveCfg = Release|x64
|
||||||
{345A953E-A004-4648-B442-DC5F9F11068C}.Release|x64.Build.0 = Release|x64
|
{345A953E-A004-4648-B442-DC5F9F11068C}.Release|x64.Build.0 = Release|x64
|
||||||
|
{9F316E83-5AE5-4939-A723-305A94F48005}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{9F316E83-5AE5-4939-A723-305A94F48005}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{9F316E83-5AE5-4939-A723-305A94F48005}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{9F316E83-5AE5-4939-A723-305A94F48005}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{9F316E83-5AE5-4939-A723-305A94F48005}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{9F316E83-5AE5-4939-A723-305A94F48005}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{9F316E83-5AE5-4939-A723-305A94F48005}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{9F316E83-5AE5-4939-A723-305A94F48005}.Release|x64.Build.0 = Release|x64
|
||||||
|
{9CDA7840-B7A5-496D-A527-E95571496D18}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{9CDA7840-B7A5-496D-A527-E95571496D18}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{9CDA7840-B7A5-496D-A527-E95571496D18}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{9CDA7840-B7A5-496D-A527-E95571496D18}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{9CDA7840-B7A5-496D-A527-E95571496D18}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{9CDA7840-B7A5-496D-A527-E95571496D18}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{9CDA7840-B7A5-496D-A527-E95571496D18}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{9CDA7840-B7A5-496D-A527-E95571496D18}.Release|x64.Build.0 = Release|x64
|
||||||
|
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|x64.Build.0 = Release|x64
|
||||||
|
{B4CF9797-519D-4AFE-A8F4-5141A6B521D3}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{B4CF9797-519D-4AFE-A8F4-5141A6B521D3}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{B4CF9797-519D-4AFE-A8F4-5141A6B521D3}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{B4CF9797-519D-4AFE-A8F4-5141A6B521D3}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{B4CF9797-519D-4AFE-A8F4-5141A6B521D3}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{B4CF9797-519D-4AFE-A8F4-5141A6B521D3}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{B4CF9797-519D-4AFE-A8F4-5141A6B521D3}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{B4CF9797-519D-4AFE-A8F4-5141A6B521D3}.Release|x64.Build.0 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2020-08-10: Inputs: Fixed horizontal mouse wheel direction.
|
||||||
// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor.
|
// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor.
|
||||||
// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter.
|
// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter.
|
||||||
// 2019-05-11: Inputs: Don't filter character value from ALLEGRO_EVENT_KEY_CHAR before calling AddInputCharacter().
|
// 2019-05-11: Inputs: Don't filter character value from ALLEGRO_EVENT_KEY_CHAR before calling AddInputCharacter().
|
||||||
@ -174,7 +175,7 @@ void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data)
|
|||||||
bool ImGui_ImplAllegro5_CreateDeviceObjects()
|
bool ImGui_ImplAllegro5_CreateDeviceObjects()
|
||||||
{
|
{
|
||||||
// Build texture atlas
|
// Build texture atlas
|
||||||
ImGuiIO &io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
unsigned char* pixels;
|
unsigned char* pixels;
|
||||||
int width, height;
|
int width, height;
|
||||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
||||||
@ -182,7 +183,7 @@ bool ImGui_ImplAllegro5_CreateDeviceObjects()
|
|||||||
// Create texture
|
// Create texture
|
||||||
int flags = al_get_new_bitmap_flags();
|
int flags = al_get_new_bitmap_flags();
|
||||||
int fmt = al_get_new_bitmap_format();
|
int fmt = al_get_new_bitmap_format();
|
||||||
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP|ALLEGRO_MIN_LINEAR|ALLEGRO_MAG_LINEAR);
|
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR);
|
||||||
al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE);
|
al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE);
|
||||||
ALLEGRO_BITMAP* img = al_create_bitmap(width, height);
|
ALLEGRO_BITMAP* img = al_create_bitmap(width, height);
|
||||||
al_set_new_bitmap_flags(flags);
|
al_set_new_bitmap_flags(flags);
|
||||||
@ -190,13 +191,13 @@ bool ImGui_ImplAllegro5_CreateDeviceObjects()
|
|||||||
if (!img)
|
if (!img)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ALLEGRO_LOCKED_REGION *locked_img = al_lock_bitmap(img, al_get_bitmap_format(img), ALLEGRO_LOCK_WRITEONLY);
|
ALLEGRO_LOCKED_REGION* locked_img = al_lock_bitmap(img, al_get_bitmap_format(img), ALLEGRO_LOCK_WRITEONLY);
|
||||||
if (!locked_img)
|
if (!locked_img)
|
||||||
{
|
{
|
||||||
al_destroy_bitmap(img);
|
al_destroy_bitmap(img);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
memcpy(locked_img->data, pixels, sizeof(int)*width*height);
|
memcpy(locked_img->data, pixels, sizeof(int) * width * height);
|
||||||
al_unlock_bitmap(img);
|
al_unlock_bitmap(img);
|
||||||
|
|
||||||
// Convert software texture to hardware texture.
|
// Convert software texture to hardware texture.
|
||||||
@ -211,7 +212,7 @@ bool ImGui_ImplAllegro5_CreateDeviceObjects()
|
|||||||
|
|
||||||
// Create an invisible mouse cursor
|
// Create an invisible mouse cursor
|
||||||
// Because al_hide_mouse_cursor() seems to mess up with the actual inputs..
|
// Because al_hide_mouse_cursor() seems to mess up with the actual inputs..
|
||||||
ALLEGRO_BITMAP* mouse_cursor = al_create_bitmap(8,8);
|
ALLEGRO_BITMAP* mouse_cursor = al_create_bitmap(8, 8);
|
||||||
g_MouseCursorInvisible = al_create_mouse_cursor(mouse_cursor, 0, 0);
|
g_MouseCursorInvisible = al_create_mouse_cursor(mouse_cursor, 0, 0);
|
||||||
al_destroy_bitmap(mouse_cursor);
|
al_destroy_bitmap(mouse_cursor);
|
||||||
|
|
||||||
@ -322,7 +323,7 @@ void ImGui_ImplAllegro5_Shutdown()
|
|||||||
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||||
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
||||||
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||||
bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT *ev)
|
bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT* ev)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
@ -332,7 +333,7 @@ bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT *ev)
|
|||||||
if (ev->mouse.display == g_Display)
|
if (ev->mouse.display == g_Display)
|
||||||
{
|
{
|
||||||
io.MouseWheel += ev->mouse.dz;
|
io.MouseWheel += ev->mouse.dz;
|
||||||
io.MouseWheelH += ev->mouse.dw;
|
io.MouseWheelH -= ev->mouse.dw;
|
||||||
io.MousePos = ImVec2(ev->mouse.x, ev->mouse.y);
|
io.MousePos = ImVec2(ev->mouse.x, ev->mouse.y);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -403,7 +404,7 @@ void ImGui_ImplAllegro5_NewFrame()
|
|||||||
if (!g_Texture)
|
if (!g_Texture)
|
||||||
ImGui_ImplAllegro5_CreateDeviceObjects();
|
ImGui_ImplAllegro5_CreateDeviceObjects();
|
||||||
|
|
||||||
ImGuiIO &io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
// Setup display size (every frame to accommodate for window resizing)
|
// Setup display size (every frame to accommodate for window resizing)
|
||||||
int w, h;
|
int w, h;
|
||||||
@ -413,7 +414,7 @@ void ImGui_ImplAllegro5_NewFrame()
|
|||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
double current_time = al_get_time();
|
double current_time = al_get_time();
|
||||||
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
|
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f / 60.0f);
|
||||||
g_Time = current_time;
|
g_Time = current_time;
|
||||||
|
|
||||||
// Setup inputs
|
// Setup inputs
|
||||||
|
@ -287,7 +287,7 @@ static void ImGui_ImplDX10_CreateFontsTexture()
|
|||||||
desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
|
desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
|
||||||
desc.CPUAccessFlags = 0;
|
desc.CPUAccessFlags = 0;
|
||||||
|
|
||||||
ID3D10Texture2D *pTexture = NULL;
|
ID3D10Texture2D* pTexture = NULL;
|
||||||
D3D10_SUBRESOURCE_DATA subResource;
|
D3D10_SUBRESOURCE_DATA subResource;
|
||||||
subResource.pSysMem = pixels;
|
subResource.pSysMem = pixels;
|
||||||
subResource.SysMemPitch = desc.Width * 4;
|
subResource.SysMemPitch = desc.Width * 4;
|
||||||
|
@ -299,7 +299,7 @@ static void ImGui_ImplDX11_CreateFontsTexture()
|
|||||||
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||||
desc.CPUAccessFlags = 0;
|
desc.CPUAccessFlags = 0;
|
||||||
|
|
||||||
ID3D11Texture2D *pTexture = NULL;
|
ID3D11Texture2D* pTexture = NULL;
|
||||||
D3D11_SUBRESOURCE_DATA subResource;
|
D3D11_SUBRESOURCE_DATA subResource;
|
||||||
subResource.pSysMem = pixels;
|
subResource.pSysMem = pixels;
|
||||||
subResource.SysMemPitch = desc.Width * 4;
|
subResource.SysMemPitch = desc.Width * 4;
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||||
// Issues:
|
|
||||||
// [ ] 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*)). See github.com/ocornut/imgui/pull/301
|
// Important: to compile on 32-bit systems, this back-end requires code to be compiled with '#define ImTextureID ImU64'.
|
||||||
|
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
|
||||||
|
// This define is done in the example .vcxproj file and need to be replicated in your app (by e.g. editing imconfig.h)
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||||
@ -13,6 +15,8 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2020-09-16: DirectX12: Avoid rendering calls with zero-sized scissor rectangle since it generates a validation layer warning.
|
||||||
|
// 2020-09-08: DirectX12: Clarified support for building on 32-bit systems by redefining ImTextureID.
|
||||||
// 2019-10-18: DirectX12: *BREAKING CHANGE* Added extra ID3D12DescriptorHeap parameter to ImGui_ImplDX12_Init() function.
|
// 2019-10-18: DirectX12: *BREAKING CHANGE* Added extra ID3D12DescriptorHeap parameter to ImGui_ImplDX12_Init() function.
|
||||||
// 2019-05-29: DirectX12: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
// 2019-05-29: DirectX12: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
||||||
// 2019-04-30: DirectX12: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
// 2019-04-30: DirectX12: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||||
@ -232,9 +236,12 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
|
|||||||
{
|
{
|
||||||
// Apply Scissor, Bind texture, Draw
|
// Apply Scissor, Bind texture, Draw
|
||||||
const D3D12_RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) };
|
const D3D12_RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) };
|
||||||
ctx->SetGraphicsRootDescriptorTable(1, *(D3D12_GPU_DESCRIPTOR_HANDLE*)&pcmd->TextureId);
|
if (r.right > r.left && r.bottom > r.top)
|
||||||
ctx->RSSetScissorRects(1, &r);
|
{
|
||||||
ctx->DrawIndexedInstanced(pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0);
|
ctx->SetGraphicsRootDescriptorTable(1, *(D3D12_GPU_DESCRIPTOR_HANDLE*)&pcmd->TextureId);
|
||||||
|
ctx->RSSetScissorRects(1, &r);
|
||||||
|
ctx->DrawIndexedInstanced(pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
global_idx_offset += cmd_list->IdxBuffer.Size;
|
global_idx_offset += cmd_list->IdxBuffer.Size;
|
||||||
@ -359,7 +366,7 @@ static void ImGui_ImplDX12_CreateFontsTexture()
|
|||||||
hr = cmdList->Close();
|
hr = cmdList->Close();
|
||||||
IM_ASSERT(SUCCEEDED(hr));
|
IM_ASSERT(SUCCEEDED(hr));
|
||||||
|
|
||||||
cmdQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*) &cmdList);
|
cmdQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&cmdList);
|
||||||
hr = cmdQueue->Signal(fence, 1);
|
hr = cmdQueue->Signal(fence, 1);
|
||||||
IM_ASSERT(SUCCEEDED(hr));
|
IM_ASSERT(SUCCEEDED(hr));
|
||||||
|
|
||||||
@ -509,7 +516,8 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
|
|||||||
psoDesc.VS = { vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize() };
|
psoDesc.VS = { vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize() };
|
||||||
|
|
||||||
// Create the input layout
|
// Create the input layout
|
||||||
static D3D12_INPUT_ELEMENT_DESC local_layout[] = {
|
static D3D12_INPUT_ELEMENT_DESC local_layout[] =
|
||||||
|
{
|
||||||
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, pos), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, pos), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
||||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, uv), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, uv), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
||||||
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert, col), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert, col), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||||
// Issues:
|
|
||||||
// [ ] 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*)). See github.com/ocornut/imgui/pull/301
|
// Important: to compile on 32-bit systems, this back-end requires code to be compiled with '#define ImTextureID ImU64'.
|
||||||
|
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
|
||||||
|
// This define is done in the example .vcxproj file and need to be replicated in your app (by e.g. editing imconfig.h)
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||||
|
@ -199,7 +199,7 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
const LPDIRECT3DTEXTURE9 texture = (LPDIRECT3DTEXTURE9)pcmd->TextureId;
|
const LPDIRECT3DTEXTURE9 texture = (LPDIRECT3DTEXTURE9)pcmd->TextureId;
|
||||||
g_pd3dDevice->SetTexture(0, texture);
|
g_pd3dDevice->SetTexture(0, texture);
|
||||||
g_pd3dDevice->SetScissorRect(&r);
|
g_pd3dDevice->SetScissorRect(&r);
|
||||||
g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, pcmd->VtxOffset + global_vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, pcmd->IdxOffset + global_idx_offset, pcmd->ElemCount/3);
|
g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, pcmd->VtxOffset + global_vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, pcmd->IdxOffset + global_idx_offset, pcmd->ElemCount / 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
global_idx_offset += cmd_list->IdxBuffer.Size;
|
global_idx_offset += cmd_list->IdxBuffer.Size;
|
||||||
@ -250,7 +250,7 @@ static bool ImGui_ImplDX9_CreateFontsTexture()
|
|||||||
if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK)
|
if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK)
|
||||||
return false;
|
return false;
|
||||||
for (int y = 0; y < height; y++)
|
for (int y = 0; y < height; y++)
|
||||||
memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * bytes_per_pixel) * y, (width * bytes_per_pixel));
|
memcpy((unsigned char*)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * bytes_per_pixel) * y, (width * bytes_per_pixel));
|
||||||
g_FontTexture->UnlockRect(0);
|
g_FontTexture->UnlockRect(0);
|
||||||
|
|
||||||
// Store our identifier
|
// Store our identifier
|
||||||
|
@ -358,7 +358,7 @@ void ImGui_ImplGlfw_NewFrame()
|
|||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
double current_time = glfwGetTime();
|
double current_time = glfwGetTime();
|
||||||
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
|
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f / 60.0f);
|
||||||
g_Time = current_time;
|
g_Time = current_time;
|
||||||
|
|
||||||
ImGui_ImplGlfw_UpdateMousePosAndButtons();
|
ImGui_ImplGlfw_UpdateMousePosAndButtons();
|
||||||
|
@ -25,9 +25,9 @@
|
|||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_glut.h"
|
#include "imgui_impl_glut.h"
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <GLUT/glut.h>
|
#include <GLUT/glut.h>
|
||||||
#else
|
#else
|
||||||
#include <GL/freeglut.h>
|
#include <GL/freeglut.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@ -41,9 +41,9 @@ bool ImGui_ImplGLUT_Init()
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
#ifdef FREEGLUT
|
#ifdef FREEGLUT
|
||||||
io.BackendPlatformName ="imgui_impl_glut (freeglut)";
|
io.BackendPlatformName = "imgui_impl_glut (freeglut)";
|
||||||
#else
|
#else
|
||||||
io.BackendPlatformName ="imgui_impl_glut";
|
io.BackendPlatformName = "imgui_impl_glut";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_Time = 0;
|
g_Time = 0;
|
||||||
|
@ -36,7 +36,7 @@ static char* g_ClipboardText = NULL;
|
|||||||
static bool g_osdKeyboardEnabled = false;
|
static bool g_osdKeyboardEnabled = false;
|
||||||
|
|
||||||
// use this setting to scale the interface - e.g. on device you could use 2 or 3 scale factor
|
// use this setting to scale the interface - e.g. on device you could use 2 or 3 scale factor
|
||||||
static ImVec2 g_RenderScale = ImVec2(1.0f,1.0f);
|
static ImVec2 g_RenderScale = ImVec2(1.0f, 1.0f);
|
||||||
|
|
||||||
// Render function.
|
// Render function.
|
||||||
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
|
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
|
||||||
@ -272,18 +272,18 @@ void ImGui_Marmalade_NewFrame()
|
|||||||
// Setup display size (every frame to accommodate for window resizing)
|
// Setup display size (every frame to accommodate for window resizing)
|
||||||
int w = IwGxGetScreenWidth(), h = IwGxGetScreenHeight();
|
int w = IwGxGetScreenWidth(), h = IwGxGetScreenHeight();
|
||||||
io.DisplaySize = ImVec2((float)w, (float)h);
|
io.DisplaySize = ImVec2((float)w, (float)h);
|
||||||
// For retina display or other situations where window coordinates are different from framebuffer coordinates. User storage only, presently not used by ImGui.
|
// For retina display or other situations where window coordinates are different from framebuffer coordinates. User storage only, presently not used by ImGui.
|
||||||
io.DisplayFramebufferScale = g_scale;
|
io.DisplayFramebufferScale = g_scale;
|
||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
double current_time = s3eTimerGetUST() / 1000.0f;
|
double current_time = s3eTimerGetUST() / 1000.0f;
|
||||||
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
|
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f / 60.0f);
|
||||||
g_Time = current_time;
|
g_Time = current_time;
|
||||||
|
|
||||||
double mouse_x, mouse_y;
|
double mouse_x, mouse_y;
|
||||||
mouse_x = s3ePointerGetX();
|
mouse_x = s3ePointerGetX();
|
||||||
mouse_y = s3ePointerGetY();
|
mouse_y = s3ePointerGetY();
|
||||||
io.MousePos = ImVec2((float)mouse_x/g_scale.x, (float)mouse_y/g_scale.y); // Mouse position (set to -FLT_MAX,-FLT_MAX if no mouse / on another screen, etc.)
|
io.MousePos = ImVec2((float)mouse_x / g_scale.x, (float)mouse_y / g_scale.y); // Mouse position (set to -FLT_MAX,-FLT_MAX if no mouse / on another screen, etc.)
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
@ -294,7 +294,7 @@ void ImGui_Marmalade_NewFrame()
|
|||||||
// TODO: Hide OS mouse cursor if ImGui is drawing it
|
// TODO: Hide OS mouse cursor if ImGui is drawing it
|
||||||
// s3ePointerSetInt(S3E_POINTER_HIDE_CURSOR,(io.MouseDrawCursor ? 0 : 1));
|
// s3ePointerSetInt(S3E_POINTER_HIDE_CURSOR,(io.MouseDrawCursor ? 0 : 1));
|
||||||
|
|
||||||
// Show/hide OSD keyboard
|
// Show/hide OSD keyboard
|
||||||
if (io.WantTextInput)
|
if (io.WantTextInput)
|
||||||
{
|
{
|
||||||
// Some text input widget is active?
|
// Some text input widget is active?
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id<MTLDevice> device);
|
IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id<MTLDevice> device);
|
||||||
IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor *renderPassDescriptor);
|
IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor);
|
||||||
IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data,
|
IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data,
|
||||||
id<MTLCommandBuffer> commandBuffer,
|
id<MTLCommandBuffer> commandBuffer,
|
||||||
id<MTLRenderCommandEncoder> commandEncoder);
|
id<MTLRenderCommandEncoder> commandEncoder);
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2020-09-17: OpenGL: Fix to avoid compiling/calling glBindSampler() on ES or pre 3.3 context which have the defines set by a loader.
|
||||||
|
// 2020-07-10: OpenGL: Added support for glad2 OpenGL loader.
|
||||||
// 2020-05-08: OpenGL: Made default GLSL version 150 (instead of 130) on OSX.
|
// 2020-05-08: OpenGL: Made default GLSL version 150 (instead of 130) on OSX.
|
||||||
// 2020-04-21: OpenGL: Fixed handling of glClipControl(GL_UPPER_LEFT) by inverting projection matrix.
|
// 2020-04-21: OpenGL: Fixed handling of glClipControl(GL_UPPER_LEFT) by inverting projection matrix.
|
||||||
// 2020-04-12: OpenGL: Fixed context version check mistakenly testing for 4.0+ instead of 3.2+ to enable ImGuiBackendFlags_RendererHasVtxOffset.
|
// 2020-04-12: OpenGL: Fixed context version check mistakenly testing for 4.0+ instead of 3.2+ to enable ImGuiBackendFlags_RendererHasVtxOffset.
|
||||||
@ -24,7 +26,7 @@
|
|||||||
// 2019-05-29: OpenGL: Desktop GL only: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
// 2019-05-29: OpenGL: Desktop GL only: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
||||||
// 2019-04-30: OpenGL: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
// 2019-04-30: OpenGL: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||||
// 2019-03-29: OpenGL: Not calling glBindBuffer more than necessary in the render loop.
|
// 2019-03-29: OpenGL: Not calling glBindBuffer more than necessary in the render loop.
|
||||||
// 2019-03-15: OpenGL: Added a dummy GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized GL function loaders early.
|
// 2019-03-15: OpenGL: Added a GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized GL function loaders early.
|
||||||
// 2019-03-03: OpenGL: Fix support for ES 2.0 (WebGL 1.0).
|
// 2019-03-03: OpenGL: Fix support for ES 2.0 (WebGL 1.0).
|
||||||
// 2019-02-20: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN even if defined by the headers/loader.
|
// 2019-02-20: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN even if defined by the headers/loader.
|
||||||
// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
|
// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
|
||||||
@ -80,7 +82,6 @@
|
|||||||
#include <stdint.h> // intptr_t
|
#include <stdint.h> // intptr_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// GL includes
|
// GL includes
|
||||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||||
#include <GLES2/gl2.h>
|
#include <GLES2/gl2.h>
|
||||||
@ -101,6 +102,8 @@
|
|||||||
#include <GL/glew.h> // Needs to be initialized with glewInit() in user's code.
|
#include <GL/glew.h> // Needs to be initialized with glewInit() in user's code.
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||||
#include <glad/glad.h> // Needs to be initialized with gladLoadGL() in user's code.
|
#include <glad/glad.h> // Needs to be initialized with gladLoadGL() in user's code.
|
||||||
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD2)
|
||||||
|
#include <glad/gl.h> // Needs to be initialized with gladLoadGL(...) or gladLoaderLoadGL() in user's code.
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
||||||
#ifndef GLFW_INCLUDE_NONE
|
#ifndef GLFW_INCLUDE_NONE
|
||||||
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
||||||
@ -121,10 +124,13 @@ using namespace gl;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
|
// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
|
||||||
#if defined(IMGUI_IMPL_OPENGL_ES2) || defined(IMGUI_IMPL_OPENGL_ES3) || !defined(GL_VERSION_3_2)
|
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_2)
|
||||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET 0
|
#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||||
#else
|
#endif
|
||||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET 1
|
|
||||||
|
// Desktop GL 3.3+ has glBindSampler()
|
||||||
|
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_3)
|
||||||
|
#define IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// OpenGL Data
|
// OpenGL Data
|
||||||
@ -152,7 +158,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
// Setup back-end capabilities flags
|
// Setup back-end capabilities flags
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.BackendRendererName = "imgui_impl_opengl3";
|
io.BackendRendererName = "imgui_impl_opengl3";
|
||||||
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||||
if (g_GlVersion >= 320)
|
if (g_GlVersion >= 320)
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
#endif
|
#endif
|
||||||
@ -176,7 +182,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
strcpy(g_GlslVersionString, glsl_version);
|
strcpy(g_GlslVersionString, glsl_version);
|
||||||
strcat(g_GlslVersionString, "\n");
|
strcat(g_GlslVersionString, "\n");
|
||||||
|
|
||||||
// Dummy construct to make it easily visible in the IDE and debugger which GL loader has been selected.
|
// Debugging construct to make it easily visible in the IDE and debugger which GL loader has been selected.
|
||||||
// The code actually never uses the 'gl_loader' variable! It is only here so you can read it!
|
// The code actually never uses the 'gl_loader' variable! It is only here so you can read it!
|
||||||
// If auto-detection fails or doesn't select the same GL loader file as used by your application,
|
// If auto-detection fails or doesn't select the same GL loader file as used by your application,
|
||||||
// you are likely to get a crash below.
|
// you are likely to get a crash below.
|
||||||
@ -189,6 +195,8 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
gl_loader = "GLEW";
|
gl_loader = "GLEW";
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||||
gl_loader = "GLAD";
|
gl_loader = "GLAD";
|
||||||
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD2)
|
||||||
|
gl_loader = "GLAD2";
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
||||||
gl_loader = "glbinding2";
|
gl_loader = "glbinding2";
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
|
||||||
@ -199,7 +207,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
gl_loader = "none";
|
gl_loader = "none";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Make a dummy GL call (we don't actually need the result)
|
// Make an arbitrary GL call (we don't actually need the result)
|
||||||
// IF YOU GET A CRASH HERE: it probably means that you haven't initialized the OpenGL function loader used by this code.
|
// IF YOU GET A CRASH HERE: it probably means that you haven't initialized the OpenGL function loader used by this code.
|
||||||
// Desktop OpenGL 3/4 need a function loader. See the IMGUI_IMPL_OPENGL_LOADER_xxx explanation above.
|
// Desktop OpenGL 3/4 need a function loader. See the IMGUI_IMPL_OPENGL_LOADER_xxx explanation above.
|
||||||
GLint current_texture;
|
GLint current_texture;
|
||||||
@ -258,10 +266,12 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
|
|||||||
glUseProgram(g_ShaderHandle);
|
glUseProgram(g_ShaderHandle);
|
||||||
glUniform1i(g_AttribLocationTex, 0);
|
glUniform1i(g_AttribLocationTex, 0);
|
||||||
glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
||||||
#ifdef GL_SAMPLER_BINDING
|
|
||||||
glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
|
if (g_GlVersion >= 330)
|
||||||
|
glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
(void)vertex_array_object;
|
(void)vertex_array_object;
|
||||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||||
glBindVertexArray(vertex_array_object);
|
glBindVertexArray(vertex_array_object);
|
||||||
@ -294,8 +304,8 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
GLuint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program);
|
GLuint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program);
|
||||||
GLuint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture);
|
GLuint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture);
|
||||||
#ifdef GL_SAMPLER_BINDING
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
GLuint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler);
|
GLuint last_sampler; if (g_GlVersion >= 330) { glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler); } else { last_sampler = 0; }
|
||||||
#endif
|
#endif
|
||||||
GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer);
|
GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer);
|
||||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||||
@ -367,7 +377,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
|
|
||||||
// Bind texture, Draw
|
// Bind texture, Draw
|
||||||
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
||||||
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||||
if (g_GlVersion >= 320)
|
if (g_GlVersion >= 320)
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset);
|
glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset);
|
||||||
else
|
else
|
||||||
@ -386,8 +396,9 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
// Restore modified GL state
|
// Restore modified GL state
|
||||||
glUseProgram(last_program);
|
glUseProgram(last_program);
|
||||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
#ifdef GL_SAMPLER_BINDING
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
glBindSampler(0, last_sampler);
|
if (g_GlVersion >= 330)
|
||||||
|
glBindSampler(0, last_sampler);
|
||||||
#endif
|
#endif
|
||||||
glActiveTexture(last_active_texture);
|
glActiveTexture(last_active_texture);
|
||||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||||
|
@ -49,6 +49,7 @@ IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
|||||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \
|
||||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \
|
||||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \
|
||||||
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD2) \
|
||||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2) \
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2) \
|
||||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3) \
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3) \
|
||||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
|
||||||
@ -68,6 +69,8 @@ IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
|||||||
#define IMGUI_IMPL_OPENGL_LOADER_GLEW
|
#define IMGUI_IMPL_OPENGL_LOADER_GLEW
|
||||||
#elif __has_include(<glad/glad.h>)
|
#elif __has_include(<glad/glad.h>)
|
||||||
#define IMGUI_IMPL_OPENGL_LOADER_GLAD
|
#define IMGUI_IMPL_OPENGL_LOADER_GLAD
|
||||||
|
#elif __has_include(<glad/gl.h>)
|
||||||
|
#define IMGUI_IMPL_OPENGL_LOADER_GLAD2
|
||||||
#elif __has_include(<GL/gl3w.h>)
|
#elif __has_include(<GL/gl3w.h>)
|
||||||
#define IMGUI_IMPL_OPENGL_LOADER_GL3W
|
#define IMGUI_IMPL_OPENGL_LOADER_GL3W
|
||||||
#elif __has_include(<glbinding/glbinding.h>)
|
#elif __has_include(<glbinding/glbinding.h>)
|
||||||
|
@ -15,5 +15,5 @@
|
|||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplOSX_Init();
|
IMGUI_IMPL_API bool ImGui_ImplOSX_Init();
|
||||||
IMGUI_IMPL_API void ImGui_ImplOSX_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplOSX_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplOSX_NewFrame(NSView *_Nullable view);
|
IMGUI_IMPL_API void ImGui_ImplOSX_NewFrame(NSView* _Nullable view);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplOSX_HandleEvent(NSEvent *_Nonnull event, NSView *_Nullable view);
|
IMGUI_IMPL_API bool ImGui_ImplOSX_HandleEvent(NSEvent* _Nonnull event, NSView* _Nullable view);
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2020-09-07: Vulkan: Added VkPipeline parameter to ImGui_ImplVulkan_RenderDrawData (default to one passed to ImGui_ImplVulkan_Init).
|
||||||
// 2020-05-04: Vulkan: Fixed crash if initial frame has no vertices.
|
// 2020-05-04: Vulkan: Fixed crash if initial frame has no vertices.
|
||||||
// 2020-04-26: Vulkan: Fixed edge case where render callbacks wouldn't be called if the ImDrawData didn't have vertices.
|
// 2020-04-26: Vulkan: Fixed edge case where render callbacks wouldn't be called if the ImDrawData didn't have vertices.
|
||||||
// 2019-08-01: Vulkan: Added support for specifying multisample count. Set ImGui_ImplVulkan_InitInfo::MSAASamples to one of the VkSampleCountFlagBits values to use, default is non-multisampled as before.
|
// 2019-08-01: Vulkan: Added support for specifying multisample count. Set ImGui_ImplVulkan_InitInfo::MSAASamples to one of the VkSampleCountFlagBits values to use, default is non-multisampled as before.
|
||||||
@ -80,6 +81,8 @@ static VkDescriptorSetLayout g_DescriptorSetLayout = VK_NULL_HANDLE;
|
|||||||
static VkPipelineLayout g_PipelineLayout = VK_NULL_HANDLE;
|
static VkPipelineLayout g_PipelineLayout = VK_NULL_HANDLE;
|
||||||
static VkDescriptorSet g_DescriptorSet = VK_NULL_HANDLE;
|
static VkDescriptorSet g_DescriptorSet = VK_NULL_HANDLE;
|
||||||
static VkPipeline g_Pipeline = VK_NULL_HANDLE;
|
static VkPipeline g_Pipeline = VK_NULL_HANDLE;
|
||||||
|
static VkShaderModule g_ShaderModuleVert;
|
||||||
|
static VkShaderModule g_ShaderModuleFrag;
|
||||||
|
|
||||||
// Font data
|
// Font data
|
||||||
static VkSampler g_FontSampler = VK_NULL_HANDLE;
|
static VkSampler g_FontSampler = VK_NULL_HANDLE;
|
||||||
@ -221,7 +224,7 @@ static uint32_t ImGui_ImplVulkan_MemoryType(VkMemoryPropertyFlags properties, ui
|
|||||||
VkPhysicalDeviceMemoryProperties prop;
|
VkPhysicalDeviceMemoryProperties prop;
|
||||||
vkGetPhysicalDeviceMemoryProperties(v->PhysicalDevice, &prop);
|
vkGetPhysicalDeviceMemoryProperties(v->PhysicalDevice, &prop);
|
||||||
for (uint32_t i = 0; i < prop.memoryTypeCount; i++)
|
for (uint32_t i = 0; i < prop.memoryTypeCount; i++)
|
||||||
if ((prop.memoryTypes[i].propertyFlags & properties) == properties && type_bits & (1<<i))
|
if ((prop.memoryTypes[i].propertyFlags & properties) == properties && type_bits & (1 << i))
|
||||||
return i;
|
return i;
|
||||||
return 0xFFFFFFFF; // Unable to find memoryType
|
return 0xFFFFFFFF; // Unable to find memoryType
|
||||||
}
|
}
|
||||||
@ -266,11 +269,11 @@ static void CreateOrResizeBuffer(VkBuffer& buffer, VkDeviceMemory& buffer_memory
|
|||||||
p_buffer_size = new_size;
|
p_buffer_size = new_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkCommandBuffer command_buffer, ImGui_ImplVulkanH_FrameRenderBuffers* rb, int fb_width, int fb_height)
|
static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkPipeline pipeline, VkCommandBuffer command_buffer, ImGui_ImplVulkanH_FrameRenderBuffers* rb, int fb_width, int fb_height)
|
||||||
{
|
{
|
||||||
// Bind pipeline and descriptor sets:
|
// Bind pipeline and descriptor sets:
|
||||||
{
|
{
|
||||||
vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, g_Pipeline);
|
vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
||||||
VkDescriptorSet desc_set[1] = { g_DescriptorSet };
|
VkDescriptorSet desc_set[1] = { g_DescriptorSet };
|
||||||
vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, g_PipelineLayout, 0, 1, desc_set, 0, NULL);
|
vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, g_PipelineLayout, 0, 1, desc_set, 0, NULL);
|
||||||
}
|
}
|
||||||
@ -312,7 +315,7 @@ static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkCommandBu
|
|||||||
|
|
||||||
// Render function
|
// Render function
|
||||||
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
|
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
|
||||||
void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer)
|
void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline)
|
||||||
{
|
{
|
||||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||||
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
@ -321,6 +324,8 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ImGui_ImplVulkan_InitInfo* v = &g_VulkanInitInfo;
|
ImGui_ImplVulkan_InitInfo* v = &g_VulkanInitInfo;
|
||||||
|
if (pipeline == VK_NULL_HANDLE)
|
||||||
|
pipeline = g_Pipeline;
|
||||||
|
|
||||||
// Allocate array to store enough vertex/index buffers
|
// Allocate array to store enough vertex/index buffers
|
||||||
ImGui_ImplVulkanH_WindowRenderBuffers* wrb = &g_MainWindowRenderBuffers;
|
ImGui_ImplVulkanH_WindowRenderBuffers* wrb = &g_MainWindowRenderBuffers;
|
||||||
@ -374,7 +379,7 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup desired Vulkan state
|
// Setup desired Vulkan state
|
||||||
ImGui_ImplVulkan_SetupRenderState(draw_data, command_buffer, rb, fb_width, fb_height);
|
ImGui_ImplVulkan_SetupRenderState(draw_data, pipeline, command_buffer, rb, fb_width, fb_height);
|
||||||
|
|
||||||
// Will project scissor/clipping rectangles into framebuffer space
|
// Will project scissor/clipping rectangles into framebuffer space
|
||||||
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
||||||
@ -395,7 +400,7 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
// User callback, registered via ImDrawList::AddCallback()
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||||
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||||
ImGui_ImplVulkan_SetupRenderState(draw_data, command_buffer, rb, fb_width, fb_height);
|
ImGui_ImplVulkan_SetupRenderState(draw_data, pipeline, command_buffer, rb, fb_width, fb_height);
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(cmd_list, pcmd);
|
pcmd->UserCallback(cmd_list, pcmd);
|
||||||
}
|
}
|
||||||
@ -442,7 +447,7 @@ bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer)
|
|||||||
unsigned char* pixels;
|
unsigned char* pixels;
|
||||||
int width, height;
|
int width, height;
|
||||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
||||||
size_t upload_size = width*height*4*sizeof(char);
|
size_t upload_size = width * height * 4 * sizeof(char);
|
||||||
|
|
||||||
VkResult err;
|
VkResult err;
|
||||||
|
|
||||||
@ -586,28 +591,199 @@ bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplVulkan_CreateDeviceObjects()
|
static void ImGui_ImplVulkan_CreateShaderModules(VkDevice device, const VkAllocationCallbacks* allocator)
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkan_InitInfo* v = &g_VulkanInitInfo;
|
// Create the shader modules
|
||||||
VkResult err;
|
if (g_ShaderModuleVert == NULL)
|
||||||
VkShaderModule vert_module;
|
|
||||||
VkShaderModule frag_module;
|
|
||||||
|
|
||||||
// Create The Shader Modules:
|
|
||||||
{
|
{
|
||||||
VkShaderModuleCreateInfo vert_info = {};
|
VkShaderModuleCreateInfo vert_info = {};
|
||||||
vert_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
vert_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
||||||
vert_info.codeSize = sizeof(__glsl_shader_vert_spv);
|
vert_info.codeSize = sizeof(__glsl_shader_vert_spv);
|
||||||
vert_info.pCode = (uint32_t*)__glsl_shader_vert_spv;
|
vert_info.pCode = (uint32_t*)__glsl_shader_vert_spv;
|
||||||
err = vkCreateShaderModule(v->Device, &vert_info, v->Allocator, &vert_module);
|
VkResult err = vkCreateShaderModule(device, &vert_info, allocator, &g_ShaderModuleVert);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
|
}
|
||||||
|
if (g_ShaderModuleFrag == NULL)
|
||||||
|
{
|
||||||
VkShaderModuleCreateInfo frag_info = {};
|
VkShaderModuleCreateInfo frag_info = {};
|
||||||
frag_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
frag_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
||||||
frag_info.codeSize = sizeof(__glsl_shader_frag_spv);
|
frag_info.codeSize = sizeof(__glsl_shader_frag_spv);
|
||||||
frag_info.pCode = (uint32_t*)__glsl_shader_frag_spv;
|
frag_info.pCode = (uint32_t*)__glsl_shader_frag_spv;
|
||||||
err = vkCreateShaderModule(v->Device, &frag_info, v->Allocator, &frag_module);
|
VkResult err = vkCreateShaderModule(device, &frag_info, allocator, &g_ShaderModuleFrag);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplVulkan_CreateFontSampler(VkDevice device, const VkAllocationCallbacks* allocator)
|
||||||
|
{
|
||||||
|
if (g_FontSampler)
|
||||||
|
return;
|
||||||
|
|
||||||
|
VkSamplerCreateInfo info = {};
|
||||||
|
info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
||||||
|
info.magFilter = VK_FILTER_LINEAR;
|
||||||
|
info.minFilter = VK_FILTER_LINEAR;
|
||||||
|
info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
|
||||||
|
info.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||||
|
info.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||||
|
info.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||||
|
info.minLod = -1000;
|
||||||
|
info.maxLod = 1000;
|
||||||
|
info.maxAnisotropy = 1.0f;
|
||||||
|
VkResult err = vkCreateSampler(device, &info, allocator, &g_FontSampler);
|
||||||
|
check_vk_result(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplVulkan_CreateDescriptorSetLayout(VkDevice device, const VkAllocationCallbacks* allocator)
|
||||||
|
{
|
||||||
|
if (g_DescriptorSetLayout)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ImGui_ImplVulkan_CreateFontSampler(device, allocator);
|
||||||
|
VkSampler sampler[1] = { g_FontSampler };
|
||||||
|
VkDescriptorSetLayoutBinding binding[1] = {};
|
||||||
|
binding[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
|
binding[0].descriptorCount = 1;
|
||||||
|
binding[0].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||||
|
binding[0].pImmutableSamplers = sampler;
|
||||||
|
VkDescriptorSetLayoutCreateInfo info = {};
|
||||||
|
info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
||||||
|
info.bindingCount = 1;
|
||||||
|
info.pBindings = binding;
|
||||||
|
VkResult err = vkCreateDescriptorSetLayout(device, &info, allocator, &g_DescriptorSetLayout);
|
||||||
|
check_vk_result(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplVulkan_CreatePipelineLayout(VkDevice device, const VkAllocationCallbacks* allocator)
|
||||||
|
{
|
||||||
|
if (g_PipelineLayout)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Constants: we are using 'vec2 offset' and 'vec2 scale' instead of a full 3d projection matrix
|
||||||
|
ImGui_ImplVulkan_CreateDescriptorSetLayout(device, allocator);
|
||||||
|
VkPushConstantRange push_constants[1] = {};
|
||||||
|
push_constants[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||||
|
push_constants[0].offset = sizeof(float) * 0;
|
||||||
|
push_constants[0].size = sizeof(float) * 4;
|
||||||
|
VkDescriptorSetLayout set_layout[1] = { g_DescriptorSetLayout };
|
||||||
|
VkPipelineLayoutCreateInfo layout_info = {};
|
||||||
|
layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
||||||
|
layout_info.setLayoutCount = 1;
|
||||||
|
layout_info.pSetLayouts = set_layout;
|
||||||
|
layout_info.pushConstantRangeCount = 1;
|
||||||
|
layout_info.pPushConstantRanges = push_constants;
|
||||||
|
VkResult err = vkCreatePipelineLayout(device, &layout_info, allocator, &g_PipelineLayout);
|
||||||
|
check_vk_result(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAllocationCallbacks* allocator, VkPipelineCache pipelineCache, VkRenderPass renderPass, VkSampleCountFlagBits MSAASamples, VkPipeline* pipeline)
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_CreateShaderModules(device, allocator);
|
||||||
|
|
||||||
|
VkPipelineShaderStageCreateInfo stage[2] = {};
|
||||||
|
stage[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||||
|
stage[0].stage = VK_SHADER_STAGE_VERTEX_BIT;
|
||||||
|
stage[0].module = g_ShaderModuleVert;
|
||||||
|
stage[0].pName = "main";
|
||||||
|
stage[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||||
|
stage[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||||
|
stage[1].module = g_ShaderModuleFrag;
|
||||||
|
stage[1].pName = "main";
|
||||||
|
|
||||||
|
VkVertexInputBindingDescription binding_desc[1] = {};
|
||||||
|
binding_desc[0].stride = sizeof(ImDrawVert);
|
||||||
|
binding_desc[0].inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
|
||||||
|
|
||||||
|
VkVertexInputAttributeDescription attribute_desc[3] = {};
|
||||||
|
attribute_desc[0].location = 0;
|
||||||
|
attribute_desc[0].binding = binding_desc[0].binding;
|
||||||
|
attribute_desc[0].format = VK_FORMAT_R32G32_SFLOAT;
|
||||||
|
attribute_desc[0].offset = IM_OFFSETOF(ImDrawVert, pos);
|
||||||
|
attribute_desc[1].location = 1;
|
||||||
|
attribute_desc[1].binding = binding_desc[0].binding;
|
||||||
|
attribute_desc[1].format = VK_FORMAT_R32G32_SFLOAT;
|
||||||
|
attribute_desc[1].offset = IM_OFFSETOF(ImDrawVert, uv);
|
||||||
|
attribute_desc[2].location = 2;
|
||||||
|
attribute_desc[2].binding = binding_desc[0].binding;
|
||||||
|
attribute_desc[2].format = VK_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
attribute_desc[2].offset = IM_OFFSETOF(ImDrawVert, col);
|
||||||
|
|
||||||
|
VkPipelineVertexInputStateCreateInfo vertex_info = {};
|
||||||
|
vertex_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
|
||||||
|
vertex_info.vertexBindingDescriptionCount = 1;
|
||||||
|
vertex_info.pVertexBindingDescriptions = binding_desc;
|
||||||
|
vertex_info.vertexAttributeDescriptionCount = 3;
|
||||||
|
vertex_info.pVertexAttributeDescriptions = attribute_desc;
|
||||||
|
|
||||||
|
VkPipelineInputAssemblyStateCreateInfo ia_info = {};
|
||||||
|
ia_info.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
||||||
|
ia_info.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
||||||
|
|
||||||
|
VkPipelineViewportStateCreateInfo viewport_info = {};
|
||||||
|
viewport_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
|
||||||
|
viewport_info.viewportCount = 1;
|
||||||
|
viewport_info.scissorCount = 1;
|
||||||
|
|
||||||
|
VkPipelineRasterizationStateCreateInfo raster_info = {};
|
||||||
|
raster_info.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
|
||||||
|
raster_info.polygonMode = VK_POLYGON_MODE_FILL;
|
||||||
|
raster_info.cullMode = VK_CULL_MODE_NONE;
|
||||||
|
raster_info.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
|
||||||
|
raster_info.lineWidth = 1.0f;
|
||||||
|
|
||||||
|
VkPipelineMultisampleStateCreateInfo ms_info = {};
|
||||||
|
ms_info.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
||||||
|
ms_info.rasterizationSamples = (MSAASamples != 0) ? MSAASamples : VK_SAMPLE_COUNT_1_BIT;
|
||||||
|
|
||||||
|
VkPipelineColorBlendAttachmentState color_attachment[1] = {};
|
||||||
|
color_attachment[0].blendEnable = VK_TRUE;
|
||||||
|
color_attachment[0].srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
|
||||||
|
color_attachment[0].dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||||
|
color_attachment[0].colorBlendOp = VK_BLEND_OP_ADD;
|
||||||
|
color_attachment[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||||
|
color_attachment[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
|
||||||
|
color_attachment[0].alphaBlendOp = VK_BLEND_OP_ADD;
|
||||||
|
color_attachment[0].colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
||||||
|
|
||||||
|
VkPipelineDepthStencilStateCreateInfo depth_info = {};
|
||||||
|
depth_info.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
|
||||||
|
|
||||||
|
VkPipelineColorBlendStateCreateInfo blend_info = {};
|
||||||
|
blend_info.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
|
||||||
|
blend_info.attachmentCount = 1;
|
||||||
|
blend_info.pAttachments = color_attachment;
|
||||||
|
|
||||||
|
VkDynamicState dynamic_states[2] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
|
||||||
|
VkPipelineDynamicStateCreateInfo dynamic_state = {};
|
||||||
|
dynamic_state.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
|
||||||
|
dynamic_state.dynamicStateCount = (uint32_t)IM_ARRAYSIZE(dynamic_states);
|
||||||
|
dynamic_state.pDynamicStates = dynamic_states;
|
||||||
|
|
||||||
|
ImGui_ImplVulkan_CreatePipelineLayout(device, allocator);
|
||||||
|
|
||||||
|
VkGraphicsPipelineCreateInfo info = {};
|
||||||
|
info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
||||||
|
info.flags = g_PipelineCreateFlags;
|
||||||
|
info.stageCount = 2;
|
||||||
|
info.pStages = stage;
|
||||||
|
info.pVertexInputState = &vertex_info;
|
||||||
|
info.pInputAssemblyState = &ia_info;
|
||||||
|
info.pViewportState = &viewport_info;
|
||||||
|
info.pRasterizationState = &raster_info;
|
||||||
|
info.pMultisampleState = &ms_info;
|
||||||
|
info.pDepthStencilState = &depth_info;
|
||||||
|
info.pColorBlendState = &blend_info;
|
||||||
|
info.pDynamicState = &dynamic_state;
|
||||||
|
info.layout = g_PipelineLayout;
|
||||||
|
info.renderPass = renderPass;
|
||||||
|
VkResult err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &info, allocator, pipeline);
|
||||||
|
check_vk_result(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ImGui_ImplVulkan_CreateDeviceObjects()
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_InitInfo* v = &g_VulkanInitInfo;
|
||||||
|
VkResult err;
|
||||||
|
|
||||||
if (!g_FontSampler)
|
if (!g_FontSampler)
|
||||||
{
|
{
|
||||||
@ -671,108 +847,7 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
|||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPipelineShaderStageCreateInfo stage[2] = {};
|
ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, v->PipelineCache, g_RenderPass, v->MSAASamples, &g_Pipeline);
|
||||||
stage[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
|
||||||
stage[0].stage = VK_SHADER_STAGE_VERTEX_BIT;
|
|
||||||
stage[0].module = vert_module;
|
|
||||||
stage[0].pName = "main";
|
|
||||||
stage[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
|
||||||
stage[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
|
|
||||||
stage[1].module = frag_module;
|
|
||||||
stage[1].pName = "main";
|
|
||||||
|
|
||||||
VkVertexInputBindingDescription binding_desc[1] = {};
|
|
||||||
binding_desc[0].stride = sizeof(ImDrawVert);
|
|
||||||
binding_desc[0].inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
|
|
||||||
|
|
||||||
VkVertexInputAttributeDescription attribute_desc[3] = {};
|
|
||||||
attribute_desc[0].location = 0;
|
|
||||||
attribute_desc[0].binding = binding_desc[0].binding;
|
|
||||||
attribute_desc[0].format = VK_FORMAT_R32G32_SFLOAT;
|
|
||||||
attribute_desc[0].offset = IM_OFFSETOF(ImDrawVert, pos);
|
|
||||||
attribute_desc[1].location = 1;
|
|
||||||
attribute_desc[1].binding = binding_desc[0].binding;
|
|
||||||
attribute_desc[1].format = VK_FORMAT_R32G32_SFLOAT;
|
|
||||||
attribute_desc[1].offset = IM_OFFSETOF(ImDrawVert, uv);
|
|
||||||
attribute_desc[2].location = 2;
|
|
||||||
attribute_desc[2].binding = binding_desc[0].binding;
|
|
||||||
attribute_desc[2].format = VK_FORMAT_R8G8B8A8_UNORM;
|
|
||||||
attribute_desc[2].offset = IM_OFFSETOF(ImDrawVert, col);
|
|
||||||
|
|
||||||
VkPipelineVertexInputStateCreateInfo vertex_info = {};
|
|
||||||
vertex_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
|
|
||||||
vertex_info.vertexBindingDescriptionCount = 1;
|
|
||||||
vertex_info.pVertexBindingDescriptions = binding_desc;
|
|
||||||
vertex_info.vertexAttributeDescriptionCount = 3;
|
|
||||||
vertex_info.pVertexAttributeDescriptions = attribute_desc;
|
|
||||||
|
|
||||||
VkPipelineInputAssemblyStateCreateInfo ia_info = {};
|
|
||||||
ia_info.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
|
||||||
ia_info.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
|
||||||
|
|
||||||
VkPipelineViewportStateCreateInfo viewport_info = {};
|
|
||||||
viewport_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
|
|
||||||
viewport_info.viewportCount = 1;
|
|
||||||
viewport_info.scissorCount = 1;
|
|
||||||
|
|
||||||
VkPipelineRasterizationStateCreateInfo raster_info = {};
|
|
||||||
raster_info.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
|
|
||||||
raster_info.polygonMode = VK_POLYGON_MODE_FILL;
|
|
||||||
raster_info.cullMode = VK_CULL_MODE_NONE;
|
|
||||||
raster_info.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
|
|
||||||
raster_info.lineWidth = 1.0f;
|
|
||||||
|
|
||||||
VkPipelineMultisampleStateCreateInfo ms_info = {};
|
|
||||||
ms_info.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
|
||||||
if (v->MSAASamples != 0)
|
|
||||||
ms_info.rasterizationSamples = v->MSAASamples;
|
|
||||||
else
|
|
||||||
ms_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
|
|
||||||
|
|
||||||
VkPipelineColorBlendAttachmentState color_attachment[1] = {};
|
|
||||||
color_attachment[0].blendEnable = VK_TRUE;
|
|
||||||
color_attachment[0].srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
|
|
||||||
color_attachment[0].dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
|
||||||
color_attachment[0].colorBlendOp = VK_BLEND_OP_ADD;
|
|
||||||
color_attachment[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
|
||||||
color_attachment[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
|
|
||||||
color_attachment[0].alphaBlendOp = VK_BLEND_OP_ADD;
|
|
||||||
color_attachment[0].colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
|
||||||
|
|
||||||
VkPipelineDepthStencilStateCreateInfo depth_info = {};
|
|
||||||
depth_info.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
|
|
||||||
|
|
||||||
VkPipelineColorBlendStateCreateInfo blend_info = {};
|
|
||||||
blend_info.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
|
|
||||||
blend_info.attachmentCount = 1;
|
|
||||||
blend_info.pAttachments = color_attachment;
|
|
||||||
|
|
||||||
VkDynamicState dynamic_states[2] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
|
|
||||||
VkPipelineDynamicStateCreateInfo dynamic_state = {};
|
|
||||||
dynamic_state.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
|
|
||||||
dynamic_state.dynamicStateCount = (uint32_t)IM_ARRAYSIZE(dynamic_states);
|
|
||||||
dynamic_state.pDynamicStates = dynamic_states;
|
|
||||||
|
|
||||||
VkGraphicsPipelineCreateInfo info = {};
|
|
||||||
info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
|
||||||
info.flags = g_PipelineCreateFlags;
|
|
||||||
info.stageCount = 2;
|
|
||||||
info.pStages = stage;
|
|
||||||
info.pVertexInputState = &vertex_info;
|
|
||||||
info.pInputAssemblyState = &ia_info;
|
|
||||||
info.pViewportState = &viewport_info;
|
|
||||||
info.pRasterizationState = &raster_info;
|
|
||||||
info.pMultisampleState = &ms_info;
|
|
||||||
info.pDepthStencilState = &depth_info;
|
|
||||||
info.pColorBlendState = &blend_info;
|
|
||||||
info.pDynamicState = &dynamic_state;
|
|
||||||
info.layout = g_PipelineLayout;
|
|
||||||
info.renderPass = g_RenderPass;
|
|
||||||
err = vkCreateGraphicsPipelines(v->Device, v->PipelineCache, 1, &info, v->Allocator, &g_Pipeline);
|
|
||||||
check_vk_result(err);
|
|
||||||
|
|
||||||
vkDestroyShaderModule(v->Device, vert_module, v->Allocator);
|
|
||||||
vkDestroyShaderModule(v->Device, frag_module, v->Allocator);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -798,6 +873,8 @@ void ImGui_ImplVulkan_DestroyDeviceObjects()
|
|||||||
ImGui_ImplVulkanH_DestroyWindowRenderBuffers(v->Device, &g_MainWindowRenderBuffers, v->Allocator);
|
ImGui_ImplVulkanH_DestroyWindowRenderBuffers(v->Device, &g_MainWindowRenderBuffers, v->Allocator);
|
||||||
ImGui_ImplVulkan_DestroyFontUploadObjects();
|
ImGui_ImplVulkan_DestroyFontUploadObjects();
|
||||||
|
|
||||||
|
if (g_ShaderModuleVert) { vkDestroyShaderModule(v->Device, g_ShaderModuleVert, v->Allocator); g_ShaderModuleVert = VK_NULL_HANDLE; }
|
||||||
|
if (g_ShaderModuleFrag) { vkDestroyShaderModule(v->Device, g_ShaderModuleFrag, v->Allocator); g_ShaderModuleFrag = VK_NULL_HANDLE; }
|
||||||
if (g_FontView) { vkDestroyImageView(v->Device, g_FontView, v->Allocator); g_FontView = VK_NULL_HANDLE; }
|
if (g_FontView) { vkDestroyImageView(v->Device, g_FontView, v->Allocator); g_FontView = VK_NULL_HANDLE; }
|
||||||
if (g_FontImage) { vkDestroyImage(v->Device, g_FontImage, v->Allocator); g_FontImage = VK_NULL_HANDLE; }
|
if (g_FontImage) { vkDestroyImage(v->Device, g_FontImage, v->Allocator); g_FontImage = VK_NULL_HANDLE; }
|
||||||
if (g_FontMemory) { vkFreeMemory(v->Device, g_FontMemory, v->Allocator); g_FontMemory = VK_NULL_HANDLE; }
|
if (g_FontMemory) { vkFreeMemory(v->Device, g_FontMemory, v->Allocator); g_FontMemory = VK_NULL_HANDLE; }
|
||||||
@ -1017,6 +1094,8 @@ void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, V
|
|||||||
wd->ImageCount = 0;
|
wd->ImageCount = 0;
|
||||||
if (wd->RenderPass)
|
if (wd->RenderPass)
|
||||||
vkDestroyRenderPass(device, wd->RenderPass, allocator);
|
vkDestroyRenderPass(device, wd->RenderPass, allocator);
|
||||||
|
if (wd->Pipeline)
|
||||||
|
vkDestroyPipeline(device, wd->Pipeline, allocator);
|
||||||
|
|
||||||
// If min image count was not specified, request different count of images dependent on selected present mode
|
// If min image count was not specified, request different count of images dependent on selected present mode
|
||||||
if (min_image_count == 0)
|
if (min_image_count == 0)
|
||||||
@ -1112,6 +1191,10 @@ void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, V
|
|||||||
info.pDependencies = &dependency;
|
info.pDependencies = &dependency;
|
||||||
err = vkCreateRenderPass(device, &info, allocator, &wd->RenderPass);
|
err = vkCreateRenderPass(device, &info, allocator, &wd->RenderPass);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
|
|
||||||
|
// We do not create a pipeline by default as this is also used by examples' main.cpp,
|
||||||
|
// but secondary viewport in multi-viewport mode may want to create one with:
|
||||||
|
//ImGui_ImplVulkan_CreatePipeline(device, allocator, VK_NULL_HANDLE, wd->RenderPass, VK_SAMPLE_COUNT_1_BIT, &wd->Pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create The Image Views
|
// Create The Image Views
|
||||||
@ -1178,6 +1261,7 @@ void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui
|
|||||||
IM_FREE(wd->FrameSemaphores);
|
IM_FREE(wd->FrameSemaphores);
|
||||||
wd->Frames = NULL;
|
wd->Frames = NULL;
|
||||||
wd->FrameSemaphores = NULL;
|
wd->FrameSemaphores = NULL;
|
||||||
|
vkDestroyPipeline(device, wd->Pipeline, allocator);
|
||||||
vkDestroyRenderPass(device, wd->RenderPass, allocator);
|
vkDestroyRenderPass(device, wd->RenderPass, allocator);
|
||||||
vkDestroySwapchainKHR(device, wd->Swapchain, allocator);
|
vkDestroySwapchainKHR(device, wd->Swapchain, allocator);
|
||||||
vkDestroySurfaceKHR(instance, wd->Surface, allocator);
|
vkDestroySurfaceKHR(instance, wd->Surface, allocator);
|
||||||
|
@ -46,7 +46,7 @@ struct ImGui_ImplVulkan_InitInfo
|
|||||||
IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass);
|
IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass);
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer);
|
IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline = VK_NULL_HANDLE);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer);
|
IMGUI_IMPL_API bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer);
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_DestroyFontUploadObjects();
|
IMGUI_IMPL_API void ImGui_ImplVulkan_DestroyFontUploadObjects();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
|
IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
|
||||||
@ -108,6 +108,7 @@ struct ImGui_ImplVulkanH_Window
|
|||||||
VkSurfaceFormatKHR SurfaceFormat;
|
VkSurfaceFormatKHR SurfaceFormat;
|
||||||
VkPresentModeKHR PresentMode;
|
VkPresentModeKHR PresentMode;
|
||||||
VkRenderPass RenderPass;
|
VkRenderPass RenderPass;
|
||||||
|
VkPipeline Pipeline; // The window pipeline may uses a different VkRenderPass than the one passed in ImGui_ImplVulkan_InitInfo
|
||||||
bool ClearEnable;
|
bool ClearEnable;
|
||||||
VkClearValue ClearValue;
|
VkClearValue ClearValue;
|
||||||
uint32_t FrameIndex; // Current frame being rendered to (0 <= FrameIndex < FrameInFlightCount)
|
uint32_t FrameIndex; // Current frame being rendered to (0 <= FrameIndex < FrameInFlightCount)
|
||||||
|
@ -63,9 +63,9 @@ static bool g_WantUpdateHasGamepad = true;
|
|||||||
// Functions
|
// Functions
|
||||||
bool ImGui_ImplWin32_Init(void* hwnd)
|
bool ImGui_ImplWin32_Init(void* hwnd)
|
||||||
{
|
{
|
||||||
if (!::QueryPerformanceFrequency((LARGE_INTEGER *)&g_TicksPerSecond))
|
if (!::QueryPerformanceFrequency((LARGE_INTEGER*)&g_TicksPerSecond))
|
||||||
return false;
|
return false;
|
||||||
if (!::QueryPerformanceCounter((LARGE_INTEGER *)&g_Time))
|
if (!::QueryPerformanceCounter((LARGE_INTEGER*)&g_Time))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Setup back-end capabilities flags
|
// Setup back-end capabilities flags
|
||||||
@ -223,7 +223,7 @@ void ImGui_ImplWin32_NewFrame()
|
|||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
INT64 current_time;
|
INT64 current_time;
|
||||||
::QueryPerformanceCounter((LARGE_INTEGER *)¤t_time);
|
::QueryPerformanceCounter((LARGE_INTEGER*)¤t_time);
|
||||||
io.DeltaTime = (float)(current_time - g_Time) / g_TicksPerSecond;
|
io.DeltaTime = (float)(current_time - g_Time) / g_TicksPerSecond;
|
||||||
g_Time = current_time;
|
g_Time = current_time;
|
||||||
|
|
||||||
|
@ -3,10 +3,11 @@
|
|||||||
// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
|
// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
|
||||||
// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
|
// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/branch with your modifications to imconfig.h)
|
// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it)
|
||||||
// B) or add configuration directives in your own file and compile with #define IMGUI_USER_CONFIG "myfilename.h"
|
// B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template.
|
||||||
// If you do so you need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include
|
//-----------------------------------------------------------------------------
|
||||||
// the imgui*.cpp files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
|
// You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp
|
||||||
|
// files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
|
||||||
// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
|
// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
|
||||||
// Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using.
|
// Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
310
imgui.h
310
imgui.h
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.77
|
// dear imgui, v1.79
|
||||||
// (headers)
|
// (headers)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@ -11,7 +11,7 @@
|
|||||||
// - FAQ http://dearimgui.org/faq
|
// - FAQ http://dearimgui.org/faq
|
||||||
// - Homepage & latest https://github.com/ocornut/imgui
|
// - Homepage & latest https://github.com/ocornut/imgui
|
||||||
// - Releases & changelog https://github.com/ocornut/imgui/releases
|
// - Releases & changelog https://github.com/ocornut/imgui/releases
|
||||||
// - Gallery https://github.com/ocornut/imgui/issues/3075 (please post your screenshots/video there!)
|
// - Gallery https://github.com/ocornut/imgui/issues/3488 (please post your screenshots/video there!)
|
||||||
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
||||||
// - Wiki https://github.com/ocornut/imgui/wiki
|
// - Wiki https://github.com/ocornut/imgui/wiki
|
||||||
// - Issues & support https://github.com/ocornut/imgui/issues
|
// - Issues & support https://github.com/ocornut/imgui/issues
|
||||||
@ -59,8 +59,8 @@ Index of this file:
|
|||||||
|
|
||||||
// Version
|
// Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
||||||
#define IMGUI_VERSION "1.77"
|
#define IMGUI_VERSION "1.79"
|
||||||
#define IMGUI_VERSION_NUM 17700
|
#define IMGUI_VERSION_NUM 17900
|
||||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
||||||
|
|
||||||
// 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)
|
||||||
@ -151,8 +151,9 @@ typedef int ImGuiMouseCursor; // -> enum ImGuiMouseCursor_ // Enum: A
|
|||||||
typedef int ImGuiStyleVar; // -> enum ImGuiStyleVar_ // Enum: A variable identifier for styling
|
typedef int ImGuiStyleVar; // -> enum ImGuiStyleVar_ // Enum: A variable identifier for styling
|
||||||
typedef int ImDrawCornerFlags; // -> enum ImDrawCornerFlags_ // Flags: for ImDrawList::AddRect(), AddRectFilled() etc.
|
typedef int ImDrawCornerFlags; // -> enum ImDrawCornerFlags_ // Flags: for ImDrawList::AddRect(), AddRectFilled() etc.
|
||||||
typedef int ImDrawListFlags; // -> enum ImDrawListFlags_ // Flags: for ImDrawList
|
typedef int ImDrawListFlags; // -> enum ImDrawListFlags_ // Flags: for ImDrawList
|
||||||
typedef int ImFontAtlasFlags; // -> enum ImFontAtlasFlags_ // Flags: for ImFontAtlas
|
typedef int ImFontAtlasFlags; // -> enum ImFontAtlasFlags_ // Flags: for ImFontAtlas build
|
||||||
typedef int ImGuiBackendFlags; // -> enum ImGuiBackendFlags_ // Flags: for io.BackendFlags
|
typedef int ImGuiBackendFlags; // -> enum ImGuiBackendFlags_ // Flags: for io.BackendFlags
|
||||||
|
typedef int ImGuiButtonFlags; // -> enum ImGuiButtonFlags_ // Flags: for InvisibleButton()
|
||||||
typedef int ImGuiColorEditFlags; // -> enum ImGuiColorEditFlags_ // Flags: for ColorEdit4(), ColorPicker4() etc.
|
typedef int ImGuiColorEditFlags; // -> enum ImGuiColorEditFlags_ // Flags: for ColorEdit4(), ColorPicker4() etc.
|
||||||
typedef int ImGuiConfigFlags; // -> enum ImGuiConfigFlags_ // Flags: for io.ConfigFlags
|
typedef int ImGuiConfigFlags; // -> enum ImGuiConfigFlags_ // Flags: for io.ConfigFlags
|
||||||
typedef int ImGuiComboFlags; // -> enum ImGuiComboFlags_ // Flags: for BeginCombo()
|
typedef int ImGuiComboFlags; // -> enum ImGuiComboFlags_ // Flags: for BeginCombo()
|
||||||
@ -163,6 +164,7 @@ typedef int ImGuiInputTextFlags; // -> enum ImGuiInputTextFlags_ // Flags: f
|
|||||||
typedef int ImGuiKeyModFlags; // -> enum ImGuiKeyModFlags_ // Flags: for io.KeyMods (Ctrl/Shift/Alt/Super)
|
typedef int ImGuiKeyModFlags; // -> enum ImGuiKeyModFlags_ // Flags: for io.KeyMods (Ctrl/Shift/Alt/Super)
|
||||||
typedef int ImGuiPopupFlags; // -> enum ImGuiPopupFlags_ // Flags: for OpenPopup*(), BeginPopupContext*(), IsPopupOpen()
|
typedef int ImGuiPopupFlags; // -> enum ImGuiPopupFlags_ // Flags: for OpenPopup*(), BeginPopupContext*(), IsPopupOpen()
|
||||||
typedef int ImGuiSelectableFlags; // -> enum ImGuiSelectableFlags_ // Flags: for Selectable()
|
typedef int ImGuiSelectableFlags; // -> enum ImGuiSelectableFlags_ // Flags: for Selectable()
|
||||||
|
typedef int ImGuiSliderFlags; // -> enum ImGuiSliderFlags_ // Flags: for DragFloat(), DragInt(), SliderFloat(), SliderInt() etc.
|
||||||
typedef int ImGuiTabBarFlags; // -> enum ImGuiTabBarFlags_ // Flags: for BeginTabBar()
|
typedef int ImGuiTabBarFlags; // -> enum ImGuiTabBarFlags_ // Flags: for BeginTabBar()
|
||||||
typedef int ImGuiTabItemFlags; // -> enum ImGuiTabItemFlags_ // Flags: for BeginTabItem()
|
typedef int ImGuiTabItemFlags; // -> enum ImGuiTabItemFlags_ // Flags: for BeginTabItem()
|
||||||
typedef int ImGuiTreeNodeFlags; // -> enum ImGuiTreeNodeFlags_ // Flags: for TreeNode(), TreeNodeEx(), CollapsingHeader()
|
typedef int ImGuiTreeNodeFlags; // -> enum ImGuiTreeNodeFlags_ // Flags: for TreeNode(), TreeNodeEx(), CollapsingHeader()
|
||||||
@ -173,7 +175,7 @@ typedef int ImGuiWindowFlags; // -> enum ImGuiWindowFlags_ // Flags: f
|
|||||||
typedef void* ImTextureID; // User data for rendering back-end to identify a texture. This is whatever to you want it to be! read the FAQ about ImTextureID for details.
|
typedef void* ImTextureID; // User data for rendering back-end to identify a texture. This is whatever to you want it to be! read the FAQ about ImTextureID for details.
|
||||||
#endif
|
#endif
|
||||||
typedef unsigned int ImGuiID; // A unique ID used by widgets, typically hashed from a stack of string.
|
typedef unsigned int ImGuiID; // A unique ID used by widgets, typically hashed from a stack of string.
|
||||||
typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData *data);
|
typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData* data);
|
||||||
typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data);
|
typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data);
|
||||||
|
|
||||||
// Decoded character types
|
// Decoded character types
|
||||||
@ -332,8 +334,8 @@ namespace ImGui
|
|||||||
// Windows Scrolling
|
// Windows Scrolling
|
||||||
IMGUI_API float GetScrollX(); // get scrolling amount [0..GetScrollMaxX()]
|
IMGUI_API float GetScrollX(); // get scrolling amount [0..GetScrollMaxX()]
|
||||||
IMGUI_API float GetScrollY(); // get scrolling amount [0..GetScrollMaxY()]
|
IMGUI_API float GetScrollY(); // get scrolling amount [0..GetScrollMaxY()]
|
||||||
IMGUI_API float GetScrollMaxX(); // get maximum scrolling amount ~~ ContentSize.X - WindowSize.X
|
IMGUI_API float GetScrollMaxX(); // get maximum scrolling amount ~~ ContentSize.x - WindowSize.x
|
||||||
IMGUI_API float GetScrollMaxY(); // get maximum scrolling amount ~~ ContentSize.Y - WindowSize.Y
|
IMGUI_API float GetScrollMaxY(); // get maximum scrolling amount ~~ ContentSize.y - WindowSize.y
|
||||||
IMGUI_API void SetScrollX(float scroll_x); // set scrolling amount [0..GetScrollMaxX()]
|
IMGUI_API void SetScrollX(float scroll_x); // set scrolling amount [0..GetScrollMaxX()]
|
||||||
IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0..GetScrollMaxY()]
|
IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0..GetScrollMaxY()]
|
||||||
IMGUI_API void SetScrollHereX(float center_x_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_x_ratio=0.0: left, 0.5: center, 1.0: right. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead.
|
IMGUI_API void SetScrollHereX(float center_x_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_x_ratio=0.0: left, 0.5: center, 1.0: right. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead.
|
||||||
@ -437,7 +439,7 @@ namespace ImGui
|
|||||||
// - You may also use one of the many IsItemXXX functions (e.g. IsItemActive, IsItemHovered, etc.) to query widget state.
|
// - You may also use one of the many IsItemXXX functions (e.g. IsItemActive, IsItemHovered, etc.) to query widget state.
|
||||||
IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0, 0)); // button
|
IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0, 0)); // button
|
||||||
IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed within text
|
IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed within text
|
||||||
IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size); // button behavior without the visuals, frequently useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.)
|
IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size, ImGuiButtonFlags flags = 0); // flexible button behavior without the visuals, frequently useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.)
|
||||||
IMGUI_API bool ArrowButton(const char* str_id, ImGuiDir dir); // square button with an arrow shape
|
IMGUI_API bool ArrowButton(const char* str_id, ImGuiDir dir); // square button with an arrow shape
|
||||||
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
|
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
|
||||||
IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding
|
IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding
|
||||||
@ -446,7 +448,7 @@ namespace ImGui
|
|||||||
IMGUI_API bool RadioButton(const char* label, bool active); // use with e.g. if (RadioButton("one", my_value==1)) { my_value = 1; }
|
IMGUI_API bool RadioButton(const char* label, bool active); // use with e.g. if (RadioButton("one", my_value==1)) { my_value = 1; }
|
||||||
IMGUI_API bool RadioButton(const char* label, int* v, int v_button); // shortcut to handle the above pattern when value is an integer
|
IMGUI_API bool RadioButton(const char* label, int* v, int v_button); // shortcut to handle the above pattern when value is an integer
|
||||||
IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-1, 0), const char* overlay = NULL);
|
IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-1, 0), const char* overlay = NULL);
|
||||||
IMGUI_API void Bullet(); // draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses
|
IMGUI_API void Bullet(); // draw a small circle + keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses
|
||||||
|
|
||||||
// Widgets: Combo Box
|
// Widgets: Combo Box
|
||||||
// - The BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items.
|
// - The BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items.
|
||||||
@ -457,44 +459,50 @@ namespace ImGui
|
|||||||
IMGUI_API bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_max_height_in_items = -1); // Separate items with \0 within a string, end item-list with \0\0. e.g. "One\0Two\0Three\0"
|
IMGUI_API bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_max_height_in_items = -1); // Separate items with \0 within a string, end item-list with \0\0. e.g. "One\0Two\0Three\0"
|
||||||
IMGUI_API bool Combo(const char* label, int* current_item, bool(*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int popup_max_height_in_items = -1);
|
IMGUI_API bool Combo(const char* label, int* current_item, bool(*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int popup_max_height_in_items = -1);
|
||||||
|
|
||||||
// Widgets: Drags
|
// Widgets: Drag Sliders
|
||||||
// - CTRL+Click on any drag box to turn them into an input box. Manually input values aren't clamped and can go off-bounds.
|
// - CTRL+Click on any drag box to turn them into an input box. Manually input values aren't clamped and can go off-bounds.
|
||||||
// - For all the Float2/Float3/Float4/Int2/Int3/Int4 versions of every functions, note that a 'float v[X]' function argument is the same as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. You can pass address of your first element out of a contiguous set, e.g. &myvector.x
|
// - For all the Float2/Float3/Float4/Int2/Int3/Int4 versions of every functions, note that a 'float v[X]' function argument is the same as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. You can pass address of your first element out of a contiguous set, e.g. &myvector.x
|
||||||
// - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc.
|
// - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc.
|
||||||
|
// - Format string may also be set to NULL or use the default format ("%f" or "%d").
|
||||||
// - Speed are per-pixel of mouse movement (v_speed=0.2f: mouse needs to move by 5 pixels to increase value by 1). For gamepad/keyboard navigation, minimum speed is Max(v_speed, minimum_step_at_given_precision).
|
// - Speed are per-pixel of mouse movement (v_speed=0.2f: mouse needs to move by 5 pixels to increase value by 1). For gamepad/keyboard navigation, minimum speed is Max(v_speed, minimum_step_at_given_precision).
|
||||||
// - Use v_min < v_max to clamp edits to given limits. Note that CTRL+Click manual input can override those limits.
|
// - Use v_min < v_max to clamp edits to given limits. Note that CTRL+Click manual input can override those limits.
|
||||||
// - Use v_max = FLT_MAX / INT_MAX etc to avoid clamping to a maximum, same with v_min = -FLT_MAX / INT_MIN to avoid clamping to a minimum.
|
// - Use v_max = FLT_MAX / INT_MAX etc to avoid clamping to a maximum, same with v_min = -FLT_MAX / INT_MIN to avoid clamping to a minimum.
|
||||||
// - Use v_min > v_max to lock edits.
|
// - We use the same sets of flags for DragXXX() and SliderXXX() functions as the features are the same and it makes it easier to swap them.
|
||||||
IMGUI_API bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", float power = 1.0f); // If v_min >= v_max we have no bound
|
// - Legacy: Pre-1.78 there are DragXXX() function signatures that takes a final `float power=1.0f' argument instead of the `ImGuiSliderFlags flags=0' argument.
|
||||||
IMGUI_API bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", float power = 1.0f);
|
// If you get a warning converting a float to ImGuiSliderFlags, read https://github.com/ocornut/imgui/issues/3361
|
||||||
IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", float power = 1.0f);
|
IMGUI_API bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound
|
||||||
IMGUI_API bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", float power = 1.0f);
|
IMGUI_API bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||||
IMGUI_API bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", const char* format_max = NULL, float power = 1.0f);
|
IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||||
IMGUI_API bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d"); // If v_min >= v_max we have no bound
|
IMGUI_API bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||||
IMGUI_API bool DragInt2(const char* label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d");
|
IMGUI_API bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", const char* format_max = NULL, ImGuiSliderFlags flags = 0);
|
||||||
IMGUI_API bool DragInt3(const char* label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d");
|
IMGUI_API bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound
|
||||||
IMGUI_API bool DragInt4(const char* label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d");
|
IMGUI_API bool DragInt2(const char* label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0);
|
||||||
IMGUI_API bool DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", const char* format_max = NULL);
|
IMGUI_API bool DragInt3(const char* label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0);
|
||||||
IMGUI_API bool DragScalar(const char* label, ImGuiDataType data_type, void* p_data, float v_speed, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, float power = 1.0f);
|
IMGUI_API bool DragInt4(const char* label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0);
|
||||||
IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, float power = 1.0f);
|
IMGUI_API bool DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", const char* format_max = NULL, ImGuiSliderFlags flags = 0);
|
||||||
|
IMGUI_API bool DragScalar(const char* label, ImGuiDataType data_type, void* p_data, float v_speed, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, ImGuiSliderFlags flags = 0);
|
||||||
|
IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, ImGuiSliderFlags flags = 0);
|
||||||
|
|
||||||
// Widgets: Sliders
|
// Widgets: Regular Sliders
|
||||||
// - CTRL+Click on any slider to turn them into an input box. Manually input values aren't clamped and can go off-bounds.
|
// - CTRL+Click on any slider to turn them into an input box. Manually input values aren't clamped and can go off-bounds.
|
||||||
// - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc.
|
// - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc.
|
||||||
IMGUI_API bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); // adjust format to decorate the value with a prefix or a suffix for in-slider labels or unit display. Use power!=1.0 for power curve sliders
|
// - Format string may also be set to NULL or use the default format ("%f" or "%d").
|
||||||
IMGUI_API bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f);
|
// - Legacy: Pre-1.78 there are SliderXXX() function signatures that takes a final `float power=1.0f' argument instead of the `ImGuiSliderFlags flags=0' argument.
|
||||||
IMGUI_API bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f);
|
// If you get a warning converting a float to ImGuiSliderFlags, read https://github.com/ocornut/imgui/issues/3361
|
||||||
IMGUI_API bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f);
|
IMGUI_API bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // adjust format to decorate the value with a prefix or a suffix for in-slider labels or unit display.
|
||||||
IMGUI_API bool SliderAngle(const char* label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f, const char* format = "%.0f deg");
|
IMGUI_API bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||||
IMGUI_API bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* format = "%d");
|
IMGUI_API bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||||
IMGUI_API bool SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format = "%d");
|
IMGUI_API bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||||
IMGUI_API bool SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format = "%d");
|
IMGUI_API bool SliderAngle(const char* label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f, const char* format = "%.0f deg", ImGuiSliderFlags flags = 0);
|
||||||
IMGUI_API bool SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format = "%d");
|
IMGUI_API bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0);
|
||||||
IMGUI_API bool SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, float power = 1.0f);
|
IMGUI_API bool SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0);
|
||||||
IMGUI_API bool SliderScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_min, const void* p_max, const char* format = NULL, float power = 1.0f);
|
IMGUI_API bool SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0);
|
||||||
IMGUI_API bool VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f);
|
IMGUI_API bool SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0);
|
||||||
IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format = "%d");
|
IMGUI_API bool SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0);
|
||||||
IMGUI_API bool VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, float power = 1.0f);
|
IMGUI_API bool SliderScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0);
|
||||||
|
IMGUI_API bool VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||||
|
IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0);
|
||||||
|
IMGUI_API bool VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0);
|
||||||
|
|
||||||
// Widgets: Input with Keyboard
|
// Widgets: Input with Keyboard
|
||||||
// - If you want to use InputText() with std::string or any custom dynamic string type, see misc/cpp/imgui_stdlib.h and comments in imgui_demo.cpp.
|
// - If you want to use InputText() with std::string or any custom dynamic string type, see misc/cpp/imgui_stdlib.h and comments in imgui_demo.cpp.
|
||||||
@ -612,13 +620,13 @@ namespace ImGui
|
|||||||
// - CloseCurrentPopup() is called by default by Selectable()/MenuItem() when activated (FIXME: need some options).
|
// - CloseCurrentPopup() is called by default by Selectable()/MenuItem() when activated (FIXME: need some options).
|
||||||
// - Use ImGuiPopupFlags_NoOpenOverExistingPopup to avoid opening a popup if there's already one at the same level. This is equivalent to e.g. testing for !IsAnyPopupOpen() prior to OpenPopup().
|
// - Use ImGuiPopupFlags_NoOpenOverExistingPopup to avoid opening a popup if there's already one at the same level. This is equivalent to e.g. testing for !IsAnyPopupOpen() prior to OpenPopup().
|
||||||
IMGUI_API void OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags = 0); // call to mark popup as open (don't call every frame!).
|
IMGUI_API void OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags = 0); // call to mark popup as open (don't call every frame!).
|
||||||
IMGUI_API bool OpenPopupContextItem(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
|
IMGUI_API void OpenPopupOnItemClick(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
|
||||||
IMGUI_API void CloseCurrentPopup(); // manually close the popup we have begin-ed into.
|
IMGUI_API void CloseCurrentPopup(); // manually close the popup we have begin-ed into.
|
||||||
// Popups: open+begin combined functions helpers
|
// Popups: open+begin combined functions helpers
|
||||||
// - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking.
|
// - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking.
|
||||||
// - They are convenient to easily create context menus, hence the name.
|
// - They are convenient to easily create context menus, hence the name.
|
||||||
// - IMPORTANT: Notice that BeginPopupContextXXX takes ImGuiPopupFlags just like OpenPopup() and unlike BeginPopup(). For full consistency, we may add ImGuiWindowFlags to the BeginPopupContextXXX functions in the future.
|
// - IMPORTANT: Notice that BeginPopupContextXXX takes ImGuiPopupFlags just like OpenPopup() and unlike BeginPopup(). For full consistency, we may add ImGuiWindowFlags to the BeginPopupContextXXX functions in the future.
|
||||||
// - We exceptionally default their flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter. Passing a mouse button to ImGuiPopupFlags is guaranteed to be legal.
|
// - IMPORTANT: we exceptionally default their flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter, so if you add other flags remember to re-add the ImGuiPopupFlags_MouseButtonRight.
|
||||||
IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
|
IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
|
||||||
IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1);// open+begin popup when clicked on current window.
|
IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1);// open+begin popup when clicked on current window.
|
||||||
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked in void (where there are no windows).
|
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked in void (where there are no windows).
|
||||||
@ -645,8 +653,9 @@ namespace ImGui
|
|||||||
// Tab Bars, Tabs
|
// Tab Bars, Tabs
|
||||||
IMGUI_API bool BeginTabBar(const char* str_id, ImGuiTabBarFlags flags = 0); // create and append into a TabBar
|
IMGUI_API bool BeginTabBar(const char* str_id, ImGuiTabBarFlags flags = 0); // create and append into a TabBar
|
||||||
IMGUI_API void EndTabBar(); // only call EndTabBar() if BeginTabBar() returns true!
|
IMGUI_API void EndTabBar(); // only call EndTabBar() if BeginTabBar() returns true!
|
||||||
IMGUI_API bool BeginTabItem(const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0);// create a Tab. Returns true if the Tab is selected.
|
IMGUI_API bool BeginTabItem(const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0); // create a Tab. Returns true if the Tab is selected.
|
||||||
IMGUI_API void EndTabItem(); // only call EndTabItem() if BeginTabItem() returns true!
|
IMGUI_API void EndTabItem(); // only call EndTabItem() if BeginTabItem() returns true!
|
||||||
|
IMGUI_API bool TabItemButton(const char* label, ImGuiTabItemFlags flags = 0); // create a Tab behaving like a button. return true when clicked. cannot be selected in the tab bar.
|
||||||
IMGUI_API void SetTabItemClosed(const char* tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name.
|
IMGUI_API void SetTabItemClosed(const char* tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name.
|
||||||
|
|
||||||
// Logging/Capture
|
// Logging/Capture
|
||||||
@ -724,7 +733,7 @@ namespace ImGui
|
|||||||
IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
|
IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
|
||||||
|
|
||||||
// Inputs Utilities: Keyboard
|
// Inputs Utilities: Keyboard
|
||||||
// - For 'int user_key_index' you can use your own indices/enums according to how your backend/engine stored them in io.KeysDown[].
|
// - For 'int user_key_index' you can use your own indices/enums according to how your back-end/engine stored them in io.KeysDown[].
|
||||||
// - We don't know the meaning of those value. You can use GetKeyIndex() to map a ImGuiKey_ value into the user index.
|
// - We don't know the meaning of those value. You can use GetKeyIndex() to map a ImGuiKey_ value into the user index.
|
||||||
IMGUI_API int GetKeyIndex(ImGuiKey imgui_key); // map ImGuiKey_* values into user's key index. == io.KeyMap[key]
|
IMGUI_API int GetKeyIndex(ImGuiKey imgui_key); // map ImGuiKey_* values into user's key index. == io.KeyMap[key]
|
||||||
IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index].
|
IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index].
|
||||||
@ -740,7 +749,7 @@ namespace ImGui
|
|||||||
IMGUI_API bool IsMouseDown(ImGuiMouseButton button); // is mouse button held?
|
IMGUI_API bool IsMouseDown(ImGuiMouseButton button); // is mouse button held?
|
||||||
IMGUI_API bool IsMouseClicked(ImGuiMouseButton button, bool repeat = false); // did mouse button clicked? (went from !Down to Down)
|
IMGUI_API bool IsMouseClicked(ImGuiMouseButton button, bool repeat = false); // did mouse button clicked? (went from !Down to Down)
|
||||||
IMGUI_API bool IsMouseReleased(ImGuiMouseButton button); // did mouse button released? (went from Down to !Down)
|
IMGUI_API bool IsMouseReleased(ImGuiMouseButton button); // did mouse button released? (went from Down to !Down)
|
||||||
IMGUI_API bool IsMouseDoubleClicked(ImGuiMouseButton button); // did mouse button double-clicked? a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime.
|
IMGUI_API bool IsMouseDoubleClicked(ImGuiMouseButton button); // did mouse button double-clicked? (note that a double-click will also report IsMouseClicked() == true)
|
||||||
IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true);// is mouse hovering given bounding rect (in screen space). clipped by current clipping settings, but disregarding of other consideration of focus/window ordering/popup-block.
|
IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true);// is mouse hovering given bounding rect (in screen space). clipped by current clipping settings, but disregarding of other consideration of focus/window ordering/popup-block.
|
||||||
IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); // by convention we use (-FLT_MAX,-FLT_MAX) to denote that there is no mouse available
|
IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); // by convention we use (-FLT_MAX,-FLT_MAX) to denote that there is no mouse available
|
||||||
IMGUI_API bool IsAnyMouseDown(); // is any mouse button held?
|
IMGUI_API bool IsAnyMouseDown(); // is any mouse button held?
|
||||||
@ -846,6 +855,7 @@ enum ImGuiInputTextFlags_
|
|||||||
ImGuiInputTextFlags_NoUndoRedo = 1 << 16, // Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID().
|
ImGuiInputTextFlags_NoUndoRedo = 1 << 16, // Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID().
|
||||||
ImGuiInputTextFlags_CharsScientific = 1 << 17, // Allow 0123456789.+-*/eE (Scientific notation input)
|
ImGuiInputTextFlags_CharsScientific = 1 << 17, // Allow 0123456789.+-*/eE (Scientific notation input)
|
||||||
ImGuiInputTextFlags_CallbackResize = 1 << 18, // Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. Notify when the string wants to be resized (for string types which hold a cache of their Size). You will be provided a new BufSize in the callback and NEED to honor it. (see misc/cpp/imgui_stdlib.h for an example of using this)
|
ImGuiInputTextFlags_CallbackResize = 1 << 18, // Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. Notify when the string wants to be resized (for string types which hold a cache of their Size). You will be provided a new BufSize in the callback and NEED to honor it. (see misc/cpp/imgui_stdlib.h for an example of using this)
|
||||||
|
ImGuiInputTextFlags_CallbackEdit = 1 << 19, // Callback on any edit (note that InputText() already returns true on edit, the callback is useful mainly to manipulate the underlying buffer while focus is active)
|
||||||
// [Internal]
|
// [Internal]
|
||||||
ImGuiInputTextFlags_Multiline = 1 << 20, // For internal use by InputTextMultiline()
|
ImGuiInputTextFlags_Multiline = 1 << 20, // For internal use by InputTextMultiline()
|
||||||
ImGuiInputTextFlags_NoMarkEdited = 1 << 21 // For internal use by functions using InputText() before reformatting data
|
ImGuiInputTextFlags_NoMarkEdited = 1 << 21 // For internal use by functions using InputText() before reformatting data
|
||||||
@ -878,12 +888,15 @@ enum ImGuiTreeNodeFlags_
|
|||||||
// small flags values as a mouse button index, so we encode the mouse button in the first few bits of the flags.
|
// small flags values as a mouse button index, so we encode the mouse button in the first few bits of the flags.
|
||||||
// It is therefore guaranteed to be legal to pass a mouse button index in ImGuiPopupFlags.
|
// It is therefore guaranteed to be legal to pass a mouse button index in ImGuiPopupFlags.
|
||||||
// - For the same reason, we exceptionally default the ImGuiPopupFlags argument of BeginPopupContextXXX functions to 1 instead of 0.
|
// - For the same reason, we exceptionally default the ImGuiPopupFlags argument of BeginPopupContextXXX functions to 1 instead of 0.
|
||||||
|
// IMPORTANT: because the default parameter is 1 (==ImGuiPopupFlags_MouseButtonRight), if you rely on the default parameter
|
||||||
|
// and want to another another flag, you need to pass in the ImGuiPopupFlags_MouseButtonRight flag.
|
||||||
|
// - Multiple buttons currently cannot be combined/or-ed in those functions (we could allow it later).
|
||||||
enum ImGuiPopupFlags_
|
enum ImGuiPopupFlags_
|
||||||
{
|
{
|
||||||
ImGuiPopupFlags_None = 0,
|
ImGuiPopupFlags_None = 0,
|
||||||
ImGuiPopupFlags_MouseButtonLeft = 0, // For BeginPopupContext*(): open on Left Mouse release. Guaranted to always be == 0 (same as ImGuiMouseButton_Left)
|
ImGuiPopupFlags_MouseButtonLeft = 0, // For BeginPopupContext*(): open on Left Mouse release. Guaranteed to always be == 0 (same as ImGuiMouseButton_Left)
|
||||||
ImGuiPopupFlags_MouseButtonRight = 1, // For BeginPopupContext*(): open on Right Mouse release. Guaranted to always be == 1 (same as ImGuiMouseButton_Right)
|
ImGuiPopupFlags_MouseButtonRight = 1, // For BeginPopupContext*(): open on Right Mouse release. Guaranteed to always be == 1 (same as ImGuiMouseButton_Right)
|
||||||
ImGuiPopupFlags_MouseButtonMiddle = 2, // For BeginPopupContext*(): open on Middle Mouse release. Guaranted to always be == 2 (same as ImGuiMouseButton_Middle)
|
ImGuiPopupFlags_MouseButtonMiddle = 2, // For BeginPopupContext*(): open on Middle Mouse release. Guaranteed to always be == 2 (same as ImGuiMouseButton_Middle)
|
||||||
ImGuiPopupFlags_MouseButtonMask_ = 0x1F,
|
ImGuiPopupFlags_MouseButtonMask_ = 0x1F,
|
||||||
ImGuiPopupFlags_MouseButtonDefault_ = 1,
|
ImGuiPopupFlags_MouseButtonDefault_ = 1,
|
||||||
ImGuiPopupFlags_NoOpenOverExistingPopup = 1 << 5, // For OpenPopup*(), BeginPopupContext*(): don't open if there's already a popup at the same level of the popup stack
|
ImGuiPopupFlags_NoOpenOverExistingPopup = 1 << 5, // For OpenPopup*(), BeginPopupContext*(): don't open if there's already a popup at the same level of the popup stack
|
||||||
@ -942,7 +955,10 @@ enum ImGuiTabItemFlags_
|
|||||||
ImGuiTabItemFlags_SetSelected = 1 << 1, // Trigger flag to programmatically make the tab selected when calling BeginTabItem()
|
ImGuiTabItemFlags_SetSelected = 1 << 1, // Trigger flag to programmatically make the tab selected when calling BeginTabItem()
|
||||||
ImGuiTabItemFlags_NoCloseWithMiddleMouseButton = 1 << 2, // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false.
|
ImGuiTabItemFlags_NoCloseWithMiddleMouseButton = 1 << 2, // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false.
|
||||||
ImGuiTabItemFlags_NoPushId = 1 << 3, // Don't call PushID(tab->ID)/PopID() on BeginTabItem()/EndTabItem()
|
ImGuiTabItemFlags_NoPushId = 1 << 3, // Don't call PushID(tab->ID)/PopID() on BeginTabItem()/EndTabItem()
|
||||||
ImGuiTabItemFlags_NoTooltip = 1 << 4 // Disable tooltip for the given tab
|
ImGuiTabItemFlags_NoTooltip = 1 << 4, // Disable tooltip for the given tab
|
||||||
|
ImGuiTabItemFlags_NoReorder = 1 << 5, // Disable reordering this tab or having another tab cross over this tab
|
||||||
|
ImGuiTabItemFlags_Leading = 1 << 6, // Enforce the tab position to the left of the tab bar (after the tab list popup button)
|
||||||
|
ImGuiTabItemFlags_Trailing = 1 << 7 // Enforce the tab position to the right of the tab bar (before the scrolling buttons)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flags for ImGui::IsWindowFocused()
|
// Flags for ImGui::IsWindowFocused()
|
||||||
@ -1222,6 +1238,19 @@ enum ImGuiStyleVar_
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Flags for InvisibleButton() [extended in imgui_internal.h]
|
||||||
|
enum ImGuiButtonFlags_
|
||||||
|
{
|
||||||
|
ImGuiButtonFlags_None = 0,
|
||||||
|
ImGuiButtonFlags_MouseButtonLeft = 1 << 0, // React on left mouse button (default)
|
||||||
|
ImGuiButtonFlags_MouseButtonRight = 1 << 1, // React on right mouse button
|
||||||
|
ImGuiButtonFlags_MouseButtonMiddle = 1 << 2, // React on center mouse button
|
||||||
|
|
||||||
|
// [Internal]
|
||||||
|
ImGuiButtonFlags_MouseButtonMask_ = ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight | ImGuiButtonFlags_MouseButtonMiddle,
|
||||||
|
ImGuiButtonFlags_MouseButtonDefault_ = ImGuiButtonFlags_MouseButtonLeft
|
||||||
|
};
|
||||||
|
|
||||||
// Flags for ColorEdit3() / ColorEdit4() / ColorPicker3() / ColorPicker4() / ColorButton()
|
// Flags for ColorEdit3() / ColorEdit4() / ColorPicker3() / ColorPicker4() / ColorButton()
|
||||||
enum ImGuiColorEditFlags_
|
enum ImGuiColorEditFlags_
|
||||||
{
|
{
|
||||||
@ -1254,13 +1283,13 @@ enum ImGuiColorEditFlags_
|
|||||||
|
|
||||||
// Defaults Options. You can set application defaults using SetColorEditOptions(). The intent is that you probably don't want to
|
// Defaults Options. You can set application defaults using SetColorEditOptions(). The intent is that you probably don't want to
|
||||||
// override them in most of your calls. Let the user choose via the option menu and/or call SetColorEditOptions() once during startup.
|
// override them in most of your calls. Let the user choose via the option menu and/or call SetColorEditOptions() once during startup.
|
||||||
ImGuiColorEditFlags__OptionsDefault = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_DisplayRGB|ImGuiColorEditFlags_InputRGB|ImGuiColorEditFlags_PickerHueBar,
|
ImGuiColorEditFlags__OptionsDefault = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_PickerHueBar,
|
||||||
|
|
||||||
// [Internal] Masks
|
// [Internal] Masks
|
||||||
ImGuiColorEditFlags__DisplayMask = ImGuiColorEditFlags_DisplayRGB|ImGuiColorEditFlags_DisplayHSV|ImGuiColorEditFlags_DisplayHex,
|
ImGuiColorEditFlags__DisplayMask = ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_DisplayHex,
|
||||||
ImGuiColorEditFlags__DataTypeMask = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_Float,
|
ImGuiColorEditFlags__DataTypeMask = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_Float,
|
||||||
ImGuiColorEditFlags__PickerMask = ImGuiColorEditFlags_PickerHueWheel|ImGuiColorEditFlags_PickerHueBar,
|
ImGuiColorEditFlags__PickerMask = ImGuiColorEditFlags_PickerHueWheel | ImGuiColorEditFlags_PickerHueBar,
|
||||||
ImGuiColorEditFlags__InputMask = ImGuiColorEditFlags_InputRGB|ImGuiColorEditFlags_InputHSV
|
ImGuiColorEditFlags__InputMask = ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_InputHSV
|
||||||
|
|
||||||
// Obsolete names (will be removed)
|
// Obsolete names (will be removed)
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
@ -1268,6 +1297,23 @@ enum ImGuiColorEditFlags_
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Flags for DragFloat(), DragInt(), SliderFloat(), SliderInt() etc.
|
||||||
|
// We use the same sets of flags for DragXXX() and SliderXXX() functions as the features are the same and it makes it easier to swap them.
|
||||||
|
enum ImGuiSliderFlags_
|
||||||
|
{
|
||||||
|
ImGuiSliderFlags_None = 0,
|
||||||
|
ImGuiSliderFlags_AlwaysClamp = 1 << 4, // Clamp value to min/max bounds when input manually with CTRL+Click. By default CTRL+Click allows going out of bounds.
|
||||||
|
ImGuiSliderFlags_Logarithmic = 1 << 5, // Make the widget logarithmic (linear otherwise). Consider using ImGuiSliderFlags_NoRoundToFormat with this if using a format-string with small amount of digits.
|
||||||
|
ImGuiSliderFlags_NoRoundToFormat = 1 << 6, // Disable rounding underlying value to match precision of the display format string (e.g. %.3f values are rounded to those 3 digits)
|
||||||
|
ImGuiSliderFlags_NoInput = 1 << 7, // Disable CTRL+Click or Enter key allowing to input text directly into the widget
|
||||||
|
ImGuiSliderFlags_InvalidMask_ = 0x7000000F // [Internal] We treat using those bits as being potentially a 'float power' argument from the previous API that has got miscast to this enum, and will trigger an assert if needed.
|
||||||
|
|
||||||
|
// Obsolete names (will be removed)
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
, ImGuiSliderFlags_ClampOnInput = ImGuiSliderFlags_AlwaysClamp // [renamed in 1.79]
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
// Identify a mouse button.
|
// Identify a mouse button.
|
||||||
// Those values are guaranteed to be stable and we frequently use 0/1 directly. Named enums provided for convenience.
|
// Those values are guaranteed to be stable and we frequently use 0/1 directly. Named enums provided for convenience.
|
||||||
enum ImGuiMouseButton_
|
enum ImGuiMouseButton_
|
||||||
@ -1316,16 +1362,16 @@ enum ImGuiCond_
|
|||||||
// Helpers: Memory allocations macros
|
// Helpers: Memory allocations macros
|
||||||
// IM_MALLOC(), IM_FREE(), IM_NEW(), IM_PLACEMENT_NEW(), IM_DELETE()
|
// IM_MALLOC(), IM_FREE(), IM_NEW(), IM_PLACEMENT_NEW(), IM_DELETE()
|
||||||
// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax.
|
// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax.
|
||||||
// Defining a custom placement new() with a dummy parameter allows us to bypass including <new> which on some platforms complains when user has disabled exceptions.
|
// Defining a custom placement new() with a custom parameter allows us to bypass including <new> which on some platforms complains when user has disabled exceptions.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
struct ImNewDummy {};
|
struct ImNewWrapper {};
|
||||||
inline void* operator new(size_t, ImNewDummy, void* ptr) { return ptr; }
|
inline void* operator new(size_t, ImNewWrapper, void* ptr) { return ptr; }
|
||||||
inline void operator delete(void*, ImNewDummy, void*) {} // This is only required so we can use the symmetrical new()
|
inline void operator delete(void*, ImNewWrapper, void*) {} // This is only required so we can use the symmetrical new()
|
||||||
#define IM_ALLOC(_SIZE) ImGui::MemAlloc(_SIZE)
|
#define IM_ALLOC(_SIZE) ImGui::MemAlloc(_SIZE)
|
||||||
#define IM_FREE(_PTR) ImGui::MemFree(_PTR)
|
#define IM_FREE(_PTR) ImGui::MemFree(_PTR)
|
||||||
#define IM_PLACEMENT_NEW(_PTR) new(ImNewDummy(), _PTR)
|
#define IM_PLACEMENT_NEW(_PTR) new(ImNewWrapper(), _PTR)
|
||||||
#define IM_NEW(_TYPE) new(ImNewDummy(), ImGui::MemAlloc(sizeof(_TYPE))) _TYPE
|
#define IM_NEW(_TYPE) new(ImNewWrapper(), ImGui::MemAlloc(sizeof(_TYPE))) _TYPE
|
||||||
template<typename T> void IM_DELETE(T* p) { if (p) { p->~T(); ImGui::MemFree(p); } }
|
template<typename T> void IM_DELETE(T* p) { if (p) { p->~T(); ImGui::MemFree(p); } }
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1360,9 +1406,10 @@ struct ImVector
|
|||||||
inline bool empty() const { return Size == 0; }
|
inline bool empty() const { return Size == 0; }
|
||||||
inline int size() const { return Size; }
|
inline int size() const { return Size; }
|
||||||
inline int size_in_bytes() const { return Size * (int)sizeof(T); }
|
inline int size_in_bytes() const { return Size * (int)sizeof(T); }
|
||||||
|
inline int max_size() const { return 0x7FFFFFFF / (int)sizeof(T); }
|
||||||
inline int capacity() const { return Capacity; }
|
inline int capacity() const { return Capacity; }
|
||||||
inline T& operator[](int i) { IM_ASSERT(i < Size); return Data[i]; }
|
inline T& operator[](int i) { IM_ASSERT(i >= 0 && i < Size); return Data[i]; }
|
||||||
inline const T& operator[](int i) const { IM_ASSERT(i < Size); return Data[i]; }
|
inline const T& operator[](int i) const { IM_ASSERT(i >= 0 && i < Size); return Data[i]; }
|
||||||
|
|
||||||
inline void clear() { if (Data) { Size = Capacity = 0; IM_FREE(Data); Data = NULL; } }
|
inline void clear() { if (Data) { Size = Capacity = 0; IM_FREE(Data); Data = NULL; } }
|
||||||
inline T* begin() { return Data; }
|
inline T* begin() { return Data; }
|
||||||
@ -1375,7 +1422,7 @@ struct ImVector
|
|||||||
inline const T& back() const { IM_ASSERT(Size > 0); return Data[Size - 1]; }
|
inline const T& back() const { IM_ASSERT(Size > 0); return Data[Size - 1]; }
|
||||||
inline void swap(ImVector<T>& rhs) { int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; T* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
|
inline void swap(ImVector<T>& rhs) { int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; T* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
|
||||||
|
|
||||||
inline int _grow_capacity(int sz) const { int new_capacity = Capacity ? (Capacity + Capacity/2) : 8; return new_capacity > sz ? new_capacity : sz; }
|
inline int _grow_capacity(int sz) const { int new_capacity = Capacity ? (Capacity + Capacity / 2) : 8; return new_capacity > sz ? new_capacity : sz; }
|
||||||
inline void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; }
|
inline void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; }
|
||||||
inline void resize(int new_size, const T& v) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) memcpy(&Data[n], &v, sizeof(v)); Size = new_size; }
|
inline void resize(int new_size, const T& v) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) memcpy(&Data[n], &v, sizeof(v)); Size = new_size; }
|
||||||
inline void shrink(int new_size) { IM_ASSERT(new_size <= Size); Size = new_size; } // Resize a vector to a smaller size, guaranteed not to cause a reallocation
|
inline void shrink(int new_size) { IM_ASSERT(new_size <= Size); Size = new_size; } // Resize a vector to a smaller size, guaranteed not to cause a reallocation
|
||||||
@ -1385,10 +1432,10 @@ struct ImVector
|
|||||||
inline void push_back(const T& v) { if (Size == Capacity) reserve(_grow_capacity(Size + 1)); memcpy(&Data[Size], &v, sizeof(v)); Size++; }
|
inline void push_back(const T& v) { if (Size == Capacity) reserve(_grow_capacity(Size + 1)); memcpy(&Data[Size], &v, sizeof(v)); Size++; }
|
||||||
inline void pop_back() { IM_ASSERT(Size > 0); Size--; }
|
inline void pop_back() { IM_ASSERT(Size > 0); Size--; }
|
||||||
inline void push_front(const T& v) { if (Size == 0) push_back(v); else insert(Data, v); }
|
inline void push_front(const T& v) { if (Size == 0) push_back(v); else insert(Data, v); }
|
||||||
inline T* erase(const T* it) { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + 1, ((size_t)Size - (size_t)off - 1) * sizeof(T)); Size--; return Data + off; }
|
inline T* erase(const T* it) { IM_ASSERT(it >= Data && it < Data + Size); const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + 1, ((size_t)Size - (size_t)off - 1) * sizeof(T)); Size--; return Data + off; }
|
||||||
inline T* erase(const T* it, const T* it_last){ IM_ASSERT(it >= Data && it < Data+Size && it_last > it && it_last <= Data+Size); const ptrdiff_t count = it_last - it; const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + count, ((size_t)Size - (size_t)off - count) * sizeof(T)); Size -= (int)count; return Data + off; }
|
inline T* erase(const T* it, const T* it_last){ IM_ASSERT(it >= Data && it < Data + Size && it_last > it && it_last <= Data + Size); const ptrdiff_t count = it_last - it; const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + count, ((size_t)Size - (size_t)off - count) * sizeof(T)); Size -= (int)count; return Data + off; }
|
||||||
inline T* erase_unsorted(const T* it) { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; if (it < Data+Size-1) memcpy(Data + off, Data + Size - 1, sizeof(T)); Size--; return Data + off; }
|
inline T* erase_unsorted(const T* it) { IM_ASSERT(it >= Data && it < Data + Size); const ptrdiff_t off = it - Data; if (it < Data + Size - 1) memcpy(Data + off, Data + Size - 1, sizeof(T)); Size--; return Data + off; }
|
||||||
inline T* insert(const T* it, const T& v) { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(_grow_capacity(Size + 1)); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(T)); memcpy(&Data[off], &v, sizeof(v)); Size++; return Data + off; }
|
inline T* insert(const T* it, const T& v) { IM_ASSERT(it >= Data && it <= Data + Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(_grow_capacity(Size + 1)); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(T)); memcpy(&Data[off], &v, sizeof(v)); Size++; return Data + off; }
|
||||||
inline bool contains(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data++ == v) return true; return false; }
|
inline bool contains(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data++ == v) return true; return false; }
|
||||||
inline T* find(const T& v) { T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; }
|
inline T* find(const T& v) { T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; }
|
||||||
inline const T* find(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; }
|
inline const T* find(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; }
|
||||||
@ -1429,17 +1476,19 @@ struct ImGuiStyle
|
|||||||
float ScrollbarRounding; // Radius of grab corners for scrollbar.
|
float ScrollbarRounding; // Radius of grab corners for scrollbar.
|
||||||
float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar.
|
float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar.
|
||||||
float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
||||||
|
float LogSliderDeadzone; // The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero.
|
||||||
float TabRounding; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
|
float TabRounding; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
|
||||||
float TabBorderSize; // Thickness of border around tabs.
|
float TabBorderSize; // Thickness of border around tabs.
|
||||||
float TabMinWidthForUnselectedCloseButton; // Minimum width for close button to appears on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected.
|
float TabMinWidthForCloseButton; // Minimum width for close button to appears on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected.
|
||||||
ImGuiDir ColorButtonPosition; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
|
ImGuiDir ColorButtonPosition; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
|
||||||
ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered).
|
ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered).
|
||||||
ImVec2 SelectableTextAlign; // Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line.
|
ImVec2 SelectableTextAlign; // Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line.
|
||||||
ImVec2 DisplayWindowPadding; // Window position are clamped to be visible within the display area by at least this amount. Only applies to regular windows.
|
ImVec2 DisplayWindowPadding; // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows.
|
||||||
ImVec2 DisplaySafeAreaPadding; // If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets correctly!
|
ImVec2 DisplaySafeAreaPadding; // If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets correctly!
|
||||||
float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later.
|
float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later.
|
||||||
bool AntiAliasedLines; // Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU.
|
bool AntiAliasedLines; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
|
||||||
bool AntiAliasedFill; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
|
bool AntiAliasedLinesUseTex; // Enable anti-aliased lines/borders using textures where possible. Require back-end to render with bilinear filtering. Latched at the beginning of the frame (copied to ImDrawList).
|
||||||
|
bool AntiAliasedFill; // Enable anti-aliased edges around filled shapes (rounded rectangles, circles, etc.). Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
|
||||||
float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
||||||
float CircleSegmentMaxError; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry.
|
float CircleSegmentMaxError; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry.
|
||||||
ImVec4 Colors[ImGuiCol_COUNT];
|
ImVec4 Colors[ImGuiCol_COUNT];
|
||||||
@ -1598,9 +1647,10 @@ struct ImGuiIO
|
|||||||
// Shared state of InputText(), passed as an argument to your callback when a ImGuiInputTextFlags_Callback* flag is used.
|
// Shared state of InputText(), passed as an argument to your callback when a ImGuiInputTextFlags_Callback* flag is used.
|
||||||
// The callback function should return 0 by default.
|
// The callback function should return 0 by default.
|
||||||
// Callbacks (follow a flag name and see comments in ImGuiInputTextFlags_ declarations for more details)
|
// Callbacks (follow a flag name and see comments in ImGuiInputTextFlags_ declarations for more details)
|
||||||
|
// - ImGuiInputTextFlags_CallbackEdit: Callback on buffer edit (note that InputText() already returns true on edit, the callback is useful mainly to manipulate the underlying buffer while focus is active)
|
||||||
|
// - ImGuiInputTextFlags_CallbackAlways: Callback on each iteration
|
||||||
// - ImGuiInputTextFlags_CallbackCompletion: Callback on pressing TAB
|
// - ImGuiInputTextFlags_CallbackCompletion: Callback on pressing TAB
|
||||||
// - ImGuiInputTextFlags_CallbackHistory: Callback on pressing Up/Down arrows
|
// - ImGuiInputTextFlags_CallbackHistory: Callback on pressing Up/Down arrows
|
||||||
// - ImGuiInputTextFlags_CallbackAlways: Callback on each iteration
|
|
||||||
// - ImGuiInputTextFlags_CallbackCharFilter: Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard.
|
// - ImGuiInputTextFlags_CallbackCharFilter: Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard.
|
||||||
// - ImGuiInputTextFlags_CallbackResize: Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow.
|
// - ImGuiInputTextFlags_CallbackResize: Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow.
|
||||||
struct ImGuiInputTextCallbackData
|
struct ImGuiInputTextCallbackData
|
||||||
@ -1627,7 +1677,9 @@ struct ImGuiInputTextCallbackData
|
|||||||
IMGUI_API ImGuiInputTextCallbackData();
|
IMGUI_API ImGuiInputTextCallbackData();
|
||||||
IMGUI_API void DeleteChars(int pos, int bytes_count);
|
IMGUI_API void DeleteChars(int pos, int bytes_count);
|
||||||
IMGUI_API void InsertChars(int pos, const char* text, const char* text_end = NULL);
|
IMGUI_API void InsertChars(int pos, const char* text, const char* text_end = NULL);
|
||||||
bool HasSelection() const { return SelectionStart != SelectionEnd; }
|
void SelectAll() { SelectionStart = 0; SelectionEnd = BufTextLen; }
|
||||||
|
void ClearSelection() { SelectionStart = SelectionEnd = BufTextLen; }
|
||||||
|
bool HasSelection() const { return SelectionStart != SelectionEnd; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Resizing callback data to apply custom constraint. As enabled by SetNextWindowSizeConstraints(). Callback is called during the next Begin().
|
// Resizing callback data to apply custom constraint. As enabled by SetNextWindowSizeConstraints(). Callback is called during the next Begin().
|
||||||
@ -1651,7 +1703,7 @@ struct ImGuiPayload
|
|||||||
ImGuiID SourceId; // Source item id
|
ImGuiID SourceId; // Source item id
|
||||||
ImGuiID SourceParentId; // Source parent id (if available)
|
ImGuiID SourceParentId; // Source parent id (if available)
|
||||||
int DataFrameCount; // Data timestamp
|
int DataFrameCount; // Data timestamp
|
||||||
char DataType[32+1]; // Data type tag (short user-supplied string, 32 characters max)
|
char DataType[32 + 1]; // Data type tag (short user-supplied string, 32 characters max)
|
||||||
bool Preview; // Set when AcceptDragDropPayload() was called and mouse has been hovering the target item (nb: handle overlapping drag targets)
|
bool Preview; // Set when AcceptDragDropPayload() was called and mouse has been hovering the target item (nb: handle overlapping drag targets)
|
||||||
bool Delivery; // Set when AcceptDragDropPayload() was called and mouse button is released over the target item.
|
bool Delivery; // Set when AcceptDragDropPayload() was called and mouse button is released over the target item.
|
||||||
|
|
||||||
@ -1670,10 +1722,26 @@ struct ImGuiPayload
|
|||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
namespace ImGui
|
namespace ImGui
|
||||||
{
|
{
|
||||||
|
// OBSOLETED in 1.79 (from August 2020)
|
||||||
|
static inline void OpenPopupContextItem(const char* str_id = NULL, ImGuiMouseButton mb = 1) { OpenPopupOnItemClick(str_id, mb); } // Bool return value removed. Use IsWindowAppearing() in BeginPopup() instead. Renamed in 1.77, renamed back in 1.79. Sorry!
|
||||||
|
// OBSOLETED in 1.78 (from June 2020)
|
||||||
|
// Old drag/sliders functions that took a 'float power = 1.0' argument instead of flags.
|
||||||
|
// For shared code, you can version check at compile-time with `#if IMGUI_VERSION_NUM >= 17704`.
|
||||||
|
IMGUI_API bool DragScalar(const char* label, ImGuiDataType data_type, void* p_data, float v_speed, const void* p_min, const void* p_max, const char* format, float power);
|
||||||
|
IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, const void* p_min, const void* p_max, const char* format, float power);
|
||||||
|
static inline bool DragFloat(const char* label, float* v, float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalar(label, ImGuiDataType_Float, v, v_speed, &v_min, &v_max, format, power); }
|
||||||
|
static inline bool DragFloat2(const char* label, float v[2], float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 2, v_speed, &v_min, &v_max, format, power); }
|
||||||
|
static inline bool DragFloat3(const char* label, float v[3], float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 3, v_speed, &v_min, &v_max, format, power); }
|
||||||
|
static inline bool DragFloat4(const char* label, float v[4], float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 4, v_speed, &v_min, &v_max, format, power); }
|
||||||
|
IMGUI_API bool SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, float power);
|
||||||
|
IMGUI_API bool SliderScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_min, const void* p_max, const char* format, float power);
|
||||||
|
static inline bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format, float power) { return SliderScalar(label, ImGuiDataType_Float, v, &v_min, &v_max, format, power); }
|
||||||
|
static inline bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 2, &v_min, &v_max, format, power); }
|
||||||
|
static inline bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 3, &v_min, &v_max, format, power); }
|
||||||
|
static inline bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 4, &v_min, &v_max, format, power); }
|
||||||
// OBSOLETED in 1.77 (from June 2020)
|
// OBSOLETED in 1.77 (from June 2020)
|
||||||
static inline bool OpenPopupOnItemClick(const char* str_id = NULL, ImGuiMouseButton mb = 1) { return OpenPopupContextItem(str_id, mb); } // Passing a mouse button to ImGuiPopupFlags is legal
|
|
||||||
static inline bool BeginPopupContextWindow(const char* str_id, ImGuiMouseButton mb, bool over_items) { return BeginPopupContextWindow(str_id, mb | (over_items ? 0 : ImGuiPopupFlags_NoOpenOverItems)); }
|
static inline bool BeginPopupContextWindow(const char* str_id, ImGuiMouseButton mb, bool over_items) { return BeginPopupContextWindow(str_id, mb | (over_items ? 0 : ImGuiPopupFlags_NoOpenOverItems)); }
|
||||||
// OBSOLETED in 1.72 (from July 2019)
|
// OBSOLETED in 1.72 (from April 2019)
|
||||||
static inline void TreeAdvanceToLabelPos() { SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()); }
|
static inline void TreeAdvanceToLabelPos() { SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()); }
|
||||||
// OBSOLETED in 1.71 (from June 2019)
|
// OBSOLETED in 1.71 (from June 2019)
|
||||||
static inline void SetNextTreeNodeOpen(bool open, ImGuiCond cond = 0) { SetNextItemOpen(open, cond); }
|
static inline void SetNextTreeNodeOpen(bool open, ImGuiCond cond = 0) { SetNextItemOpen(open, cond); }
|
||||||
@ -1818,37 +1886,45 @@ struct ImGuiStorage
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Helper: Manually clip large list of items.
|
// Helper: Manually clip large list of items.
|
||||||
// If you are submitting lots of evenly spaced items and you have a random access to the list, you can perform coarse clipping based on visibility to save yourself from processing those items at all.
|
// If you are submitting lots of evenly spaced items and you have a random access to the list, you can perform coarse
|
||||||
|
// clipping based on visibility to save yourself from processing those items at all.
|
||||||
// The clipper calculates the range of visible items and advance the cursor to compensate for the non-visible items we have skipped.
|
// The clipper calculates the range of visible items and advance the cursor to compensate for the non-visible items we have skipped.
|
||||||
// ImGui already clip items based on their bounds but it needs to measure text size to do so. Coarse clipping before submission makes this cost and your own data fetching/submission cost null.
|
// (Dear ImGui already clip items based on their bounds but it needs to measure text size to do so, whereas manual coarse clipping before submission makes this cost and your own data fetching/submission cost almost null)
|
||||||
// Usage:
|
// Usage:
|
||||||
// ImGuiListClipper clipper(1000); // we have 1000 elements, evenly spaced.
|
// ImGuiListClipper clipper;
|
||||||
// while (clipper.Step())
|
// clipper.Begin(1000); // We have 1000 elements, evenly spaced.
|
||||||
// for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
// while (clipper.Step())
|
||||||
// ImGui::Text("line number %d", i);
|
// for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
||||||
// - Step 0: the clipper let you process the first element, regardless of it being visible or not, so we can measure the element height (step skipped if we passed a known height as second arg to constructor).
|
// ImGui::Text("line number %d", i);
|
||||||
// - Step 1: the clipper infer height from first element, calculate the actual range of elements to display, and position the cursor before the first element.
|
// Generally what happens is:
|
||||||
// - (Step 2: dummy step only required if an explicit items_height was passed to constructor or Begin() and user call Step(). Does nothing and switch to Step 3.)
|
// - Clipper lets you process the first element (DisplayStart = 0, DisplayEnd = 1) regardless of it being visible or not.
|
||||||
// - Step 3: the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd), advance the cursor to the end of the list and then returns 'false' to end the loop.
|
// - User code submit one element.
|
||||||
|
// - Clipper can measure the height of the first element
|
||||||
|
// - Clipper calculate the actual range of elements to display based on the current clipping rectangle, position the cursor before the first visible element.
|
||||||
|
// - User code submit visible elements.
|
||||||
struct ImGuiListClipper
|
struct ImGuiListClipper
|
||||||
{
|
{
|
||||||
int DisplayStart, DisplayEnd;
|
int DisplayStart;
|
||||||
int ItemsCount;
|
int DisplayEnd;
|
||||||
|
|
||||||
// [Internal]
|
// [Internal]
|
||||||
|
int ItemsCount;
|
||||||
int StepNo;
|
int StepNo;
|
||||||
float ItemsHeight;
|
float ItemsHeight;
|
||||||
float StartPosY;
|
float StartPosY;
|
||||||
|
|
||||||
// items_count: Use -1 to ignore (you can call Begin later). Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step).
|
IMGUI_API ImGuiListClipper();
|
||||||
// items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing().
|
IMGUI_API ~ImGuiListClipper();
|
||||||
// If you don't specify an items_height, you NEED to call Step(). If you specify items_height you may call the old Begin()/End() api directly, but prefer calling Step().
|
|
||||||
ImGuiListClipper(int items_count = -1, float items_height = -1.0f) { Begin(items_count, items_height); } // NB: Begin() initialize every fields (as we allow user to call Begin/End multiple times on a same instance if they want).
|
|
||||||
~ImGuiListClipper() { IM_ASSERT(ItemsCount == -1); } // Assert if user forgot to call End() or Step() until false.
|
|
||||||
|
|
||||||
IMGUI_API bool Step(); // Call until it returns false. The DisplayStart/DisplayEnd fields will be set and you can process/draw those items.
|
// items_count: Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step)
|
||||||
|
// items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing().
|
||||||
IMGUI_API void Begin(int items_count, float items_height = -1.0f); // Automatically called by constructor if you passed 'items_count' or by Step() in Step 1.
|
IMGUI_API void Begin(int items_count, float items_height = -1.0f); // Automatically called by constructor if you passed 'items_count' or by Step() in Step 1.
|
||||||
IMGUI_API void End(); // Automatically called on the last call of Step() that returns false.
|
IMGUI_API void End(); // Automatically called on the last call of Step() that returns false.
|
||||||
|
IMGUI_API bool Step(); // Call until it returns false. The DisplayStart/DisplayEnd fields will be set and you can process/draw those items.
|
||||||
|
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
inline ImGuiListClipper(int items_count, float items_height = -1.0f) { memset(this, 0, sizeof(*this)); ItemsCount = -1; Begin(items_count, items_height); } // [removed in 1.79]
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helpers macros to generate 32-bit encoded colors
|
// Helpers macros to generate 32-bit encoded colors
|
||||||
@ -1879,8 +1955,8 @@ struct ImColor
|
|||||||
ImVec4 Value;
|
ImVec4 Value;
|
||||||
|
|
||||||
ImColor() { Value.x = Value.y = Value.z = Value.w = 0.0f; }
|
ImColor() { Value.x = Value.y = Value.z = Value.w = 0.0f; }
|
||||||
ImColor(int r, int g, int b, int a = 255) { float sc = 1.0f/255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; }
|
ImColor(int r, int g, int b, int a = 255) { float sc = 1.0f / 255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; }
|
||||||
ImColor(ImU32 rgba) { float sc = 1.0f/255.0f; Value.x = (float)((rgba>>IM_COL32_R_SHIFT)&0xFF) * sc; Value.y = (float)((rgba>>IM_COL32_G_SHIFT)&0xFF) * sc; Value.z = (float)((rgba>>IM_COL32_B_SHIFT)&0xFF) * sc; Value.w = (float)((rgba>>IM_COL32_A_SHIFT)&0xFF) * sc; }
|
ImColor(ImU32 rgba) { float sc = 1.0f / 255.0f; Value.x = (float)((rgba >> IM_COL32_R_SHIFT) & 0xFF) * sc; Value.y = (float)((rgba >> IM_COL32_G_SHIFT) & 0xFF) * sc; Value.z = (float)((rgba >> IM_COL32_B_SHIFT) & 0xFF) * sc; Value.w = (float)((rgba >> IM_COL32_A_SHIFT) & 0xFF) * sc; }
|
||||||
ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
|
ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
|
||||||
ImColor(const ImVec4& col) { Value = col; }
|
ImColor(const ImVec4& col) { Value = col; }
|
||||||
inline operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); }
|
inline operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); }
|
||||||
@ -1888,7 +1964,7 @@ struct ImColor
|
|||||||
|
|
||||||
// FIXME-OBSOLETE: May need to obsolete/cleanup those helpers.
|
// FIXME-OBSOLETE: May need to obsolete/cleanup those helpers.
|
||||||
inline void SetHSV(float h, float s, float v, float a = 1.0f){ ImGui::ColorConvertHSVtoRGB(h, s, v, Value.x, Value.y, Value.z); Value.w = a; }
|
inline void SetHSV(float h, float s, float v, float a = 1.0f){ ImGui::ColorConvertHSVtoRGB(h, s, v, Value.x, Value.y, Value.z); Value.w = a; }
|
||||||
static ImColor HSV(float h, float s, float v, float a = 1.0f) { float r,g,b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r,g,b,a); }
|
static ImColor HSV(float h, float s, float v, float a = 1.0f) { float r, g, b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r, g, b, a); }
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1896,6 +1972,11 @@ struct ImColor
|
|||||||
// Hold a series of drawing commands. The user provides a renderer for ImDrawData which essentially contains an array of ImDrawList.
|
// Hold a series of drawing commands. The user provides a renderer for ImDrawData which essentially contains an array of ImDrawList.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// The maximum line width to bake anti-aliased textures for. Build atlas with ImFontAtlasFlags_NoBakedLines to disable baking.
|
||||||
|
#ifndef IM_DRAWLIST_TEX_LINES_WIDTH_MAX
|
||||||
|
#define IM_DRAWLIST_TEX_LINES_WIDTH_MAX (63)
|
||||||
|
#endif
|
||||||
|
|
||||||
// ImDrawCallback: Draw callbacks for advanced uses [configurable type: override in imconfig.h]
|
// ImDrawCallback: Draw callbacks for advanced uses [configurable type: override in imconfig.h]
|
||||||
// NB: You most likely do NOT need to use draw callbacks just to create your own widget or customized UI rendering,
|
// NB: You most likely do NOT need to use draw callbacks just to create your own widget or customized UI rendering,
|
||||||
// you can poke into the draw list for that! Draw callback may be useful for example to:
|
// you can poke into the draw list for that! Draw callback may be useful for example to:
|
||||||
@ -1992,12 +2073,15 @@ enum ImDrawCornerFlags_
|
|||||||
ImDrawCornerFlags_All = 0xF // In your function calls you may use ~0 (= all bits sets) instead of ImDrawCornerFlags_All, as a convenience
|
ImDrawCornerFlags_All = 0xF // In your function calls you may use ~0 (= all bits sets) instead of ImDrawCornerFlags_All, as a convenience
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Flags for ImDrawList. Those are set automatically by ImGui:: functions from ImGuiIO settings, and generally not manipulated directly.
|
||||||
|
// It is however possible to temporarily alter flags between calls to ImDrawList:: functions.
|
||||||
enum ImDrawListFlags_
|
enum ImDrawListFlags_
|
||||||
{
|
{
|
||||||
ImDrawListFlags_None = 0,
|
ImDrawListFlags_None = 0,
|
||||||
ImDrawListFlags_AntiAliasedLines = 1 << 0, // Lines are anti-aliased (*2 the number of triangles for 1.0f wide line, otherwise *3 the number of triangles)
|
ImDrawListFlags_AntiAliasedLines = 1 << 0, // Enable anti-aliased lines/borders (*2 the number of triangles for 1.0f wide line or lines thin enough to be drawn using textures, otherwise *3 the number of triangles)
|
||||||
ImDrawListFlags_AntiAliasedFill = 1 << 1, // Filled shapes have anti-aliased edges (*2 the number of vertices)
|
ImDrawListFlags_AntiAliasedLinesUseTex = 1 << 1, // Enable anti-aliased lines/borders using textures when possible. Require back-end to render with bilinear filtering.
|
||||||
ImDrawListFlags_AllowVtxOffset = 1 << 2 // Can emit 'VtxOffset > 0' to allow large meshes. Set when 'ImGuiBackendFlags_RendererHasVtxOffset' is enabled.
|
ImDrawListFlags_AntiAliasedFill = 1 << 2, // Enable anti-aliased edge around filled shapes (rounded rectangles, circles).
|
||||||
|
ImDrawListFlags_AllowVtxOffset = 1 << 3 // Can emit 'VtxOffset > 0' to allow large meshes. Set when 'ImGuiBackendFlags_RendererHasVtxOffset' is enabled.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Draw command list
|
// Draw command list
|
||||||
@ -2043,6 +2127,7 @@ struct ImDrawList
|
|||||||
// Primitives
|
// Primitives
|
||||||
// - For rectangular primitives, "p_min" and "p_max" represent the upper-left and lower-right corners.
|
// - For rectangular primitives, "p_min" and "p_max" represent the upper-left and lower-right corners.
|
||||||
// - For circle primitives, use "num_segments == 0" to automatically calculate tessellation (preferred).
|
// - For circle primitives, use "num_segments == 0" to automatically calculate tessellation (preferred).
|
||||||
|
// In older versions (until Dear ImGui 1.77) the AddCircle functions defaulted to num_segments == 12.
|
||||||
// In future versions we will use textures to provide cheaper and higher-quality circles.
|
// In future versions we will use textures to provide cheaper and higher-quality circles.
|
||||||
// Use AddNgon() and AddNgonFilled() functions if you need to guaranteed a specific number of sides.
|
// Use AddNgon() and AddNgonFilled() functions if you need to guaranteed a specific number of sides.
|
||||||
IMGUI_API void AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness = 1.0f);
|
IMGUI_API void AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness = 1.0f);
|
||||||
@ -2053,8 +2138,8 @@ struct ImDrawList
|
|||||||
IMGUI_API void AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col);
|
IMGUI_API void AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col);
|
||||||
IMGUI_API void AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness = 1.0f);
|
IMGUI_API void AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness = 1.0f);
|
||||||
IMGUI_API void AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col);
|
IMGUI_API void AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col);
|
||||||
IMGUI_API void AddCircle(const ImVec2& center, float radius, ImU32 col, int num_segments = 12, float thickness = 1.0f);
|
IMGUI_API void AddCircle(const ImVec2& center, float radius, ImU32 col, int num_segments = 0, float thickness = 1.0f);
|
||||||
IMGUI_API void AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments = 12);
|
IMGUI_API void AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments = 0);
|
||||||
IMGUI_API void AddNgon(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness = 1.0f);
|
IMGUI_API void AddNgon(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness = 1.0f);
|
||||||
IMGUI_API void AddNgonFilled(const ImVec2& center, float radius, ImU32 col, int num_segments);
|
IMGUI_API void AddNgonFilled(const ImVec2& center, float radius, ImU32 col, int num_segments);
|
||||||
IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
|
IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
|
||||||
@ -2074,7 +2159,7 @@ struct ImDrawList
|
|||||||
// Stateful path API, add points then finish with PathFillConvex() or PathStroke()
|
// Stateful path API, add points then finish with PathFillConvex() or PathStroke()
|
||||||
inline void PathClear() { _Path.Size = 0; }
|
inline void PathClear() { _Path.Size = 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.Data[_Path.Size-1], &pos, 8) != 0) _Path.push_back(pos); }
|
inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || memcmp(&_Path.Data[_Path.Size - 1], &pos, 8) != 0) _Path.push_back(pos); }
|
||||||
inline void PathFillConvex(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; } // Note: Anti-aliased filling requires points to be in clockwise order.
|
inline void PathFillConvex(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; } // 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); _Path.Size = 0; }
|
inline void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness); _Path.Size = 0; }
|
||||||
IMGUI_API void PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments = 10);
|
IMGUI_API void PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments = 10);
|
||||||
@ -2211,11 +2296,13 @@ struct ImFontAtlasCustomRect
|
|||||||
bool IsPacked() const { return X != 0xFFFF; }
|
bool IsPacked() const { return X != 0xFFFF; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Flags for ImFontAtlas build
|
||||||
enum ImFontAtlasFlags_
|
enum ImFontAtlasFlags_
|
||||||
{
|
{
|
||||||
ImFontAtlasFlags_None = 0,
|
ImFontAtlasFlags_None = 0,
|
||||||
ImFontAtlasFlags_NoPowerOfTwoHeight = 1 << 0, // Don't round the height to next power of two
|
ImFontAtlasFlags_NoPowerOfTwoHeight = 1 << 0, // Don't round the height to next power of two
|
||||||
ImFontAtlasFlags_NoMouseCursors = 1 << 1 // Don't build software mouse cursors into the atlas
|
ImFontAtlasFlags_NoMouseCursors = 1 << 1, // Don't build software mouse cursors into the atlas (save a little texture memory)
|
||||||
|
ImFontAtlasFlags_NoBakedLines = 1 << 2 // Don't build thick line textures into the atlas (save a little texture memory). The AntiAliasedLinesUseTex features uses them, otherwise they will be rendered using polygons (more expensive for CPU/GPU).
|
||||||
};
|
};
|
||||||
|
|
||||||
// Load and rasterize multiple TTF/OTF fonts into a same texture. The font atlas will build a single texture holding:
|
// Load and rasterize multiple TTF/OTF fonts into a same texture. The font atlas will build a single texture holding:
|
||||||
@ -2289,7 +2376,7 @@ struct ImFontAtlas
|
|||||||
// Note: this API may be redesigned later in order to support multi-monitor varying DPI settings.
|
// Note: this API may be redesigned later in order to support multi-monitor varying DPI settings.
|
||||||
IMGUI_API int AddCustomRectRegular(int width, int height);
|
IMGUI_API int AddCustomRectRegular(int width, int height);
|
||||||
IMGUI_API int AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset = ImVec2(0, 0));
|
IMGUI_API int AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset = ImVec2(0, 0));
|
||||||
const ImFontAtlasCustomRect*GetCustomRectByIndex(int index) const { if (index < 0) return NULL; return &CustomRects[index]; }
|
ImFontAtlasCustomRect* GetCustomRectByIndex(int index) { IM_ASSERT(index >= 0); return &CustomRects[index]; }
|
||||||
|
|
||||||
// [Internal]
|
// [Internal]
|
||||||
IMGUI_API void CalcCustomRectUV(const ImFontAtlasCustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max) const;
|
IMGUI_API void CalcCustomRectUV(const ImFontAtlasCustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max) const;
|
||||||
@ -2315,8 +2402,12 @@ struct ImFontAtlas
|
|||||||
ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel
|
ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel
|
||||||
ImVector<ImFont*> Fonts; // Hold all the fonts returned by AddFont*. Fonts[0] is the default font upon calling ImGui::NewFrame(), use ImGui::PushFont()/PopFont() to change the current font.
|
ImVector<ImFont*> Fonts; // Hold all the fonts returned by AddFont*. Fonts[0] is the default font upon calling ImGui::NewFrame(), use ImGui::PushFont()/PopFont() to change the current font.
|
||||||
ImVector<ImFontAtlasCustomRect> CustomRects; // Rectangles for packing custom texture data into the atlas.
|
ImVector<ImFontAtlasCustomRect> CustomRects; // Rectangles for packing custom texture data into the atlas.
|
||||||
ImVector<ImFontConfig> ConfigData; // Internal data
|
ImVector<ImFontConfig> ConfigData; // Configuration data
|
||||||
int CustomRectIds[1]; // Identifiers of custom texture rectangle used by ImFontAtlas/ImDrawList
|
ImVec4 TexUvLines[IM_DRAWLIST_TEX_LINES_WIDTH_MAX + 1]; // UVs for baked anti-aliased lines
|
||||||
|
|
||||||
|
// [Internal] Packing data
|
||||||
|
int PackIdMouseCursors; // Custom texture rectangle ID for white pixel and mouse cursors
|
||||||
|
int PackIdLines; // Custom texture rectangle ID for baked anti-aliased lines
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
typedef ImFontAtlasCustomRect CustomRect; // OBSOLETED in 1.72+
|
typedef ImFontAtlasCustomRect CustomRect; // OBSOLETED in 1.72+
|
||||||
@ -2333,11 +2424,10 @@ struct ImFont
|
|||||||
float FallbackAdvanceX; // 4 // out // = FallbackGlyph->AdvanceX
|
float FallbackAdvanceX; // 4 // out // = FallbackGlyph->AdvanceX
|
||||||
float FontSize; // 4 // in // // Height of characters/line, set during loading (don't change after loading)
|
float FontSize; // 4 // in // // Height of characters/line, set during loading (don't change after loading)
|
||||||
|
|
||||||
// Members: Hot ~36/48 bytes (for CalcTextSize + render loop)
|
// Members: Hot ~28/40 bytes (for CalcTextSize + render loop)
|
||||||
ImVector<ImWchar> IndexLookup; // 12-16 // out // // Sparse. Index glyphs by Unicode code-point.
|
ImVector<ImWchar> IndexLookup; // 12-16 // out // // Sparse. Index glyphs by Unicode code-point.
|
||||||
ImVector<ImFontGlyph> Glyphs; // 12-16 // out // // All glyphs.
|
ImVector<ImFontGlyph> Glyphs; // 12-16 // out // // All glyphs.
|
||||||
const ImFontGlyph* FallbackGlyph; // 4-8 // out // = FindGlyph(FontFallbackChar)
|
const ImFontGlyph* FallbackGlyph; // 4-8 // out // = FindGlyph(FontFallbackChar)
|
||||||
ImVec2 DisplayOffset; // 8 // in // = (0,0) // Offset font rendering by xx pixels
|
|
||||||
|
|
||||||
// Members: Cold ~32/40 bytes
|
// Members: Cold ~32/40 bytes
|
||||||
ImFontAtlas* ContainerAtlas; // 4-8 // out // // What we has been loaded into
|
ImFontAtlas* ContainerAtlas; // 4-8 // out // // What we has been loaded into
|
||||||
@ -2371,7 +2461,7 @@ struct ImFont
|
|||||||
IMGUI_API void BuildLookupTable();
|
IMGUI_API void BuildLookupTable();
|
||||||
IMGUI_API void ClearOutputData();
|
IMGUI_API void ClearOutputData();
|
||||||
IMGUI_API void GrowIndex(int new_size);
|
IMGUI_API void GrowIndex(int new_size);
|
||||||
IMGUI_API void AddGlyph(ImWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x);
|
IMGUI_API void AddGlyph(const ImFontConfig* src_cfg, ImWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x);
|
||||||
IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built.
|
IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built.
|
||||||
IMGUI_API void SetGlyphVisible(ImWchar c, bool visible);
|
IMGUI_API void SetGlyphVisible(ImWchar c, bool visible);
|
||||||
IMGUI_API void SetFallbackChar(ImWchar c);
|
IMGUI_API void SetFallbackChar(ImWchar c);
|
||||||
|
834
imgui_demo.cpp
834
imgui_demo.cpp
File diff suppressed because it is too large
Load Diff
465
imgui_draw.cpp
465
imgui_draw.cpp
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.77
|
// dear imgui, v1.79
|
||||||
// (drawing and font code)
|
// (drawing and font code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -339,7 +339,7 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// ImDrawList
|
// [SECTION] ImDrawList
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
ImDrawListSharedData::ImDrawListSharedData()
|
ImDrawListSharedData::ImDrawListSharedData()
|
||||||
@ -358,6 +358,7 @@ ImDrawListSharedData::ImDrawListSharedData()
|
|||||||
ArcFastVtx[i] = ImVec2(ImCos(a), ImSin(a));
|
ArcFastVtx[i] = ImVec2(ImCos(a), ImSin(a));
|
||||||
}
|
}
|
||||||
memset(CircleSegmentCounts, 0, sizeof(CircleSegmentCounts)); // This will be set by SetCircleSegmentMaxError()
|
memset(CircleSegmentCounts, 0, sizeof(CircleSegmentCounts)); // This will be set by SetCircleSegmentMaxError()
|
||||||
|
TexUvLines = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawListSharedData::SetCircleSegmentMaxError(float max_error)
|
void ImDrawListSharedData::SetCircleSegmentMaxError(float max_error)
|
||||||
@ -516,7 +517,7 @@ void ImDrawList::_OnChangedVtxOffset()
|
|||||||
// We don't need to compare curr_cmd->VtxOffset != _CmdHeader.VtxOffset because we know it'll be different at the time we call this.
|
// We don't need to compare curr_cmd->VtxOffset != _CmdHeader.VtxOffset because we know it'll be different at the time we call this.
|
||||||
_VtxCurrentIdx = 0;
|
_VtxCurrentIdx = 0;
|
||||||
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
IM_ASSERT(curr_cmd->VtxOffset != _CmdHeader.VtxOffset);
|
//IM_ASSERT(curr_cmd->VtxOffset != _CmdHeader.VtxOffset); // See #3349
|
||||||
if (curr_cmd->ElemCount != 0)
|
if (curr_cmd->ElemCount != 0)
|
||||||
{
|
{
|
||||||
AddDrawCmd();
|
AddDrawCmd();
|
||||||
@ -581,6 +582,9 @@ void ImDrawList::PrimReserve(int idx_count, int vtx_count)
|
|||||||
IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
|
IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
|
||||||
if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset))
|
if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset))
|
||||||
{
|
{
|
||||||
|
// FIXME: In theory we should be testing that vtx_count <64k here.
|
||||||
|
// In practice, RenderText() relies on reserving ahead for a worst case scenario so it is currently useful for us
|
||||||
|
// to not make that check until we rework the text functions to handle clipping and large horizontal lines better.
|
||||||
_CmdHeader.VtxOffset = VtxBuffer.Size;
|
_CmdHeader.VtxOffset = VtxBuffer.Size;
|
||||||
_OnChangedVtxOffset();
|
_OnChangedVtxOffset();
|
||||||
}
|
}
|
||||||
@ -666,28 +670,41 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const ImVec2 opaque_uv = _Data->TexUvWhitePixel;
|
const ImVec2 opaque_uv = _Data->TexUvWhitePixel;
|
||||||
int count = points_count;
|
const int count = closed ? points_count : points_count - 1; // The number of line segments we need to draw
|
||||||
if (!closed)
|
|
||||||
count = points_count-1;
|
|
||||||
|
|
||||||
const bool thick_line = (thickness > 1.0f);
|
const bool thick_line = (thickness > 1.0f);
|
||||||
|
|
||||||
if (Flags & ImDrawListFlags_AntiAliasedLines)
|
if (Flags & ImDrawListFlags_AntiAliasedLines)
|
||||||
{
|
{
|
||||||
// Anti-aliased stroke
|
// Anti-aliased stroke
|
||||||
const float AA_SIZE = 1.0f;
|
const float AA_SIZE = 1.0f;
|
||||||
const ImU32 col_trans = col & ~IM_COL32_A_MASK;
|
const ImU32 col_trans = col & ~IM_COL32_A_MASK;
|
||||||
|
|
||||||
const int idx_count = thick_line ? count*18 : count*12;
|
// Thicknesses <1.0 should behave like thickness 1.0
|
||||||
const int vtx_count = thick_line ? points_count*4 : points_count*3;
|
thickness = ImMax(thickness, 1.0f);
|
||||||
|
const int integer_thickness = (int)thickness;
|
||||||
|
const float fractional_thickness = thickness - integer_thickness;
|
||||||
|
|
||||||
|
// Do we want to draw this line using a texture?
|
||||||
|
// - For now, only draw integer-width lines using textures to avoid issues with the way scaling occurs, could be improved.
|
||||||
|
// - If AA_SIZE is not 1.0f we cannot use the texture path.
|
||||||
|
const bool use_texture = (Flags & ImDrawListFlags_AntiAliasedLinesUseTex) && (integer_thickness < IM_DRAWLIST_TEX_LINES_WIDTH_MAX) && (fractional_thickness <= 0.00001f);
|
||||||
|
|
||||||
|
// We should never hit this, because NewFrame() doesn't set ImDrawListFlags_AntiAliasedLinesUseTex unless ImFontAtlasFlags_NoBakedLines is off
|
||||||
|
IM_ASSERT_PARANOID(!use_texture || !(_Data->Font->ContainerAtlas->Flags & ImFontAtlasFlags_NoBakedLines));
|
||||||
|
|
||||||
|
const int idx_count = use_texture ? (count * 6) : (thick_line ? count * 18 : count * 12);
|
||||||
|
const int vtx_count = use_texture ? (points_count * 2) : (thick_line ? points_count * 4 : points_count * 3);
|
||||||
PrimReserve(idx_count, vtx_count);
|
PrimReserve(idx_count, vtx_count);
|
||||||
|
|
||||||
// Temporary buffer
|
// Temporary buffer
|
||||||
ImVec2* temp_normals = (ImVec2*)alloca(points_count * (thick_line ? 5 : 3) * sizeof(ImVec2)); //-V630
|
// The first <points_count> items are normals at each line point, then after that there are either 2 or 4 temp points for each line point
|
||||||
|
ImVec2* temp_normals = (ImVec2*)alloca(points_count * ((use_texture || !thick_line) ? 3 : 5) * sizeof(ImVec2)); //-V630
|
||||||
ImVec2* temp_points = temp_normals + points_count;
|
ImVec2* temp_points = temp_normals + points_count;
|
||||||
|
|
||||||
|
// Calculate normals (tangents) for each line segment
|
||||||
for (int i1 = 0; i1 < count; i1++)
|
for (int i1 = 0; i1 < count; i1++)
|
||||||
{
|
{
|
||||||
const int i2 = (i1+1) == points_count ? 0 : i1+1;
|
const int i2 = (i1 + 1) == points_count ? 0 : i1 + 1;
|
||||||
float dx = points[i2].x - points[i1].x;
|
float dx = points[i2].x - points[i1].x;
|
||||||
float dy = points[i2].y - points[i1].y;
|
float dy = points[i2].y - points[i1].y;
|
||||||
IM_NORMALIZE2F_OVER_ZERO(dx, dy);
|
IM_NORMALIZE2F_OVER_ZERO(dx, dy);
|
||||||
@ -695,61 +712,113 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
|||||||
temp_normals[i1].y = -dx;
|
temp_normals[i1].y = -dx;
|
||||||
}
|
}
|
||||||
if (!closed)
|
if (!closed)
|
||||||
temp_normals[points_count-1] = temp_normals[points_count-2];
|
temp_normals[points_count - 1] = temp_normals[points_count - 2];
|
||||||
|
|
||||||
if (!thick_line)
|
// If we are drawing a one-pixel-wide line without a texture, or a textured line of any width, we only need 2 or 3 vertices per point
|
||||||
|
if (use_texture || !thick_line)
|
||||||
{
|
{
|
||||||
|
// [PATH 1] Texture-based lines (thick or non-thick)
|
||||||
|
// [PATH 2] Non texture-based lines (non-thick)
|
||||||
|
|
||||||
|
// The width of the geometry we need to draw - this is essentially <thickness> pixels for the line itself, plus "one pixel" for AA.
|
||||||
|
// - In the texture-based path, we don't use AA_SIZE here because the +1 is tied to the generated texture
|
||||||
|
// (see ImFontAtlasBuildRenderLinesTexData() function), and so alternate values won't work without changes to that code.
|
||||||
|
// - In the non texture-based paths, we would allow AA_SIZE to potentially be != 1.0f with a patch (e.g. fringe_scale patch to
|
||||||
|
// allow scaling geometry while preserving one-screen-pixel AA fringe).
|
||||||
|
const float half_draw_size = use_texture ? ((thickness * 0.5f) + 1) : AA_SIZE;
|
||||||
|
|
||||||
|
// If line is not closed, the first and last points need to be generated differently as there are no normals to blend
|
||||||
if (!closed)
|
if (!closed)
|
||||||
{
|
{
|
||||||
temp_points[0] = points[0] + temp_normals[0] * AA_SIZE;
|
temp_points[0] = points[0] + temp_normals[0] * half_draw_size;
|
||||||
temp_points[1] = points[0] - temp_normals[0] * AA_SIZE;
|
temp_points[1] = points[0] - temp_normals[0] * half_draw_size;
|
||||||
temp_points[(points_count-1)*2+0] = points[points_count-1] + temp_normals[points_count-1] * AA_SIZE;
|
temp_points[(points_count-1)*2+0] = points[points_count-1] + temp_normals[points_count-1] * half_draw_size;
|
||||||
temp_points[(points_count-1)*2+1] = points[points_count-1] - temp_normals[points_count-1] * AA_SIZE;
|
temp_points[(points_count-1)*2+1] = points[points_count-1] - temp_normals[points_count-1] * half_draw_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate the indices to form a number of triangles for each line segment, and the vertices for the line edges
|
||||||
|
// This takes points n and n+1 and writes into n+1, with the first point in a closed line being generated from the final one (as n+1 wraps)
|
||||||
// FIXME-OPT: Merge the different loops, possibly remove the temporary buffer.
|
// FIXME-OPT: Merge the different loops, possibly remove the temporary buffer.
|
||||||
unsigned int idx1 = _VtxCurrentIdx;
|
unsigned int idx1 = _VtxCurrentIdx; // Vertex index for start of line segment
|
||||||
for (int i1 = 0; i1 < count; i1++)
|
for (int i1 = 0; i1 < count; i1++) // i1 is the first point of the line segment
|
||||||
{
|
{
|
||||||
const int i2 = (i1+1) == points_count ? 0 : i1+1;
|
const int i2 = (i1 + 1) == points_count ? 0 : i1 + 1; // i2 is the second point of the line segment
|
||||||
unsigned int idx2 = (i1+1) == points_count ? _VtxCurrentIdx : idx1+3;
|
const unsigned int idx2 = ((i1 + 1) == points_count) ? _VtxCurrentIdx : (idx1 + (use_texture ? 2 : 3)); // Vertex index for end of segment
|
||||||
|
|
||||||
// Average normals
|
// Average normals
|
||||||
float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f;
|
float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f;
|
||||||
float dm_y = (temp_normals[i1].y + temp_normals[i2].y) * 0.5f;
|
float dm_y = (temp_normals[i1].y + temp_normals[i2].y) * 0.5f;
|
||||||
IM_FIXNORMAL2F(dm_x, dm_y);
|
IM_FIXNORMAL2F(dm_x, dm_y);
|
||||||
dm_x *= AA_SIZE;
|
dm_x *= half_draw_size; // dm_x, dm_y are offset to the outer edge of the AA area
|
||||||
dm_y *= AA_SIZE;
|
dm_y *= half_draw_size;
|
||||||
|
|
||||||
// Add temporary vertices
|
// Add temporary vertexes for the outer edges
|
||||||
ImVec2* out_vtx = &temp_points[i2*2];
|
ImVec2* out_vtx = &temp_points[i2 * 2];
|
||||||
out_vtx[0].x = points[i2].x + dm_x;
|
out_vtx[0].x = points[i2].x + dm_x;
|
||||||
out_vtx[0].y = points[i2].y + dm_y;
|
out_vtx[0].y = points[i2].y + dm_y;
|
||||||
out_vtx[1].x = points[i2].x - dm_x;
|
out_vtx[1].x = points[i2].x - dm_x;
|
||||||
out_vtx[1].y = points[i2].y - dm_y;
|
out_vtx[1].y = points[i2].y - dm_y;
|
||||||
|
|
||||||
// Add indexes
|
if (use_texture)
|
||||||
_IdxWritePtr[0] = (ImDrawIdx)(idx2+0); _IdxWritePtr[1] = (ImDrawIdx)(idx1+0); _IdxWritePtr[2] = (ImDrawIdx)(idx1+2);
|
{
|
||||||
_IdxWritePtr[3] = (ImDrawIdx)(idx1+2); _IdxWritePtr[4] = (ImDrawIdx)(idx2+2); _IdxWritePtr[5] = (ImDrawIdx)(idx2+0);
|
// Add indices for two triangles
|
||||||
_IdxWritePtr[6] = (ImDrawIdx)(idx2+1); _IdxWritePtr[7] = (ImDrawIdx)(idx1+1); _IdxWritePtr[8] = (ImDrawIdx)(idx1+0);
|
_IdxWritePtr[0] = (ImDrawIdx)(idx2 + 0); _IdxWritePtr[1] = (ImDrawIdx)(idx1 + 0); _IdxWritePtr[2] = (ImDrawIdx)(idx1 + 1); // Right tri
|
||||||
_IdxWritePtr[9] = (ImDrawIdx)(idx1+0); _IdxWritePtr[10]= (ImDrawIdx)(idx2+0); _IdxWritePtr[11]= (ImDrawIdx)(idx2+1);
|
_IdxWritePtr[3] = (ImDrawIdx)(idx2 + 1); _IdxWritePtr[4] = (ImDrawIdx)(idx1 + 1); _IdxWritePtr[5] = (ImDrawIdx)(idx2 + 0); // Left tri
|
||||||
_IdxWritePtr += 12;
|
_IdxWritePtr += 6;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Add indexes for four triangles
|
||||||
|
_IdxWritePtr[0] = (ImDrawIdx)(idx2 + 0); _IdxWritePtr[1] = (ImDrawIdx)(idx1 + 0); _IdxWritePtr[2] = (ImDrawIdx)(idx1 + 2); // Right tri 1
|
||||||
|
_IdxWritePtr[3] = (ImDrawIdx)(idx1 + 2); _IdxWritePtr[4] = (ImDrawIdx)(idx2 + 2); _IdxWritePtr[5] = (ImDrawIdx)(idx2 + 0); // Right tri 2
|
||||||
|
_IdxWritePtr[6] = (ImDrawIdx)(idx2 + 1); _IdxWritePtr[7] = (ImDrawIdx)(idx1 + 1); _IdxWritePtr[8] = (ImDrawIdx)(idx1 + 0); // Left tri 1
|
||||||
|
_IdxWritePtr[9] = (ImDrawIdx)(idx1 + 0); _IdxWritePtr[10] = (ImDrawIdx)(idx2 + 0); _IdxWritePtr[11] = (ImDrawIdx)(idx2 + 1); // Left tri 2
|
||||||
|
_IdxWritePtr += 12;
|
||||||
|
}
|
||||||
|
|
||||||
idx1 = idx2;
|
idx1 = idx2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add vertices
|
// Add vertexes for each point on the line
|
||||||
for (int i = 0; i < points_count; i++)
|
if (use_texture)
|
||||||
{
|
{
|
||||||
_VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = opaque_uv; _VtxWritePtr[0].col = col;
|
// If we're using textures we only need to emit the left/right edge vertices
|
||||||
_VtxWritePtr[1].pos = temp_points[i*2+0]; _VtxWritePtr[1].uv = opaque_uv; _VtxWritePtr[1].col = col_trans;
|
ImVec4 tex_uvs = _Data->TexUvLines[integer_thickness];
|
||||||
_VtxWritePtr[2].pos = temp_points[i*2+1]; _VtxWritePtr[2].uv = opaque_uv; _VtxWritePtr[2].col = col_trans;
|
if (fractional_thickness != 0.0f)
|
||||||
_VtxWritePtr += 3;
|
{
|
||||||
|
const ImVec4 tex_uvs_1 = _Data->TexUvLines[integer_thickness + 1];
|
||||||
|
tex_uvs.x = tex_uvs.x + (tex_uvs_1.x - tex_uvs.x) * fractional_thickness; // inlined ImLerp()
|
||||||
|
tex_uvs.y = tex_uvs.y + (tex_uvs_1.y - tex_uvs.y) * fractional_thickness;
|
||||||
|
tex_uvs.z = tex_uvs.z + (tex_uvs_1.z - tex_uvs.z) * fractional_thickness;
|
||||||
|
tex_uvs.w = tex_uvs.w + (tex_uvs_1.w - tex_uvs.w) * fractional_thickness;
|
||||||
|
}
|
||||||
|
ImVec2 tex_uv0(tex_uvs.x, tex_uvs.y);
|
||||||
|
ImVec2 tex_uv1(tex_uvs.z, tex_uvs.w);
|
||||||
|
for (int i = 0; i < points_count; i++)
|
||||||
|
{
|
||||||
|
_VtxWritePtr[0].pos = temp_points[i * 2 + 0]; _VtxWritePtr[0].uv = tex_uv0; _VtxWritePtr[0].col = col; // Left-side outer edge
|
||||||
|
_VtxWritePtr[1].pos = temp_points[i * 2 + 1]; _VtxWritePtr[1].uv = tex_uv1; _VtxWritePtr[1].col = col; // Right-side outer edge
|
||||||
|
_VtxWritePtr += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If we're not using a texture, we need the center vertex as well
|
||||||
|
for (int i = 0; i < points_count; i++)
|
||||||
|
{
|
||||||
|
_VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = opaque_uv; _VtxWritePtr[0].col = col; // Center of line
|
||||||
|
_VtxWritePtr[1].pos = temp_points[i * 2 + 0]; _VtxWritePtr[1].uv = opaque_uv; _VtxWritePtr[1].col = col_trans; // Left-side outer edge
|
||||||
|
_VtxWritePtr[2].pos = temp_points[i * 2 + 1]; _VtxWritePtr[2].uv = opaque_uv; _VtxWritePtr[2].col = col_trans; // Right-side outer edge
|
||||||
|
_VtxWritePtr += 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// [PATH 2] Non texture-based lines (thick): we need to draw the solid line core and thus require four vertices per point
|
||||||
const float half_inner_thickness = (thickness - AA_SIZE) * 0.5f;
|
const float half_inner_thickness = (thickness - AA_SIZE) * 0.5f;
|
||||||
|
|
||||||
|
// If line is not closed, the first and last points need to be generated differently as there are no normals to blend
|
||||||
if (!closed)
|
if (!closed)
|
||||||
{
|
{
|
||||||
const int points_last = points_count - 1;
|
const int points_last = points_count - 1;
|
||||||
@ -763,9 +832,11 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
|||||||
temp_points[points_last * 4 + 3] = points[points_last] - temp_normals[points_last] * (half_inner_thickness + AA_SIZE);
|
temp_points[points_last * 4 + 3] = points[points_last] - temp_normals[points_last] * (half_inner_thickness + AA_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate the indices to form a number of triangles for each line segment, and the vertices for the line edges
|
||||||
|
// This takes points n and n+1 and writes into n+1, with the first point in a closed line being generated from the final one (as n+1 wraps)
|
||||||
// FIXME-OPT: Merge the different loops, possibly remove the temporary buffer.
|
// FIXME-OPT: Merge the different loops, possibly remove the temporary buffer.
|
||||||
unsigned int idx1 = _VtxCurrentIdx;
|
unsigned int idx1 = _VtxCurrentIdx; // Vertex index for start of line segment
|
||||||
for (int i1 = 0; i1 < count; i1++)
|
for (int i1 = 0; i1 < count; i1++) // i1 is the first point of the line segment
|
||||||
{
|
{
|
||||||
const int i2 = (i1 + 1) == points_count ? 0 : (i1 + 1); // i2 is the second point of the line segment
|
const int i2 = (i1 + 1) == points_count ? 0 : (i1 + 1); // i2 is the second point of the line segment
|
||||||
const unsigned int idx2 = (i1 + 1) == points_count ? _VtxCurrentIdx : (idx1 + 4); // Vertex index for end of segment
|
const unsigned int idx2 = (i1 + 1) == points_count ? _VtxCurrentIdx : (idx1 + 4); // Vertex index for end of segment
|
||||||
@ -780,7 +851,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
|||||||
float dm_in_y = dm_y * half_inner_thickness;
|
float dm_in_y = dm_y * half_inner_thickness;
|
||||||
|
|
||||||
// Add temporary vertices
|
// Add temporary vertices
|
||||||
ImVec2* out_vtx = &temp_points[i2*4];
|
ImVec2* out_vtx = &temp_points[i2 * 4];
|
||||||
out_vtx[0].x = points[i2].x + dm_out_x;
|
out_vtx[0].x = points[i2].x + dm_out_x;
|
||||||
out_vtx[0].y = points[i2].y + dm_out_y;
|
out_vtx[0].y = points[i2].y + dm_out_y;
|
||||||
out_vtx[1].x = points[i2].x + dm_in_x;
|
out_vtx[1].x = points[i2].x + dm_in_x;
|
||||||
@ -816,14 +887,14 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Non Anti-aliased Stroke
|
// [PATH 4] Non texture-based, Non anti-aliased lines
|
||||||
const int idx_count = count*6;
|
const int idx_count = count * 6;
|
||||||
const int vtx_count = count*4; // FIXME-OPT: Not sharing edges
|
const int vtx_count = count * 4; // FIXME-OPT: Not sharing edges
|
||||||
PrimReserve(idx_count, vtx_count);
|
PrimReserve(idx_count, vtx_count);
|
||||||
|
|
||||||
for (int i1 = 0; i1 < count; i1++)
|
for (int i1 = 0; i1 < count; i1++)
|
||||||
{
|
{
|
||||||
const int i2 = (i1+1) == points_count ? 0 : i1+1;
|
const int i2 = (i1 + 1) == points_count ? 0 : i1 + 1;
|
||||||
const ImVec2& p1 = points[i1];
|
const ImVec2& p1 = points[i1];
|
||||||
const ImVec2& p2 = points[i2];
|
const ImVec2& p2 = points[i2];
|
||||||
|
|
||||||
@ -860,22 +931,22 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
|||||||
// Anti-aliased Fill
|
// Anti-aliased Fill
|
||||||
const float AA_SIZE = 1.0f;
|
const float AA_SIZE = 1.0f;
|
||||||
const ImU32 col_trans = col & ~IM_COL32_A_MASK;
|
const ImU32 col_trans = col & ~IM_COL32_A_MASK;
|
||||||
const int idx_count = (points_count-2)*3 + points_count*6;
|
const int idx_count = (points_count - 2)*3 + points_count * 6;
|
||||||
const int vtx_count = (points_count*2);
|
const int vtx_count = (points_count * 2);
|
||||||
PrimReserve(idx_count, vtx_count);
|
PrimReserve(idx_count, vtx_count);
|
||||||
|
|
||||||
// Add indexes for fill
|
// Add indexes for fill
|
||||||
unsigned int vtx_inner_idx = _VtxCurrentIdx;
|
unsigned int vtx_inner_idx = _VtxCurrentIdx;
|
||||||
unsigned int vtx_outer_idx = _VtxCurrentIdx+1;
|
unsigned int vtx_outer_idx = _VtxCurrentIdx + 1;
|
||||||
for (int i = 2; i < points_count; i++)
|
for (int i = 2; i < points_count; i++)
|
||||||
{
|
{
|
||||||
_IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx+((i-1)<<1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_inner_idx+(i<<1));
|
_IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx + ((i - 1) << 1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_inner_idx + (i << 1));
|
||||||
_IdxWritePtr += 3;
|
_IdxWritePtr += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute normals
|
// Compute normals
|
||||||
ImVec2* temp_normals = (ImVec2*)alloca(points_count * sizeof(ImVec2)); //-V630
|
ImVec2* temp_normals = (ImVec2*)alloca(points_count * sizeof(ImVec2)); //-V630
|
||||||
for (int i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++)
|
for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++)
|
||||||
{
|
{
|
||||||
const ImVec2& p0 = points[i0];
|
const ImVec2& p0 = points[i0];
|
||||||
const ImVec2& p1 = points[i1];
|
const ImVec2& p1 = points[i1];
|
||||||
@ -886,7 +957,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
|||||||
temp_normals[i0].y = -dx;
|
temp_normals[i0].y = -dx;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++)
|
for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++)
|
||||||
{
|
{
|
||||||
// Average normals
|
// Average normals
|
||||||
const ImVec2& n0 = temp_normals[i0];
|
const ImVec2& n0 = temp_normals[i0];
|
||||||
@ -903,8 +974,8 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
|||||||
_VtxWritePtr += 2;
|
_VtxWritePtr += 2;
|
||||||
|
|
||||||
// Add indexes for fringes
|
// Add indexes for fringes
|
||||||
_IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx+(i1<<1)); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx+(i0<<1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_outer_idx+(i0<<1));
|
_IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx + (i1 << 1)); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx + (i0 << 1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_outer_idx + (i0 << 1));
|
||||||
_IdxWritePtr[3] = (ImDrawIdx)(vtx_outer_idx+(i0<<1)); _IdxWritePtr[4] = (ImDrawIdx)(vtx_outer_idx+(i1<<1)); _IdxWritePtr[5] = (ImDrawIdx)(vtx_inner_idx+(i1<<1));
|
_IdxWritePtr[3] = (ImDrawIdx)(vtx_outer_idx + (i0 << 1)); _IdxWritePtr[4] = (ImDrawIdx)(vtx_outer_idx + (i1 << 1)); _IdxWritePtr[5] = (ImDrawIdx)(vtx_inner_idx + (i1 << 1));
|
||||||
_IdxWritePtr += 6;
|
_IdxWritePtr += 6;
|
||||||
}
|
}
|
||||||
_VtxCurrentIdx += (ImDrawIdx)vtx_count;
|
_VtxCurrentIdx += (ImDrawIdx)vtx_count;
|
||||||
@ -912,7 +983,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Non Anti-aliased Fill
|
// Non Anti-aliased Fill
|
||||||
const int idx_count = (points_count-2)*3;
|
const int idx_count = (points_count - 2)*3;
|
||||||
const int vtx_count = points_count;
|
const int vtx_count = points_count;
|
||||||
PrimReserve(idx_count, vtx_count);
|
PrimReserve(idx_count, vtx_count);
|
||||||
for (int i = 0; i < vtx_count; i++)
|
for (int i = 0; i < vtx_count; i++)
|
||||||
@ -922,7 +993,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
|||||||
}
|
}
|
||||||
for (int i = 2; i < points_count; i++)
|
for (int i = 2; i < points_count; i++)
|
||||||
{
|
{
|
||||||
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+i-1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+i);
|
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx + i - 1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx + i);
|
||||||
_IdxWritePtr += 3;
|
_IdxWritePtr += 3;
|
||||||
}
|
}
|
||||||
_VtxCurrentIdx += (ImDrawIdx)vtx_count;
|
_VtxCurrentIdx += (ImDrawIdx)vtx_count;
|
||||||
@ -989,20 +1060,20 @@ static void PathBezierToCasteljau(ImVector<ImVec2>* path, float x1, float y1, fl
|
|||||||
float d3 = ((x3 - x4) * dy - (y3 - y4) * dx);
|
float d3 = ((x3 - x4) * dy - (y3 - y4) * dx);
|
||||||
d2 = (d2 >= 0) ? d2 : -d2;
|
d2 = (d2 >= 0) ? d2 : -d2;
|
||||||
d3 = (d3 >= 0) ? d3 : -d3;
|
d3 = (d3 >= 0) ? d3 : -d3;
|
||||||
if ((d2+d3) * (d2+d3) < tess_tol * (dx*dx + dy*dy))
|
if ((d2 + d3) * (d2 + d3) < tess_tol * (dx * dx + dy * dy))
|
||||||
{
|
{
|
||||||
path->push_back(ImVec2(x4, y4));
|
path->push_back(ImVec2(x4, y4));
|
||||||
}
|
}
|
||||||
else if (level < 10)
|
else if (level < 10)
|
||||||
{
|
{
|
||||||
float x12 = (x1+x2)*0.5f, y12 = (y1+y2)*0.5f;
|
float x12 = (x1 + x2)*0.5f, y12 = (y1 + y2)*0.5f;
|
||||||
float x23 = (x2+x3)*0.5f, y23 = (y2+y3)*0.5f;
|
float x23 = (x2 + x3)*0.5f, y23 = (y2 + y3)*0.5f;
|
||||||
float x34 = (x3+x4)*0.5f, y34 = (y3+y4)*0.5f;
|
float x34 = (x3 + x4)*0.5f, y34 = (y3 + y4)*0.5f;
|
||||||
float x123 = (x12+x23)*0.5f, y123 = (y12+y23)*0.5f;
|
float x123 = (x12 + x23)*0.5f, y123 = (y12 + y23)*0.5f;
|
||||||
float x234 = (x23+x34)*0.5f, y234 = (y23+y34)*0.5f;
|
float x234 = (x23 + x34)*0.5f, y234 = (y23 + y34)*0.5f;
|
||||||
float x1234 = (x123+x234)*0.5f, y1234 = (y123+y234)*0.5f;
|
float x1234 = (x123 + x234)*0.5f, y1234 = (y123 + y234)*0.5f;
|
||||||
PathBezierToCasteljau(path, x1,y1, x12,y12, x123,y123, x1234,y1234, tess_tol, level+1);
|
PathBezierToCasteljau(path, x1, y1, x12, y12, x123, y123, x1234, y1234, tess_tol, level + 1);
|
||||||
PathBezierToCasteljau(path, x1234,y1234, x234,y234, x34,y34, x4,y4, tess_tol, level+1);
|
PathBezierToCasteljau(path, x1234, y1234, x234, y234, x34, y34, x4, y4, tess_tol, level + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1062,9 +1133,9 @@ void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, fl
|
|||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
if (Flags & ImDrawListFlags_AntiAliasedLines)
|
if (Flags & ImDrawListFlags_AntiAliasedLines)
|
||||||
PathRect(p_min + ImVec2(0.50f,0.50f), p_max - ImVec2(0.50f,0.50f), rounding, rounding_corners);
|
PathRect(p_min + ImVec2(0.50f, 0.50f), p_max - ImVec2(0.50f, 0.50f), rounding, rounding_corners);
|
||||||
else
|
else
|
||||||
PathRect(p_min + ImVec2(0.50f,0.50f), p_max - ImVec2(0.49f,0.49f), rounding, rounding_corners); // Better looking lower-right corner and rounded non-AA shapes.
|
PathRect(p_min + ImVec2(0.50f, 0.50f), p_max - ImVec2(0.49f, 0.49f), rounding, rounding_corners); // Better looking lower-right corner and rounded non-AA shapes.
|
||||||
PathStroke(col, true, thickness);
|
PathStroke(col, true, thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1092,8 +1163,8 @@ void ImDrawList::AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_ma
|
|||||||
|
|
||||||
const ImVec2 uv = _Data->TexUvWhitePixel;
|
const ImVec2 uv = _Data->TexUvWhitePixel;
|
||||||
PrimReserve(6, 4);
|
PrimReserve(6, 4);
|
||||||
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+1)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2));
|
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 1)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 2));
|
||||||
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+3));
|
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 2)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 3));
|
||||||
PrimWriteVtx(p_min, uv, col_upr_left);
|
PrimWriteVtx(p_min, uv, col_upr_left);
|
||||||
PrimWriteVtx(ImVec2(p_max.x, p_min.y), uv, col_upr_right);
|
PrimWriteVtx(ImVec2(p_max.x, p_min.y), uv, col_upr_right);
|
||||||
PrimWriteVtx(p_max, uv, col_bot_right);
|
PrimWriteVtx(p_max, uv, col_bot_right);
|
||||||
@ -1170,7 +1241,7 @@ void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int nu
|
|||||||
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
||||||
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
|
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
|
||||||
if (num_segments == 12)
|
if (num_segments == 12)
|
||||||
PathArcToFast(center, radius - 0.5f, 0, 12);
|
PathArcToFast(center, radius - 0.5f, 0, 12 - 1);
|
||||||
else
|
else
|
||||||
PathArcTo(center, radius - 0.5f, 0.0f, a_max, num_segments - 1);
|
PathArcTo(center, radius - 0.5f, 0.0f, a_max, num_segments - 1);
|
||||||
PathStroke(col, true, thickness);
|
PathStroke(col, true, thickness);
|
||||||
@ -1200,7 +1271,7 @@ void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col,
|
|||||||
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
||||||
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
|
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
|
||||||
if (num_segments == 12)
|
if (num_segments == 12)
|
||||||
PathArcToFast(center, radius, 0, 12);
|
PathArcToFast(center, radius, 0, 12 - 1);
|
||||||
else
|
else
|
||||||
PathArcTo(center, radius, 0.0f, a_max, num_segments - 1);
|
PathArcTo(center, radius, 0.0f, a_max, num_segments - 1);
|
||||||
PathFillConvex(col);
|
PathFillConvex(col);
|
||||||
@ -1334,7 +1405,7 @@ void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_mi
|
|||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// ImDrawListSplitter
|
// [SECTION] ImDrawListSplitter
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// FIXME: This may be a little confusing, trying to be a little too low-level/optimal instead of just doing vector swap..
|
// FIXME: This may be a little confusing, trying to be a little too low-level/optimal instead of just doing vector swap..
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1528,13 +1599,19 @@ void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int ve
|
|||||||
float gradient_inv_length2 = 1.0f / ImLengthSqr(gradient_extent);
|
float gradient_inv_length2 = 1.0f / ImLengthSqr(gradient_extent);
|
||||||
ImDrawVert* vert_start = draw_list->VtxBuffer.Data + vert_start_idx;
|
ImDrawVert* vert_start = draw_list->VtxBuffer.Data + vert_start_idx;
|
||||||
ImDrawVert* vert_end = draw_list->VtxBuffer.Data + vert_end_idx;
|
ImDrawVert* vert_end = draw_list->VtxBuffer.Data + vert_end_idx;
|
||||||
|
const int col0_r = (int)(col0 >> IM_COL32_R_SHIFT) & 0xFF;
|
||||||
|
const int col0_g = (int)(col0 >> IM_COL32_G_SHIFT) & 0xFF;
|
||||||
|
const int col0_b = (int)(col0 >> IM_COL32_B_SHIFT) & 0xFF;
|
||||||
|
const int col_delta_r = ((int)(col1 >> IM_COL32_R_SHIFT) & 0xFF) - col0_r;
|
||||||
|
const int col_delta_g = ((int)(col1 >> IM_COL32_G_SHIFT) & 0xFF) - col0_g;
|
||||||
|
const int col_delta_b = ((int)(col1 >> IM_COL32_B_SHIFT) & 0xFF) - col0_b;
|
||||||
for (ImDrawVert* vert = vert_start; vert < vert_end; vert++)
|
for (ImDrawVert* vert = vert_start; vert < vert_end; vert++)
|
||||||
{
|
{
|
||||||
float d = ImDot(vert->pos - gradient_p0, gradient_extent);
|
float d = ImDot(vert->pos - gradient_p0, gradient_extent);
|
||||||
float t = ImClamp(d * gradient_inv_length2, 0.0f, 1.0f);
|
float t = ImClamp(d * gradient_inv_length2, 0.0f, 1.0f);
|
||||||
int r = ImLerp((int)(col0 >> IM_COL32_R_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_R_SHIFT) & 0xFF, t);
|
int r = (int)(col0_r + col_delta_r * t);
|
||||||
int g = ImLerp((int)(col0 >> IM_COL32_G_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_G_SHIFT) & 0xFF, t);
|
int g = (int)(col0_g + col_delta_g * t);
|
||||||
int b = ImLerp((int)(col0 >> IM_COL32_B_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_B_SHIFT) & 0xFF, t);
|
int b = (int)(col0_b + col_delta_b * t);
|
||||||
vert->col = (r << IM_COL32_R_SHIFT) | (g << IM_COL32_G_SHIFT) | (b << IM_COL32_B_SHIFT) | (vert->col & IM_COL32_A_MASK);
|
vert->col = (r << IM_COL32_R_SHIFT) | (g << IM_COL32_G_SHIFT) | (b << IM_COL32_B_SHIFT) | (vert->col & IM_COL32_A_MASK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1596,10 +1673,10 @@ ImFontConfig::ImFontConfig()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// A work of art lies ahead! (. = white layer, X = black layer, others are blank)
|
// A work of art lies ahead! (. = white layer, X = black layer, others are blank)
|
||||||
// The white texels on the top left are the ones we'll use everywhere in Dear ImGui to render filled shapes.
|
// The 2x2 white texels on the top left are the ones we'll use everywhere in Dear ImGui to render filled shapes.
|
||||||
const int FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF = 108;
|
const int FONT_ATLAS_DEFAULT_TEX_DATA_W = 108; // Actual texture will be 2 times that + 1 spacing.
|
||||||
const int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27;
|
const int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27;
|
||||||
static const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF * FONT_ATLAS_DEFAULT_TEX_DATA_H + 1] =
|
static const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W * FONT_ATLAS_DEFAULT_TEX_DATA_H + 1] =
|
||||||
{
|
{
|
||||||
"..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX- XX "
|
"..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX- XX "
|
||||||
"..- -X.....X- X.X - X.X -X.....X - X.....X- X..X "
|
"..- -X.....X- X.X - X.X -X.....X - X.....X- X..X "
|
||||||
@ -1656,8 +1733,7 @@ ImFontAtlas::ImFontAtlas()
|
|||||||
TexWidth = TexHeight = 0;
|
TexWidth = TexHeight = 0;
|
||||||
TexUvScale = ImVec2(0.0f, 0.0f);
|
TexUvScale = ImVec2(0.0f, 0.0f);
|
||||||
TexUvWhitePixel = ImVec2(0.0f, 0.0f);
|
TexUvWhitePixel = ImVec2(0.0f, 0.0f);
|
||||||
for (int n = 0; n < IM_ARRAYSIZE(CustomRectIds); n++)
|
PackIdMouseCursors = PackIdLines = -1;
|
||||||
CustomRectIds[n] = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImFontAtlas::~ImFontAtlas()
|
ImFontAtlas::~ImFontAtlas()
|
||||||
@ -1685,8 +1761,7 @@ void ImFontAtlas::ClearInputData()
|
|||||||
}
|
}
|
||||||
ConfigData.clear();
|
ConfigData.clear();
|
||||||
CustomRects.clear();
|
CustomRects.clear();
|
||||||
for (int n = 0; n < IM_ARRAYSIZE(CustomRectIds); n++)
|
PackIdMouseCursors = PackIdLines = -1;
|
||||||
CustomRectIds[n] = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImFontAtlas::ClearTexData()
|
void ImFontAtlas::ClearTexData()
|
||||||
@ -1787,15 +1862,15 @@ ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Default font TTF is compressed with stb_compress then base85 encoded (see misc/fonts/binary_to_compressed_c.cpp for encoder)
|
// Default font TTF is compressed with stb_compress then base85 encoded (see misc/fonts/binary_to_compressed_c.cpp for encoder)
|
||||||
static unsigned int stb_decompress_length(const unsigned char *input);
|
static unsigned int stb_decompress_length(const unsigned char* input);
|
||||||
static unsigned int stb_decompress(unsigned char *output, const unsigned char *input, unsigned int length);
|
static unsigned int stb_decompress(unsigned char* output, const unsigned char* input, unsigned int length);
|
||||||
static const char* GetDefaultCompressedFontDataTTFBase85();
|
static const char* GetDefaultCompressedFontDataTTFBase85();
|
||||||
static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; }
|
static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; }
|
||||||
static void Decode85(const unsigned char* src, unsigned char* dst)
|
static void Decode85(const unsigned char* src, unsigned char* dst)
|
||||||
{
|
{
|
||||||
while (*src)
|
while (*src)
|
||||||
{
|
{
|
||||||
unsigned int tmp = Decode85Byte(src[0]) + 85*(Decode85Byte(src[1]) + 85*(Decode85Byte(src[2]) + 85*(Decode85Byte(src[3]) + 85*Decode85Byte(src[4]))));
|
unsigned int tmp = Decode85Byte(src[0]) + 85 * (Decode85Byte(src[1]) + 85 * (Decode85Byte(src[2]) + 85 * (Decode85Byte(src[3]) + 85 * Decode85Byte(src[4]))));
|
||||||
dst[0] = ((tmp >> 0) & 0xFF); dst[1] = ((tmp >> 8) & 0xFF); dst[2] = ((tmp >> 16) & 0xFF); dst[3] = ((tmp >> 24) & 0xFF); // We can't assume little-endianness.
|
dst[0] = ((tmp >> 0) & 0xFF); dst[1] = ((tmp >> 8) & 0xFF); dst[2] = ((tmp >> 16) & 0xFF); dst[3] = ((tmp >> 24) & 0xFF); // We can't assume little-endianness.
|
||||||
src += 5;
|
src += 5;
|
||||||
dst += 4;
|
dst += 4;
|
||||||
@ -1816,11 +1891,11 @@ ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template)
|
|||||||
if (font_cfg.Name[0] == '\0')
|
if (font_cfg.Name[0] == '\0')
|
||||||
ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "ProggyClean.ttf, %dpx", (int)font_cfg.SizePixels);
|
ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "ProggyClean.ttf, %dpx", (int)font_cfg.SizePixels);
|
||||||
font_cfg.EllipsisChar = (ImWchar)0x0085;
|
font_cfg.EllipsisChar = (ImWchar)0x0085;
|
||||||
|
font_cfg.GlyphOffset.y = 1.0f * IM_FLOOR(font_cfg.SizePixels / 13.0f); // Add +1 offset per 13 units
|
||||||
|
|
||||||
const char* ttf_compressed_base85 = GetDefaultCompressedFontDataTTFBase85();
|
const char* ttf_compressed_base85 = GetDefaultCompressedFontDataTTFBase85();
|
||||||
const ImWchar* glyph_ranges = font_cfg.GlyphRanges != NULL ? font_cfg.GlyphRanges : GetGlyphRangesDefault();
|
const ImWchar* glyph_ranges = font_cfg.GlyphRanges != NULL ? font_cfg.GlyphRanges : GetGlyphRangesDefault();
|
||||||
ImFont* font = AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_cfg.SizePixels, &font_cfg, glyph_ranges);
|
ImFont* font = AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_cfg.SizePixels, &font_cfg, glyph_ranges);
|
||||||
font->DisplayOffset.y = 1.0f;
|
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1862,7 +1937,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float si
|
|||||||
ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
|
ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
|
||||||
{
|
{
|
||||||
const unsigned int buf_decompressed_size = stb_decompress_length((const unsigned char*)compressed_ttf_data);
|
const unsigned int buf_decompressed_size = stb_decompress_length((const unsigned char*)compressed_ttf_data);
|
||||||
unsigned char* buf_decompressed_data = (unsigned char *)IM_ALLOC(buf_decompressed_size);
|
unsigned char* buf_decompressed_data = (unsigned char*)IM_ALLOC(buf_decompressed_size);
|
||||||
stb_decompress(buf_decompressed_data, (const unsigned char*)compressed_ttf_data, (unsigned int)compressed_ttf_size);
|
stb_decompress(buf_decompressed_data, (const unsigned char*)compressed_ttf_data, (unsigned int)compressed_ttf_size);
|
||||||
|
|
||||||
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
||||||
@ -1926,15 +2001,15 @@ bool ImFontAtlas::GetMouseCursorTexData(ImGuiMouseCursor cursor_type, ImVec2* ou
|
|||||||
if (Flags & ImFontAtlasFlags_NoMouseCursors)
|
if (Flags & ImFontAtlasFlags_NoMouseCursors)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
IM_ASSERT(CustomRectIds[0] != -1);
|
IM_ASSERT(PackIdMouseCursors != -1);
|
||||||
ImFontAtlasCustomRect& r = CustomRects[CustomRectIds[0]];
|
ImFontAtlasCustomRect* r = GetCustomRectByIndex(PackIdMouseCursors);
|
||||||
ImVec2 pos = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][0] + ImVec2((float)r.X, (float)r.Y);
|
ImVec2 pos = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][0] + ImVec2((float)r->X, (float)r->Y);
|
||||||
ImVec2 size = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][1];
|
ImVec2 size = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][1];
|
||||||
*out_size = size;
|
*out_size = size;
|
||||||
*out_offset = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][2];
|
*out_offset = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][2];
|
||||||
out_uv_border[0] = (pos) * TexUvScale;
|
out_uv_border[0] = (pos) * TexUvScale;
|
||||||
out_uv_border[1] = (pos + size) * TexUvScale;
|
out_uv_border[1] = (pos + size) * TexUvScale;
|
||||||
pos.x += FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF + 1;
|
pos.x += FONT_ATLAS_DEFAULT_TEX_DATA_W + 1;
|
||||||
out_uv_fill[0] = (pos) * TexUvScale;
|
out_uv_fill[0] = (pos) * TexUvScale;
|
||||||
out_uv_fill[1] = (pos + size) * TexUvScale;
|
out_uv_fill[1] = (pos + size) * TexUvScale;
|
||||||
return true;
|
return true;
|
||||||
@ -2149,7 +2224,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|||||||
if (atlas->TexDesiredWidth > 0)
|
if (atlas->TexDesiredWidth > 0)
|
||||||
atlas->TexWidth = atlas->TexDesiredWidth;
|
atlas->TexWidth = atlas->TexDesiredWidth;
|
||||||
else
|
else
|
||||||
atlas->TexWidth = (surface_sqrt >= 4096*0.7f) ? 4096 : (surface_sqrt >= 2048*0.7f) ? 2048 : (surface_sqrt >= 1024*0.7f) ? 1024 : 512;
|
atlas->TexWidth = (surface_sqrt >= 4096 * 0.7f) ? 4096 : (surface_sqrt >= 2048 * 0.7f) ? 2048 : (surface_sqrt >= 1024 * 0.7f) ? 1024 : 512;
|
||||||
|
|
||||||
// 5. Start packing
|
// 5. Start packing
|
||||||
// Pack our extra data rectangles first, so it will be on the upper-left corner of our texture (UV will have small values).
|
// Pack our extra data rectangles first, so it will be on the upper-left corner of our texture (UV will have small values).
|
||||||
@ -2216,8 +2291,11 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|||||||
if (src_tmp.GlyphsCount == 0)
|
if (src_tmp.GlyphsCount == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// When merging fonts with MergeMode=true:
|
||||||
|
// - We can have multiple input fonts writing into a same destination font.
|
||||||
|
// - dst_font->ConfigData is != from cfg which is our source configuration.
|
||||||
ImFontConfig& cfg = atlas->ConfigData[src_i];
|
ImFontConfig& cfg = atlas->ConfigData[src_i];
|
||||||
ImFont* dst_font = cfg.DstFont; // We can have multiple input fonts writing into a same destination font (when using MergeMode=true)
|
ImFont* dst_font = cfg.DstFont;
|
||||||
|
|
||||||
const float font_scale = stbtt_ScaleForPixelHeight(&src_tmp.FontInfo, cfg.SizePixels);
|
const float font_scale = stbtt_ScaleForPixelHeight(&src_tmp.FontInfo, cfg.SizePixels);
|
||||||
int unscaled_ascent, unscaled_descent, unscaled_line_gap;
|
int unscaled_ascent, unscaled_descent, unscaled_line_gap;
|
||||||
@ -2231,20 +2309,13 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|||||||
|
|
||||||
for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++)
|
for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++)
|
||||||
{
|
{
|
||||||
|
// Register glyph
|
||||||
const int codepoint = src_tmp.GlyphsList[glyph_i];
|
const int codepoint = src_tmp.GlyphsList[glyph_i];
|
||||||
const stbtt_packedchar& pc = src_tmp.PackedChars[glyph_i];
|
const stbtt_packedchar& pc = src_tmp.PackedChars[glyph_i];
|
||||||
|
|
||||||
const float char_advance_x_org = pc.xadvance;
|
|
||||||
const float char_advance_x_mod = ImClamp(char_advance_x_org, cfg.GlyphMinAdvanceX, cfg.GlyphMaxAdvanceX);
|
|
||||||
float char_off_x = font_off_x;
|
|
||||||
if (char_advance_x_org != char_advance_x_mod)
|
|
||||||
char_off_x += cfg.PixelSnapH ? ImFloor((char_advance_x_mod - char_advance_x_org) * 0.5f) : (char_advance_x_mod - char_advance_x_org) * 0.5f;
|
|
||||||
|
|
||||||
// Register glyph
|
|
||||||
stbtt_aligned_quad q;
|
stbtt_aligned_quad q;
|
||||||
float dummy_x = 0.0f, dummy_y = 0.0f;
|
float unused_x = 0.0f, unused_y = 0.0f;
|
||||||
stbtt_GetPackedQuad(src_tmp.PackedChars, atlas->TexWidth, atlas->TexHeight, glyph_i, &dummy_x, &dummy_y, &q, 0);
|
stbtt_GetPackedQuad(src_tmp.PackedChars, atlas->TexWidth, atlas->TexHeight, glyph_i, &unused_x, &unused_y, &q, 0);
|
||||||
dst_font->AddGlyph((ImWchar)codepoint, q.x0 + char_off_x, q.y0 + font_off_y, q.x1 + char_off_x, q.y1 + font_off_y, q.s0, q.t0, q.s1, q.t1, char_advance_x_mod);
|
dst_font->AddGlyph(&cfg, (ImWchar)codepoint, q.x0 + font_off_x, q.y0 + font_off_y, q.x1 + font_off_x, q.y1 + font_off_y, q.s0, q.t0, q.s1, q.t1, pc.xadvance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2256,17 +2327,6 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register default custom rectangles (this is called/shared by both the stb_truetype and the FreeType builder)
|
|
||||||
void ImFontAtlasBuildInit(ImFontAtlas* atlas)
|
|
||||||
{
|
|
||||||
if (atlas->CustomRectIds[0] >= 0)
|
|
||||||
return;
|
|
||||||
if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors))
|
|
||||||
atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF*2+1, FONT_ATLAS_DEFAULT_TEX_DATA_H);
|
|
||||||
else
|
|
||||||
atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(2, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent)
|
void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent)
|
||||||
{
|
{
|
||||||
if (!font_config->MergeMode)
|
if (!font_config->MergeMode)
|
||||||
@ -2274,6 +2334,7 @@ void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* f
|
|||||||
font->ClearOutputData();
|
font->ClearOutputData();
|
||||||
font->FontSize = font_config->SizePixels;
|
font->FontSize = font_config->SizePixels;
|
||||||
font->ConfigData = font_config;
|
font->ConfigData = font_config;
|
||||||
|
font->ConfigDataCount = 0;
|
||||||
font->ContainerAtlas = atlas;
|
font->ContainerAtlas = atlas;
|
||||||
font->Ascent = ascent;
|
font->Ascent = ascent;
|
||||||
font->Descent = descent;
|
font->Descent = descent;
|
||||||
@ -2308,52 +2369,113 @@ void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImFontAtlasBuildRender1bppRectFromString(ImFontAtlas* atlas, int x, int y, int w, int h, const char* in_str, char in_marker_char, unsigned char in_marker_pixel_value)
|
||||||
|
{
|
||||||
|
IM_ASSERT(x >= 0 && x + w <= atlas->TexWidth);
|
||||||
|
IM_ASSERT(y >= 0 && y + h <= atlas->TexHeight);
|
||||||
|
unsigned char* out_pixel = atlas->TexPixelsAlpha8 + x + (y * atlas->TexWidth);
|
||||||
|
for (int off_y = 0; off_y < h; off_y++, out_pixel += atlas->TexWidth, in_str += w)
|
||||||
|
for (int off_x = 0; off_x < w; off_x++)
|
||||||
|
out_pixel[off_x] = (in_str[off_x] == in_marker_char) ? in_marker_pixel_value : 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
static void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas)
|
static void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas)
|
||||||
{
|
{
|
||||||
IM_ASSERT(atlas->CustomRectIds[0] >= 0);
|
ImFontAtlasCustomRect* r = atlas->GetCustomRectByIndex(atlas->PackIdMouseCursors);
|
||||||
IM_ASSERT(atlas->TexPixelsAlpha8 != NULL);
|
IM_ASSERT(r->IsPacked());
|
||||||
ImFontAtlasCustomRect& r = atlas->CustomRects[atlas->CustomRectIds[0]];
|
|
||||||
IM_ASSERT(r.IsPacked());
|
|
||||||
|
|
||||||
const int w = atlas->TexWidth;
|
const int w = atlas->TexWidth;
|
||||||
if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors))
|
if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors))
|
||||||
{
|
{
|
||||||
// Render/copy pixels
|
// Render/copy pixels
|
||||||
IM_ASSERT(r.Width == FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF * 2 + 1 && r.Height == FONT_ATLAS_DEFAULT_TEX_DATA_H);
|
IM_ASSERT(r->Width == FONT_ATLAS_DEFAULT_TEX_DATA_W * 2 + 1 && r->Height == FONT_ATLAS_DEFAULT_TEX_DATA_H);
|
||||||
for (int y = 0, n = 0; y < FONT_ATLAS_DEFAULT_TEX_DATA_H; y++)
|
const int x_for_white = r->X;
|
||||||
for (int x = 0; x < FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF; x++, n++)
|
const int x_for_black = r->X + FONT_ATLAS_DEFAULT_TEX_DATA_W + 1;
|
||||||
{
|
ImFontAtlasBuildRender1bppRectFromString(atlas, x_for_white, r->Y, FONT_ATLAS_DEFAULT_TEX_DATA_W, FONT_ATLAS_DEFAULT_TEX_DATA_H, FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS, '.', 0xFF);
|
||||||
const int offset0 = (int)(r.X + x) + (int)(r.Y + y) * w;
|
ImFontAtlasBuildRender1bppRectFromString(atlas, x_for_black, r->Y, FONT_ATLAS_DEFAULT_TEX_DATA_W, FONT_ATLAS_DEFAULT_TEX_DATA_H, FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS, 'X', 0xFF);
|
||||||
const int offset1 = offset0 + FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF + 1;
|
|
||||||
atlas->TexPixelsAlpha8[offset0] = FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[n] == '.' ? 0xFF : 0x00;
|
|
||||||
atlas->TexPixelsAlpha8[offset1] = FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[n] == 'X' ? 0xFF : 0x00;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IM_ASSERT(r.Width == 2 && r.Height == 2);
|
// Render 4 white pixels
|
||||||
const int offset = (int)(r.X) + (int)(r.Y) * w;
|
IM_ASSERT(r->Width == 2 && r->Height == 2);
|
||||||
|
const int offset = (int)r->X + (int)r->Y * w;
|
||||||
atlas->TexPixelsAlpha8[offset] = atlas->TexPixelsAlpha8[offset + 1] = atlas->TexPixelsAlpha8[offset + w] = atlas->TexPixelsAlpha8[offset + w + 1] = 0xFF;
|
atlas->TexPixelsAlpha8[offset] = atlas->TexPixelsAlpha8[offset + 1] = atlas->TexPixelsAlpha8[offset + w] = atlas->TexPixelsAlpha8[offset + w + 1] = 0xFF;
|
||||||
}
|
}
|
||||||
atlas->TexUvWhitePixel = ImVec2((r.X + 0.5f) * atlas->TexUvScale.x, (r.Y + 0.5f) * atlas->TexUvScale.y);
|
atlas->TexUvWhitePixel = ImVec2((r->X + 0.5f) * atlas->TexUvScale.x, (r->Y + 0.5f) * atlas->TexUvScale.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ImFontAtlasBuildRenderLinesTexData(ImFontAtlas* atlas)
|
||||||
|
{
|
||||||
|
if (atlas->Flags & ImFontAtlasFlags_NoBakedLines)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// This generates a triangular shape in the texture, with the various line widths stacked on top of each other to allow interpolation between them
|
||||||
|
ImFontAtlasCustomRect* r = atlas->GetCustomRectByIndex(atlas->PackIdLines);
|
||||||
|
IM_ASSERT(r->IsPacked());
|
||||||
|
for (unsigned int n = 0; n < IM_DRAWLIST_TEX_LINES_WIDTH_MAX + 1; n++) // +1 because of the zero-width row
|
||||||
|
{
|
||||||
|
// Each line consists of at least two empty pixels at the ends, with a line of solid pixels in the middle
|
||||||
|
unsigned int y = n;
|
||||||
|
unsigned int line_width = n;
|
||||||
|
unsigned int pad_left = (r->Width - line_width) / 2;
|
||||||
|
unsigned int pad_right = r->Width - (pad_left + line_width);
|
||||||
|
|
||||||
|
// Write each slice
|
||||||
|
IM_ASSERT(pad_left + line_width + pad_right == r->Width && y < r->Height); // Make sure we're inside the texture bounds before we start writing pixels
|
||||||
|
unsigned char* write_ptr = &atlas->TexPixelsAlpha8[r->X + ((r->Y + y) * atlas->TexWidth)];
|
||||||
|
memset(write_ptr, 0x00, pad_left);
|
||||||
|
memset(write_ptr + pad_left, 0xFF, line_width);
|
||||||
|
memset(write_ptr + pad_left + line_width, 0x00, pad_right);
|
||||||
|
|
||||||
|
// Calculate UVs for this line
|
||||||
|
ImVec2 uv0 = ImVec2((float)(r->X + pad_left - 1), (float)(r->Y + y)) * atlas->TexUvScale;
|
||||||
|
ImVec2 uv1 = ImVec2((float)(r->X + pad_left + line_width + 1), (float)(r->Y + y + 1)) * atlas->TexUvScale;
|
||||||
|
float half_v = (uv0.y + uv1.y) * 0.5f; // Calculate a constant V in the middle of the row to avoid sampling artifacts
|
||||||
|
atlas->TexUvLines[n] = ImVec4(uv0.x, half_v, uv1.x, half_v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note: this is called / shared by both the stb_truetype and the FreeType builder
|
||||||
|
void ImFontAtlasBuildInit(ImFontAtlas* atlas)
|
||||||
|
{
|
||||||
|
// Register texture region for mouse cursors or standard white pixels
|
||||||
|
if (atlas->PackIdMouseCursors < 0)
|
||||||
|
{
|
||||||
|
if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors))
|
||||||
|
atlas->PackIdMouseCursors = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_W * 2 + 1, FONT_ATLAS_DEFAULT_TEX_DATA_H);
|
||||||
|
else
|
||||||
|
atlas->PackIdMouseCursors = atlas->AddCustomRectRegular(2, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register texture region for thick lines
|
||||||
|
// The +2 here is to give space for the end caps, whilst height +1 is to accommodate the fact we have a zero-width row
|
||||||
|
if (atlas->PackIdLines < 0)
|
||||||
|
{
|
||||||
|
if (!(atlas->Flags & ImFontAtlasFlags_NoBakedLines))
|
||||||
|
atlas->PackIdLines = atlas->AddCustomRectRegular(IM_DRAWLIST_TEX_LINES_WIDTH_MAX + 2, IM_DRAWLIST_TEX_LINES_WIDTH_MAX + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is called/shared by both the stb_truetype and the FreeType builder.
|
||||||
void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
|
void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
|
||||||
{
|
{
|
||||||
// Render into our custom data block
|
// Render into our custom data blocks
|
||||||
|
IM_ASSERT(atlas->TexPixelsAlpha8 != NULL);
|
||||||
ImFontAtlasBuildRenderDefaultTexData(atlas);
|
ImFontAtlasBuildRenderDefaultTexData(atlas);
|
||||||
|
ImFontAtlasBuildRenderLinesTexData(atlas);
|
||||||
|
|
||||||
// Register custom rectangle glyphs
|
// Register custom rectangle glyphs
|
||||||
for (int i = 0; i < atlas->CustomRects.Size; i++)
|
for (int i = 0; i < atlas->CustomRects.Size; i++)
|
||||||
{
|
{
|
||||||
const ImFontAtlasCustomRect& r = atlas->CustomRects[i];
|
const ImFontAtlasCustomRect* r = &atlas->CustomRects[i];
|
||||||
if (r.Font == NULL || r.GlyphID == 0)
|
if (r->Font == NULL || r->GlyphID == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
IM_ASSERT(r.Font->ContainerAtlas == atlas);
|
// Will ignore ImFontConfig settings: GlyphMinAdvanceX, GlyphMinAdvanceY, GlyphExtraSpacing, PixelSnapH
|
||||||
|
IM_ASSERT(r->Font->ContainerAtlas == atlas);
|
||||||
ImVec2 uv0, uv1;
|
ImVec2 uv0, uv1;
|
||||||
atlas->CalcCustomRectUV(&r, &uv0, &uv1);
|
atlas->CalcCustomRectUV(r, &uv0, &uv1);
|
||||||
r.Font->AddGlyph((ImWchar)r.GlyphID, r.GlyphOffset.x, r.GlyphOffset.y, r.GlyphOffset.x + r.Width, r.GlyphOffset.y + r.Height, uv0.x, uv0.y, uv1.x, uv1.y, r.GlyphAdvanceX);
|
r->Font->AddGlyph(NULL, (ImWchar)r->GlyphID, r->GlyphOffset.x, r->GlyphOffset.y, r->GlyphOffset.x + r->Width, r->GlyphOffset.y + r->Height, uv0.x, uv0.y, uv1.x, uv1.y, r->GlyphAdvanceX);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build all fonts lookup tables
|
// Build all fonts lookup tables
|
||||||
@ -2646,7 +2768,6 @@ ImFont::ImFont()
|
|||||||
FallbackAdvanceX = 0.0f;
|
FallbackAdvanceX = 0.0f;
|
||||||
FallbackChar = (ImWchar)'?';
|
FallbackChar = (ImWchar)'?';
|
||||||
EllipsisChar = (ImWchar)-1;
|
EllipsisChar = (ImWchar)-1;
|
||||||
DisplayOffset = ImVec2(0.0f, 0.0f);
|
|
||||||
FallbackGlyph = NULL;
|
FallbackGlyph = NULL;
|
||||||
ContainerAtlas = NULL;
|
ContainerAtlas = NULL;
|
||||||
ConfigData = NULL;
|
ConfigData = NULL;
|
||||||
@ -2712,7 +2833,7 @@ void ImFont::BuildLookupTable()
|
|||||||
tab_glyph.Codepoint = '\t';
|
tab_glyph.Codepoint = '\t';
|
||||||
tab_glyph.AdvanceX *= IM_TABSIZE;
|
tab_glyph.AdvanceX *= IM_TABSIZE;
|
||||||
IndexAdvanceX[(int)tab_glyph.Codepoint] = (float)tab_glyph.AdvanceX;
|
IndexAdvanceX[(int)tab_glyph.Codepoint] = (float)tab_glyph.AdvanceX;
|
||||||
IndexLookup[(int)tab_glyph.Codepoint] = (ImWchar)(Glyphs.Size-1);
|
IndexLookup[(int)tab_glyph.Codepoint] = (ImWchar)(Glyphs.Size - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark special glyphs as not visible (note that AddGlyph already mark as non-visible glyphs with zero-size polygons)
|
// Mark special glyphs as not visible (note that AddGlyph already mark as non-visible glyphs with zero-size polygons)
|
||||||
@ -2763,8 +2884,29 @@ void ImFont::GrowIndex(int new_size)
|
|||||||
|
|
||||||
// x0/y0/x1/y1 are offset from the character upper-left layout position, in pixels. Therefore x0/y0 are often fairly close to zero.
|
// x0/y0/x1/y1 are offset from the character upper-left layout position, in pixels. Therefore x0/y0 are often fairly close to zero.
|
||||||
// Not to be mistaken with texture coordinates, which are held by u0/v0/u1/v1 in normalized format (0.0..1.0 on each texture axis).
|
// Not to be mistaken with texture coordinates, which are held by u0/v0/u1/v1 in normalized format (0.0..1.0 on each texture axis).
|
||||||
void ImFont::AddGlyph(ImWchar codepoint, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x)
|
// 'cfg' is not necessarily == 'this->ConfigData' because multiple source fonts+configs can be used to build one target font.
|
||||||
|
void ImFont::AddGlyph(const ImFontConfig* cfg, ImWchar codepoint, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x)
|
||||||
{
|
{
|
||||||
|
if (cfg != NULL)
|
||||||
|
{
|
||||||
|
// Clamp & recenter if needed
|
||||||
|
const float advance_x_original = advance_x;
|
||||||
|
advance_x = ImClamp(advance_x, cfg->GlyphMinAdvanceX, cfg->GlyphMaxAdvanceX);
|
||||||
|
if (advance_x != advance_x_original)
|
||||||
|
{
|
||||||
|
float char_off_x = cfg->PixelSnapH ? ImFloor((advance_x - advance_x_original) * 0.5f) : (advance_x - advance_x_original) * 0.5f;
|
||||||
|
x0 += char_off_x;
|
||||||
|
x1 += char_off_x;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Snap to pixel
|
||||||
|
if (cfg->PixelSnapH)
|
||||||
|
advance_x = IM_ROUND(advance_x);
|
||||||
|
|
||||||
|
// Bake spacing
|
||||||
|
advance_x += cfg->GlyphExtraSpacing.x;
|
||||||
|
}
|
||||||
|
|
||||||
Glyphs.resize(Glyphs.Size + 1);
|
Glyphs.resize(Glyphs.Size + 1);
|
||||||
ImFontGlyph& glyph = Glyphs.back();
|
ImFontGlyph& glyph = Glyphs.back();
|
||||||
glyph.Codepoint = (unsigned int)codepoint;
|
glyph.Codepoint = (unsigned int)codepoint;
|
||||||
@ -2777,14 +2919,13 @@ void ImFont::AddGlyph(ImWchar codepoint, float x0, float y0, float x1, float y1,
|
|||||||
glyph.V0 = v0;
|
glyph.V0 = v0;
|
||||||
glyph.U1 = u1;
|
glyph.U1 = u1;
|
||||||
glyph.V1 = v1;
|
glyph.V1 = v1;
|
||||||
glyph.AdvanceX = advance_x + ConfigData->GlyphExtraSpacing.x; // Bake spacing into AdvanceX
|
glyph.AdvanceX = advance_x;
|
||||||
|
|
||||||
if (ConfigData->PixelSnapH)
|
|
||||||
glyph.AdvanceX = IM_ROUND(glyph.AdvanceX);
|
|
||||||
|
|
||||||
// Compute rough surface usage metrics (+1 to account for average padding, +0.99 to round)
|
// Compute rough surface usage metrics (+1 to account for average padding, +0.99 to round)
|
||||||
|
// We use (U1-U0)*TexWidth instead of X1-X0 to account for oversampling.
|
||||||
|
float pad = ContainerAtlas->TexGlyphPadding + 0.99f;
|
||||||
DirtyLookupTables = true;
|
DirtyLookupTables = true;
|
||||||
MetricsTotalSurface += (int)((glyph.U1 - glyph.U0) * ContainerAtlas->TexWidth + 1.99f) * (int)((glyph.V1 - glyph.V0) * ContainerAtlas->TexHeight + 1.99f);
|
MetricsTotalSurface += (int)((glyph.U1 - glyph.U0) * ContainerAtlas->TexWidth + pad) * (int)((glyph.V1 - glyph.V0) * ContainerAtlas->TexHeight + pad);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
|
void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
|
||||||
@ -3021,8 +3162,8 @@ void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
|||||||
if (!glyph || !glyph->Visible)
|
if (!glyph || !glyph->Visible)
|
||||||
return;
|
return;
|
||||||
float scale = (size >= 0.0f) ? (size / FontSize) : 1.0f;
|
float scale = (size >= 0.0f) ? (size / FontSize) : 1.0f;
|
||||||
pos.x = IM_FLOOR(pos.x + DisplayOffset.x);
|
pos.x = IM_FLOOR(pos.x);
|
||||||
pos.y = IM_FLOOR(pos.y + DisplayOffset.y);
|
pos.y = IM_FLOOR(pos.y);
|
||||||
draw_list->PrimReserve(6, 4);
|
draw_list->PrimReserve(6, 4);
|
||||||
draw_list->PrimRectUV(ImVec2(pos.x + glyph->X0 * scale, pos.y + glyph->Y0 * scale), ImVec2(pos.x + glyph->X1 * scale, pos.y + glyph->Y1 * scale), ImVec2(glyph->U0, glyph->V0), ImVec2(glyph->U1, glyph->V1), col);
|
draw_list->PrimRectUV(ImVec2(pos.x + glyph->X0 * scale, pos.y + glyph->Y0 * scale), ImVec2(pos.x + glyph->X1 * scale, pos.y + glyph->Y1 * scale), ImVec2(glyph->U0, glyph->V0), ImVec2(glyph->U1, glyph->V1), col);
|
||||||
}
|
}
|
||||||
@ -3033,8 +3174,8 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
|||||||
text_end = text_begin + strlen(text_begin); // ImGui:: functions generally already provides a valid text_end, so this is merely to handle direct calls.
|
text_end = text_begin + strlen(text_begin); // ImGui:: functions generally already provides a valid text_end, so this is merely to handle direct calls.
|
||||||
|
|
||||||
// Align to be pixel perfect
|
// Align to be pixel perfect
|
||||||
pos.x = IM_FLOOR(pos.x + DisplayOffset.x);
|
pos.x = IM_FLOOR(pos.x);
|
||||||
pos.y = IM_FLOOR(pos.y + DisplayOffset.y);
|
pos.y = IM_FLOOR(pos.y);
|
||||||
float x = pos.x;
|
float x = pos.x;
|
||||||
float y = pos.y;
|
float y = pos.y;
|
||||||
if (y > clip_rect.w)
|
if (y > clip_rect.w)
|
||||||
@ -3207,7 +3348,7 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
|||||||
// Give back unused vertices (clipped ones, blanks) ~ this is essentially a PrimUnreserve() action.
|
// Give back unused vertices (clipped ones, blanks) ~ this is essentially a PrimUnreserve() action.
|
||||||
draw_list->VtxBuffer.Size = (int)(vtx_write - draw_list->VtxBuffer.Data); // Same as calling shrink()
|
draw_list->VtxBuffer.Size = (int)(vtx_write - draw_list->VtxBuffer.Data); // Same as calling shrink()
|
||||||
draw_list->IdxBuffer.Size = (int)(idx_write - draw_list->IdxBuffer.Data);
|
draw_list->IdxBuffer.Size = (int)(idx_write - draw_list->IdxBuffer.Data);
|
||||||
draw_list->CmdBuffer[draw_list->CmdBuffer.Size-1].ElemCount -= (idx_expected_size - draw_list->IdxBuffer.Size);
|
draw_list->CmdBuffer[draw_list->CmdBuffer.Size - 1].ElemCount -= (idx_expected_size - draw_list->IdxBuffer.Size);
|
||||||
draw_list->_VtxWritePtr = vtx_write;
|
draw_list->_VtxWritePtr = vtx_write;
|
||||||
draw_list->_IdxWritePtr = idx_write;
|
draw_list->_IdxWritePtr = idx_write;
|
||||||
draw_list->_VtxCurrentIdx = vtx_current_idx;
|
draw_list->_VtxCurrentIdx = vtx_current_idx;
|
||||||
@ -3293,10 +3434,10 @@ void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, Im
|
|||||||
pos -= offset;
|
pos -= offset;
|
||||||
const ImTextureID tex_id = font_atlas->TexID;
|
const ImTextureID tex_id = font_atlas->TexID;
|
||||||
draw_list->PushTextureID(tex_id);
|
draw_list->PushTextureID(tex_id);
|
||||||
draw_list->AddImage(tex_id, pos + ImVec2(1,0)*scale, pos + ImVec2(1,0)*scale + size*scale, uv[2], uv[3], col_shadow);
|
draw_list->AddImage(tex_id, pos + ImVec2(1, 0) * scale, pos + (ImVec2(1, 0) + size) * scale, uv[2], uv[3], col_shadow);
|
||||||
draw_list->AddImage(tex_id, pos + ImVec2(2,0)*scale, pos + ImVec2(2,0)*scale + size*scale, uv[2], uv[3], col_shadow);
|
draw_list->AddImage(tex_id, pos + ImVec2(2, 0) * scale, pos + (ImVec2(2, 0) + size) * scale, uv[2], uv[3], col_shadow);
|
||||||
draw_list->AddImage(tex_id, pos, pos + size*scale, uv[2], uv[3], col_border);
|
draw_list->AddImage(tex_id, pos, pos + size * scale, uv[2], uv[3], col_border);
|
||||||
draw_list->AddImage(tex_id, pos, pos + size*scale, uv[0], uv[1], col_fill);
|
draw_list->AddImage(tex_id, pos, pos + size * scale, uv[0], uv[1], col_fill);
|
||||||
draw_list->PopTextureID();
|
draw_list->PopTextureID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3383,6 +3524,22 @@ void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, Im
|
|||||||
draw_list->PathFillConvex(col);
|
draw_list->PathFillConvex(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect inner, ImU32 col, float rounding)
|
||||||
|
{
|
||||||
|
const bool fill_L = (inner.Min.x > outer.Min.x);
|
||||||
|
const bool fill_R = (inner.Max.x < outer.Max.x);
|
||||||
|
const bool fill_U = (inner.Min.y > outer.Min.y);
|
||||||
|
const bool fill_D = (inner.Max.y < outer.Max.y);
|
||||||
|
if (fill_L) draw_list->AddRectFilled(ImVec2(outer.Min.x, inner.Min.y), ImVec2(inner.Min.x, inner.Max.y), col, rounding, (fill_U ? 0 : ImDrawCornerFlags_TopLeft) | (fill_D ? 0 : ImDrawCornerFlags_BotLeft));
|
||||||
|
if (fill_R) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Min.y), ImVec2(outer.Max.x, inner.Max.y), col, rounding, (fill_U ? 0 : ImDrawCornerFlags_TopRight) | (fill_D ? 0 : ImDrawCornerFlags_BotRight));
|
||||||
|
if (fill_U) draw_list->AddRectFilled(ImVec2(inner.Min.x, outer.Min.y), ImVec2(inner.Max.x, inner.Min.y), col, rounding, (fill_L ? 0 : ImDrawCornerFlags_TopLeft) | (fill_R ? 0 : ImDrawCornerFlags_TopRight));
|
||||||
|
if (fill_D) draw_list->AddRectFilled(ImVec2(inner.Min.x, inner.Max.y), ImVec2(inner.Max.x, outer.Max.y), col, rounding, (fill_L ? 0 : ImDrawCornerFlags_BotLeft) | (fill_R ? 0 : ImDrawCornerFlags_BotRight));
|
||||||
|
if (fill_L && fill_U) draw_list->AddRectFilled(ImVec2(outer.Min.x, outer.Min.y), ImVec2(inner.Min.x, inner.Min.y), col, rounding, ImDrawCornerFlags_TopLeft);
|
||||||
|
if (fill_R && fill_U) draw_list->AddRectFilled(ImVec2(inner.Max.x, outer.Min.y), ImVec2(outer.Max.x, inner.Min.y), col, rounding, ImDrawCornerFlags_TopRight);
|
||||||
|
if (fill_L && fill_D) draw_list->AddRectFilled(ImVec2(outer.Min.x, inner.Max.y), ImVec2(inner.Min.x, outer.Max.y), col, rounding, ImDrawCornerFlags_BotLeft);
|
||||||
|
if (fill_R && fill_D) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Max.y), ImVec2(outer.Max.x, outer.Max.y), col, rounding, ImDrawCornerFlags_BotRight);
|
||||||
|
}
|
||||||
|
|
||||||
// Helper for ColorPicker4()
|
// Helper for ColorPicker4()
|
||||||
// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that.
|
// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that.
|
||||||
// Spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding altogether.
|
// Spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding altogether.
|
||||||
@ -3551,7 +3708,7 @@ static unsigned int stb_decompress(unsigned char *output, const unsigned char *i
|
|||||||
// Exported using misc/fonts/binary_to_compressed_c.cpp (with compression + base85 string encoding).
|
// Exported using misc/fonts/binary_to_compressed_c.cpp (with compression + base85 string encoding).
|
||||||
// The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size.
|
// The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
static const char proggy_clean_ttf_compressed_data_base85[11980+1] =
|
static const char proggy_clean_ttf_compressed_data_base85[11980 + 1] =
|
||||||
"7])#######hV0qs'/###[),##/l:$#Q6>##5[n42>c-TH`->>#/e>11NNV=Bv(*:.F?uu#(gRU.o0XGH`$vhLG1hxt9?W`#,5LsCp#-i>.r$<$6pD>Lb';9Crc6tgXmKVeU2cD4Eo3R/"
|
"7])#######hV0qs'/###[),##/l:$#Q6>##5[n42>c-TH`->>#/e>11NNV=Bv(*:.F?uu#(gRU.o0XGH`$vhLG1hxt9?W`#,5LsCp#-i>.r$<$6pD>Lb';9Crc6tgXmKVeU2cD4Eo3R/"
|
||||||
"2*>]b(MC;$jPfY.;h^`IWM9<Lh2TlS+f-s$o6Q<BWH`YiU.xfLq$N;$0iR/GX:U(jcW2p/W*q?-qmnUCI;jHSAiFWM.R*kU@C=GH?a9wp8f$e.-4^Qg1)Q-GL(lf(r/7GrRgwV%MS=C#"
|
"2*>]b(MC;$jPfY.;h^`IWM9<Lh2TlS+f-s$o6Q<BWH`YiU.xfLq$N;$0iR/GX:U(jcW2p/W*q?-qmnUCI;jHSAiFWM.R*kU@C=GH?a9wp8f$e.-4^Qg1)Q-GL(lf(r/7GrRgwV%MS=C#"
|
||||||
"`8ND>Qo#t'X#(v#Y9w0#1D$CIf;W'#pWUPXOuxXuU(H9M(1<q-UE31#^-V'8IRUo7Qf./L>=Ke$$'5F%)]0^#0X@U.a<r:QLtFsLcL6##lOj)#.Y5<-R&KgLwqJfLgN&;Q?gI^#DY2uL"
|
"`8ND>Qo#t'X#(v#Y9w0#1D$CIf;W'#pWUPXOuxXuU(H9M(1<q-UE31#^-V'8IRUo7Qf./L>=Ke$$'5F%)]0^#0X@U.a<r:QLtFsLcL6##lOj)#.Y5<-R&KgLwqJfLgN&;Q?gI^#DY2uL"
|
||||||
|
238
imgui_internal.h
238
imgui_internal.h
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.77
|
// dear imgui, v1.79
|
||||||
// (internal structures/api)
|
// (internal structures/api)
|
||||||
|
|
||||||
// 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!
|
||||||
@ -96,7 +96,7 @@ struct ImGuiContext; // Main Dear ImGui context
|
|||||||
struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum
|
struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum
|
||||||
struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup()
|
struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup()
|
||||||
struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box
|
struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box
|
||||||
struct ImGuiItemHoveredDataBackup; // Backup and restore IsItemHovered() internal data
|
struct ImGuiLastItemDataBackup; // Backup and restore IsItemHovered() internal data
|
||||||
struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only
|
struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only
|
||||||
struct ImGuiNavMoveResult; // Result of a gamepad/keyboard directional navigation move query result
|
struct ImGuiNavMoveResult; // Result of a gamepad/keyboard directional navigation move query result
|
||||||
struct ImGuiNextWindowData; // Storage for SetNextWindow** functions
|
struct ImGuiNextWindowData; // Storage for SetNextWindow** functions
|
||||||
@ -114,7 +114,6 @@ struct ImGuiWindowSettings; // Storage for a window .ini settings (we ke
|
|||||||
typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical
|
typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical
|
||||||
typedef int ImGuiButtonFlags; // -> enum ImGuiButtonFlags_ // Flags: for ButtonEx(), ButtonBehavior()
|
typedef int ImGuiButtonFlags; // -> enum ImGuiButtonFlags_ // Flags: for ButtonEx(), ButtonBehavior()
|
||||||
typedef int ImGuiColumnsFlags; // -> enum ImGuiColumnsFlags_ // Flags: BeginColumns()
|
typedef int ImGuiColumnsFlags; // -> enum ImGuiColumnsFlags_ // Flags: BeginColumns()
|
||||||
typedef int ImGuiDragFlags; // -> enum ImGuiDragFlags_ // Flags: for DragBehavior()
|
|
||||||
typedef int ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag()
|
typedef int ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag()
|
||||||
typedef int ImGuiItemStatusFlags; // -> enum ImGuiItemStatusFlags_ // Flags: for DC.LastItemStatusFlags
|
typedef int ImGuiItemStatusFlags; // -> enum ImGuiItemStatusFlags_ // Flags: for DC.LastItemStatusFlags
|
||||||
typedef int ImGuiNavHighlightFlags; // -> enum ImGuiNavHighlightFlags_ // Flags: for RenderNavHighlight()
|
typedef int ImGuiNavHighlightFlags; // -> enum ImGuiNavHighlightFlags_ // Flags: for RenderNavHighlight()
|
||||||
@ -123,7 +122,6 @@ typedef int ImGuiNavMoveFlags; // -> enum ImGuiNavMoveFlags_ // F
|
|||||||
typedef int ImGuiNextItemDataFlags; // -> enum ImGuiNextItemDataFlags_ // Flags: for SetNextItemXXX() functions
|
typedef int ImGuiNextItemDataFlags; // -> enum ImGuiNextItemDataFlags_ // Flags: for SetNextItemXXX() functions
|
||||||
typedef int ImGuiNextWindowDataFlags; // -> enum ImGuiNextWindowDataFlags_// Flags: for SetNextWindowXXX() functions
|
typedef int ImGuiNextWindowDataFlags; // -> enum ImGuiNextWindowDataFlags_// Flags: for SetNextWindowXXX() functions
|
||||||
typedef int ImGuiSeparatorFlags; // -> enum ImGuiSeparatorFlags_ // Flags: for SeparatorEx()
|
typedef int ImGuiSeparatorFlags; // -> enum ImGuiSeparatorFlags_ // Flags: for SeparatorEx()
|
||||||
typedef int ImGuiSliderFlags; // -> enum ImGuiSliderFlags_ // Flags: for SliderBehavior()
|
|
||||||
typedef int ImGuiTextFlags; // -> enum ImGuiTextFlags_ // Flags: for TextEx()
|
typedef int ImGuiTextFlags; // -> enum ImGuiTextFlags_ // Flags: for TextEx()
|
||||||
typedef int ImGuiTooltipFlags; // -> enum ImGuiTooltipFlags_ // Flags: for BeginTooltipEx()
|
typedef int ImGuiTooltipFlags; // -> enum ImGuiTooltipFlags_ // Flags: for BeginTooltipEx()
|
||||||
|
|
||||||
@ -163,6 +161,12 @@ namespace ImStb
|
|||||||
#define IMGUI_DEBUG_LOG(_FMT,...) printf("[%05d] " _FMT, GImGui->FrameCount, __VA_ARGS__)
|
#define IMGUI_DEBUG_LOG(_FMT,...) printf("[%05d] " _FMT, GImGui->FrameCount, __VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Debug Logging for selected systems. Remove the '((void)0) //' to enable.
|
||||||
|
//#define IMGUI_DEBUG_LOG_POPUP IMGUI_DEBUG_LOG // Enable log
|
||||||
|
//#define IMGUI_DEBUG_LOG_NAV IMGUI_DEBUG_LOG // Enable log
|
||||||
|
#define IMGUI_DEBUG_LOG_POPUP(...) ((void)0) // Disable log
|
||||||
|
#define IMGUI_DEBUG_LOG_NAV(...) ((void)0) // Disable log
|
||||||
|
|
||||||
// Static Asserts
|
// Static Asserts
|
||||||
#if (__cplusplus >= 201100)
|
#if (__cplusplus >= 201100)
|
||||||
#define IM_STATIC_ASSERT(_COND) static_assert(_COND, "")
|
#define IM_STATIC_ASSERT(_COND) static_assert(_COND, "")
|
||||||
@ -290,21 +294,21 @@ IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, cons
|
|||||||
// We are keeping those disabled by default so they don't leak in user space, to allow user enabling implicit cast operators between ImVec2 and their own types (using IM_VEC2_CLASS_EXTRA etc.)
|
// We are keeping those disabled by default so they don't leak in user space, to allow user enabling implicit cast operators between ImVec2 and their own types (using IM_VEC2_CLASS_EXTRA etc.)
|
||||||
// We unfortunately don't have a unary- operator for ImVec2 because this would needs to be defined inside the class itself.
|
// We unfortunately don't have a unary- operator for ImVec2 because this would needs to be defined inside the class itself.
|
||||||
#ifdef IMGUI_DEFINE_MATH_OPERATORS
|
#ifdef IMGUI_DEFINE_MATH_OPERATORS
|
||||||
static inline ImVec2 operator*(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x*rhs, lhs.y*rhs); }
|
static inline ImVec2 operator*(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x * rhs, lhs.y * rhs); }
|
||||||
static inline ImVec2 operator/(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x/rhs, lhs.y/rhs); }
|
static inline ImVec2 operator/(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x / rhs, lhs.y / rhs); }
|
||||||
static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x+rhs.x, lhs.y+rhs.y); }
|
static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x + rhs.x, lhs.y + rhs.y); }
|
||||||
static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x-rhs.x, lhs.y-rhs.y); }
|
static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x - rhs.x, lhs.y - rhs.y); }
|
||||||
static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x*rhs.x, lhs.y*rhs.y); }
|
static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
|
||||||
static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x/rhs.x, lhs.y/rhs.y); }
|
static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x / rhs.x, lhs.y / rhs.y); }
|
||||||
static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
|
static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
|
||||||
static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
|
static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
|
||||||
static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
|
static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
|
||||||
static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
|
static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
|
||||||
static inline ImVec2& operator*=(ImVec2& lhs, const ImVec2& rhs) { lhs.x *= rhs.x; lhs.y *= rhs.y; return lhs; }
|
static inline ImVec2& operator*=(ImVec2& lhs, const ImVec2& rhs) { lhs.x *= rhs.x; lhs.y *= rhs.y; return lhs; }
|
||||||
static inline ImVec2& operator/=(ImVec2& lhs, const ImVec2& rhs) { lhs.x /= rhs.x; lhs.y /= rhs.y; return lhs; }
|
static inline ImVec2& operator/=(ImVec2& lhs, const ImVec2& rhs) { lhs.x /= rhs.x; lhs.y /= rhs.y; return lhs; }
|
||||||
static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x+rhs.x, lhs.y+rhs.y, lhs.z+rhs.z, lhs.w+rhs.w); }
|
static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z, lhs.w + rhs.w); }
|
||||||
static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x-rhs.x, lhs.y-rhs.y, lhs.z-rhs.z, lhs.w-rhs.w); }
|
static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z, lhs.w - rhs.w); }
|
||||||
static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z, lhs.w*rhs.w); }
|
static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z, lhs.w * rhs.w); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Helpers: File System
|
// Helpers: File System
|
||||||
@ -344,6 +348,12 @@ IMGUI_API void* ImFileLoadToMemory(const char* filename, const char*
|
|||||||
#define ImCeil(X) ceilf(X)
|
#define ImCeil(X) ceilf(X)
|
||||||
static inline float ImPow(float x, float y) { return powf(x, y); } // DragBehaviorT/SliderBehaviorT uses ImPow with either float/double and need the precision
|
static inline float ImPow(float x, float y) { return powf(x, y); } // DragBehaviorT/SliderBehaviorT uses ImPow with either float/double and need the precision
|
||||||
static inline double ImPow(double x, double y) { return pow(x, y); }
|
static inline double ImPow(double x, double y) { return pow(x, y); }
|
||||||
|
static inline float ImLog(float x) { return logf(x); } // DragBehaviorT/SliderBehaviorT uses ImLog with either float/double and need the precision
|
||||||
|
static inline double ImLog(double x) { return log(x); }
|
||||||
|
static inline float ImAbs(float x) { return fabsf(x); }
|
||||||
|
static inline double ImAbs(double x) { return fabs(x); }
|
||||||
|
static inline float ImSign(float x) { return (x < 0.0f) ? -1.0f : ((x > 0.0f) ? 1.0f : 0.0f); } // Sign operator - returns -1, 0 or 1 based on sign of argument
|
||||||
|
static inline double ImSign(double x) { return (x < 0.0) ? -1.0 : ((x > 0.0) ? 1.0 : 0.0); }
|
||||||
#endif
|
#endif
|
||||||
// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support variety of types: signed/unsigned int/long long float/double
|
// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support variety of types: signed/unsigned int/long long float/double
|
||||||
// (Exceptionally using templates here but we could also redefine them for those types)
|
// (Exceptionally using templates here but we could also redefine them for those types)
|
||||||
@ -362,9 +372,9 @@ static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t)
|
|||||||
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); }
|
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); }
|
||||||
static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); }
|
static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * 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 / ImSqrt(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 int ImModPositive(int a, int b) { return (a + b) % b; }
|
static inline int ImModPositive(int a, int b) { return (a + b) % b; }
|
||||||
@ -544,6 +554,7 @@ struct IMGUI_API ImDrawListSharedData
|
|||||||
// [Internal] Lookup tables
|
// [Internal] Lookup tables
|
||||||
ImVec2 ArcFastVtx[12 * IM_DRAWLIST_ARCFAST_TESSELLATION_MULTIPLIER]; // FIXME: Bake rounded corners fill/borders in atlas
|
ImVec2 ArcFastVtx[12 * IM_DRAWLIST_ARCFAST_TESSELLATION_MULTIPLIER]; // FIXME: Bake rounded corners fill/borders in atlas
|
||||||
ImU8 CircleSegmentCounts[64]; // Precomputed segment count for given radius (array index + 1) before we calculate it dynamically (to avoid calculation overhead)
|
ImU8 CircleSegmentCounts[64]; // Precomputed segment count for given radius (array index + 1) before we calculate it dynamically (to avoid calculation overhead)
|
||||||
|
const ImVec4* TexUvLines; // UV of anti-aliased lines in the atlas
|
||||||
|
|
||||||
ImDrawListSharedData();
|
ImDrawListSharedData();
|
||||||
void SetCircleSegmentMaxError(float max_error);
|
void SetCircleSegmentMaxError(float max_error);
|
||||||
@ -574,6 +585,7 @@ enum ImGuiItemFlags_
|
|||||||
ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false
|
ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false
|
||||||
ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // MenuItem/Selectable() automatically closes current Popup window
|
ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // MenuItem/Selectable() automatically closes current Popup window
|
||||||
ImGuiItemFlags_MixedValue = 1 << 6, // false // [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ. Currently only supported by Checkbox() (later should support all sorts of widgets)
|
ImGuiItemFlags_MixedValue = 1 << 6, // false // [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ. Currently only supported by Checkbox() (later should support all sorts of widgets)
|
||||||
|
ImGuiItemFlags_ReadOnly = 1 << 7, // false // [ALPHA] Allow hovering interactions but underlying value is not changed.
|
||||||
ImGuiItemFlags_Default_ = 0
|
ImGuiItemFlags_Default_ = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -598,58 +610,47 @@ enum ImGuiItemStatusFlags_
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ImGuiButtonFlags_
|
// Extend ImGuiButtonFlags_
|
||||||
|
enum ImGuiButtonFlagsPrivate_
|
||||||
{
|
{
|
||||||
ImGuiButtonFlags_None = 0,
|
ImGuiButtonFlags_PressedOnClick = 1 << 4, // return true on click (mouse down event)
|
||||||
ImGuiButtonFlags_Repeat = 1 << 0, // hold to repeat
|
ImGuiButtonFlags_PressedOnClickRelease = 1 << 5, // [Default] return true on click + release on same item <-- this is what the majority of Button are using
|
||||||
ImGuiButtonFlags_PressedOnClick = 1 << 1, // return true on click (mouse down event)
|
ImGuiButtonFlags_PressedOnClickReleaseAnywhere = 1 << 6, // return true on click + release even if the release event is not done while hovering the item
|
||||||
ImGuiButtonFlags_PressedOnClickRelease = 1 << 2, // [Default] return true on click + release on same item <-- this is what the majority of Button are using
|
ImGuiButtonFlags_PressedOnRelease = 1 << 7, // return true on release (default requires click+release)
|
||||||
ImGuiButtonFlags_PressedOnClickReleaseAnywhere = 1 << 3, // return true on click + release even if the release event is not done while hovering the item
|
ImGuiButtonFlags_PressedOnDoubleClick = 1 << 8, // return true on double-click (default requires click+release)
|
||||||
ImGuiButtonFlags_PressedOnRelease = 1 << 4, // return true on release (default requires click+release)
|
ImGuiButtonFlags_PressedOnDragDropHold = 1 << 9, // return true when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers)
|
||||||
ImGuiButtonFlags_PressedOnDoubleClick = 1 << 5, // return true on double-click (default requires click+release)
|
ImGuiButtonFlags_Repeat = 1 << 10, // hold to repeat
|
||||||
ImGuiButtonFlags_PressedOnDragDropHold = 1 << 6, // return true when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers)
|
ImGuiButtonFlags_FlattenChildren = 1 << 11, // allow interactions even if a child window is overlapping
|
||||||
ImGuiButtonFlags_FlattenChildren = 1 << 7, // allow interactions even if a child window is overlapping
|
ImGuiButtonFlags_AllowItemOverlap = 1 << 12, // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap()
|
||||||
ImGuiButtonFlags_AllowItemOverlap = 1 << 8, // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap()
|
ImGuiButtonFlags_DontClosePopups = 1 << 13, // disable automatically closing parent popup on press // [UNUSED]
|
||||||
ImGuiButtonFlags_DontClosePopups = 1 << 9, // disable automatically closing parent popup on press // [UNUSED]
|
ImGuiButtonFlags_Disabled = 1 << 14, // disable interactions
|
||||||
ImGuiButtonFlags_Disabled = 1 << 10, // disable interactions
|
ImGuiButtonFlags_AlignTextBaseLine = 1 << 15, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
|
||||||
ImGuiButtonFlags_AlignTextBaseLine = 1 << 11, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
|
ImGuiButtonFlags_NoKeyModifiers = 1 << 16, // disable mouse interaction if a key modifier is held
|
||||||
ImGuiButtonFlags_NoKeyModifiers = 1 << 12, // disable mouse interaction if a key modifier is held
|
ImGuiButtonFlags_NoHoldingActiveId = 1 << 17, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
|
||||||
ImGuiButtonFlags_NoHoldingActiveId = 1 << 13, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
|
ImGuiButtonFlags_NoNavFocus = 1 << 18, // don't override navigation focus when activated
|
||||||
ImGuiButtonFlags_NoNavFocus = 1 << 14, // don't override navigation focus when activated
|
ImGuiButtonFlags_NoHoveredOnFocus = 1 << 19, // don't report as hovered when nav focus is on this item
|
||||||
ImGuiButtonFlags_NoHoveredOnFocus = 1 << 15, // don't report as hovered when nav focus is on this item
|
|
||||||
ImGuiButtonFlags_MouseButtonLeft = 1 << 16, // [Default] react on left mouse button
|
|
||||||
ImGuiButtonFlags_MouseButtonRight = 1 << 17, // react on right mouse button
|
|
||||||
ImGuiButtonFlags_MouseButtonMiddle = 1 << 18, // react on center mouse button
|
|
||||||
|
|
||||||
ImGuiButtonFlags_MouseButtonMask_ = ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight | ImGuiButtonFlags_MouseButtonMiddle,
|
|
||||||
ImGuiButtonFlags_MouseButtonShift_ = 16,
|
|
||||||
ImGuiButtonFlags_MouseButtonDefault_ = ImGuiButtonFlags_MouseButtonLeft,
|
|
||||||
ImGuiButtonFlags_PressedOnMask_ = ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_PressedOnDragDropHold,
|
ImGuiButtonFlags_PressedOnMask_ = ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_PressedOnDragDropHold,
|
||||||
ImGuiButtonFlags_PressedOnDefault_ = ImGuiButtonFlags_PressedOnClickRelease
|
ImGuiButtonFlags_PressedOnDefault_ = ImGuiButtonFlags_PressedOnClickRelease
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ImGuiSliderFlags_
|
// Extend ImGuiSliderFlags_
|
||||||
|
enum ImGuiSliderFlagsPrivate_
|
||||||
{
|
{
|
||||||
ImGuiSliderFlags_None = 0,
|
ImGuiSliderFlags_Vertical = 1 << 20, // Should this slider be orientated vertically?
|
||||||
ImGuiSliderFlags_Vertical = 1 << 0
|
ImGuiSliderFlags_ReadOnly = 1 << 21
|
||||||
};
|
|
||||||
|
|
||||||
enum ImGuiDragFlags_
|
|
||||||
{
|
|
||||||
ImGuiDragFlags_None = 0,
|
|
||||||
ImGuiDragFlags_Vertical = 1 << 0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extend ImGuiSelectableFlags_
|
// Extend ImGuiSelectableFlags_
|
||||||
enum ImGuiSelectableFlagsPrivate_
|
enum ImGuiSelectableFlagsPrivate_
|
||||||
{
|
{
|
||||||
// NB: need to be in sync with last value of ImGuiSelectableFlags_
|
// NB: need to be in sync with last value of ImGuiSelectableFlags_
|
||||||
ImGuiSelectableFlags_NoHoldingActiveID = 1 << 20,
|
ImGuiSelectableFlags_NoHoldingActiveID = 1 << 20,
|
||||||
ImGuiSelectableFlags_SelectOnClick = 1 << 21, // Override button behavior to react on Click (default is Click+Release)
|
ImGuiSelectableFlags_SelectOnClick = 1 << 21, // Override button behavior to react on Click (default is Click+Release)
|
||||||
ImGuiSelectableFlags_SelectOnRelease = 1 << 22, // Override button behavior to react on Release (default is Click+Release)
|
ImGuiSelectableFlags_SelectOnRelease = 1 << 22, // Override button behavior to react on Release (default is Click+Release)
|
||||||
ImGuiSelectableFlags_SpanAvailWidth = 1 << 23, // Span all avail width even if we declared less for layout purpose. FIXME: We may be able to remove this (added in 6251d379, 2bcafc86 for menus)
|
ImGuiSelectableFlags_SpanAvailWidth = 1 << 23, // Span all avail width even if we declared less for layout purpose. FIXME: We may be able to remove this (added in 6251d379, 2bcafc86 for menus)
|
||||||
ImGuiSelectableFlags_DrawHoveredWhenHeld= 1 << 24, // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow.
|
ImGuiSelectableFlags_DrawHoveredWhenHeld = 1 << 24, // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow.
|
||||||
ImGuiSelectableFlags_SetNavIdOnHover = 1 << 25
|
ImGuiSelectableFlags_SetNavIdOnHover = 1 << 25, // Set Nav/Focus ID on mouse hover (used by MenuItem)
|
||||||
|
ImGuiSelectableFlags_NoPadWithHalfSpacing = 1 << 26 // Disable padding each side with ItemSpacing * 0.5f
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extend ImGuiTreeNodeFlags_
|
// Extend ImGuiTreeNodeFlags_
|
||||||
@ -776,7 +777,8 @@ enum ImGuiNavLayer
|
|||||||
enum ImGuiPopupPositionPolicy
|
enum ImGuiPopupPositionPolicy
|
||||||
{
|
{
|
||||||
ImGuiPopupPositionPolicy_Default,
|
ImGuiPopupPositionPolicy_Default,
|
||||||
ImGuiPopupPositionPolicy_ComboBox
|
ImGuiPopupPositionPolicy_ComboBox,
|
||||||
|
ImGuiPopupPositionPolicy_Tooltip
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ImGuiDataTypeTempStorage
|
struct ImGuiDataTypeTempStorage
|
||||||
@ -787,7 +789,8 @@ struct ImGuiDataTypeTempStorage
|
|||||||
// Type information associated to one ImGuiDataType. Retrieve with DataTypeGetInfo().
|
// Type information associated to one ImGuiDataType. Retrieve with DataTypeGetInfo().
|
||||||
struct ImGuiDataTypeInfo
|
struct ImGuiDataTypeInfo
|
||||||
{
|
{
|
||||||
size_t Size; // Size in byte
|
size_t Size; // Size in bytes
|
||||||
|
const char* Name; // Short descriptive name for the type, for debugging
|
||||||
const char* PrintFmt; // Default printf format for the type
|
const char* PrintFmt; // Default printf format for the type
|
||||||
const char* ScanFmt; // Default scanf format for the type
|
const char* ScanFmt; // Default scanf format for the type
|
||||||
};
|
};
|
||||||
@ -860,6 +863,7 @@ struct IMGUI_API ImGuiInputTextState
|
|||||||
float CursorAnim; // timer for cursor blink, reset on every user action so the cursor reappears immediately
|
float CursorAnim; // timer for cursor blink, reset on every user action so the cursor reappears immediately
|
||||||
bool CursorFollow; // set when we want scrolling to follow the current cursor position (not always!)
|
bool CursorFollow; // set when we want scrolling to follow the current cursor position (not always!)
|
||||||
bool SelectedAllMouseLock; // after a double-click to select all, we ignore further mouse drags to update selection
|
bool SelectedAllMouseLock; // after a double-click to select all, we ignore further mouse drags to update selection
|
||||||
|
bool Edited; // edited this frame
|
||||||
ImGuiInputTextFlags UserFlags; // Temporarily set while we call user's callback
|
ImGuiInputTextFlags UserFlags; // Temporarily set while we call user's callback
|
||||||
ImGuiInputTextCallback UserCallback; // "
|
ImGuiInputTextCallback UserCallback; // "
|
||||||
void* UserCallbackData; // "
|
void* UserCallbackData; // "
|
||||||
@ -1016,7 +1020,7 @@ struct ImGuiColumns
|
|||||||
float HostCursorMaxPosX; // Backup of CursorMaxPos at the time of BeginColumns()
|
float HostCursorMaxPosX; // Backup of CursorMaxPos at the time of BeginColumns()
|
||||||
ImRect HostInitialClipRect; // Backup of ClipRect at the time of BeginColumns()
|
ImRect HostInitialClipRect; // Backup of ClipRect at the time of BeginColumns()
|
||||||
ImRect HostBackupClipRect; // Backup of ClipRect during PushColumnsBackground()/PopColumnsBackground()
|
ImRect HostBackupClipRect; // Backup of ClipRect during PushColumnsBackground()/PopColumnsBackground()
|
||||||
ImRect HostWorkRect; // Backup of WorkRect at the time of BeginColumns()
|
ImRect HostBackupParentWorkRect;//Backup of WorkRect at the time of BeginColumns()
|
||||||
ImVector<ImGuiColumnData> Columns;
|
ImVector<ImGuiColumnData> Columns;
|
||||||
ImDrawListSplitter Splitter;
|
ImDrawListSplitter Splitter;
|
||||||
|
|
||||||
@ -1128,17 +1132,19 @@ struct ImGuiContext
|
|||||||
ImGuiStorage WindowsById; // Map window's ImGuiID to ImGuiWindow*
|
ImGuiStorage WindowsById; // Map window's ImGuiID to ImGuiWindow*
|
||||||
int WindowsActiveCount; // Number of unique windows submitted by frame
|
int WindowsActiveCount; // Number of unique windows submitted by frame
|
||||||
ImGuiWindow* CurrentWindow; // Window being drawn into
|
ImGuiWindow* CurrentWindow; // Window being drawn into
|
||||||
ImGuiWindow* HoveredWindow; // Will catch mouse inputs
|
ImGuiWindow* HoveredWindow; // Window the mouse is hovering. Will typically catch mouse inputs.
|
||||||
ImGuiWindow* HoveredRootWindow; // Will catch mouse inputs (for focus/move only)
|
ImGuiWindow* HoveredRootWindow; // == HoveredWindow ? HoveredWindow->RootWindow : NULL, merely a shortcut to avoid null test in some situation.
|
||||||
ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actually window that is moved is generally MovingWindow->RootWindow.
|
ImGuiWindow* HoveredWindowUnderMovingWindow; // Hovered window ignoring MovingWindow. Only set if MovingWindow is set.
|
||||||
|
ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actual window that is moved is generally MovingWindow->RootWindow.
|
||||||
ImGuiWindow* WheelingWindow; // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window.
|
ImGuiWindow* WheelingWindow; // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window.
|
||||||
ImVec2 WheelingWindowRefMousePos;
|
ImVec2 WheelingWindowRefMousePos;
|
||||||
float WheelingWindowTimer;
|
float WheelingWindowTimer;
|
||||||
|
|
||||||
// Item/widgets state and tracking information
|
// Item/widgets state and tracking information
|
||||||
ImGuiID HoveredId; // Hovered widget
|
ImGuiID HoveredId; // Hovered widget
|
||||||
bool HoveredIdAllowOverlap;
|
|
||||||
ImGuiID HoveredIdPreviousFrame;
|
ImGuiID HoveredIdPreviousFrame;
|
||||||
|
bool HoveredIdAllowOverlap;
|
||||||
|
bool HoveredIdDisabled; // At least one widget passed the rect test, but has been discarded by disabled flag or popup inhibit. May be true even if HoveredId == 0.
|
||||||
float HoveredIdTimer; // Measure contiguous hovering time
|
float HoveredIdTimer; // Measure contiguous hovering time
|
||||||
float HoveredIdNotActiveTimer; // Measure contiguous hovering time where the item has not been active
|
float HoveredIdNotActiveTimer; // Measure contiguous hovering time where the item has not been active
|
||||||
ImGuiID ActiveId; // Active widget
|
ImGuiID ActiveId; // Active widget
|
||||||
@ -1146,6 +1152,7 @@ struct ImGuiContext
|
|||||||
float ActiveIdTimer;
|
float ActiveIdTimer;
|
||||||
bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
|
bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
|
||||||
bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
|
bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
|
||||||
|
bool ActiveIdNoClearOnFocusLoss; // Disable losing active id if the active id window gets unfocused.
|
||||||
bool ActiveIdHasBeenPressedBefore; // Track whether the active id led to a press (this is to allow changing between PressOnClick and PressOnRelease without pressing twice). Used by range_select branch.
|
bool ActiveIdHasBeenPressedBefore; // Track whether the active id led to a press (this is to allow changing between PressOnClick and PressOnRelease without pressing twice). Used by range_select branch.
|
||||||
bool ActiveIdHasBeenEditedBefore; // Was the value associated to the widget Edited over the course of the Active state.
|
bool ActiveIdHasBeenEditedBefore; // Was the value associated to the widget Edited over the course of the Active state.
|
||||||
bool ActiveIdHasBeenEditedThisFrame;
|
bool ActiveIdHasBeenEditedThisFrame;
|
||||||
@ -1188,11 +1195,11 @@ struct ImGuiContext
|
|||||||
ImGuiKeyModFlags NavJustMovedToKeyMods;
|
ImGuiKeyModFlags NavJustMovedToKeyMods;
|
||||||
ImGuiID NavNextActivateId; // Set by ActivateItem(), queued until next frame.
|
ImGuiID NavNextActivateId; // Set by ActivateItem(), queued until next frame.
|
||||||
ImGuiInputSource NavInputSource; // Keyboard or Gamepad mode? THIS WILL ONLY BE None or NavGamepad or NavKeyboard.
|
ImGuiInputSource NavInputSource; // Keyboard or Gamepad mode? THIS WILL ONLY BE None or NavGamepad or NavKeyboard.
|
||||||
ImRect NavScoringRect; // Rectangle used for scoring, in screen space. Based of window->DC.NavRefRectRel[], modified for directional navigation scoring.
|
ImRect NavScoringRect; // Rectangle used for scoring, in screen space. Based of window->NavRectRel[], modified for directional navigation scoring.
|
||||||
int NavScoringCount; // Metrics for debugging
|
int NavScoringCount; // Metrics for debugging
|
||||||
ImGuiNavLayer NavLayer; // Layer we are navigating on. For now the system is hard-coded for 0=main contents and 1=menu/title bar, may expose layers later.
|
ImGuiNavLayer NavLayer; // Layer we are navigating on. For now the system is hard-coded for 0=main contents and 1=menu/title bar, may expose layers later.
|
||||||
int NavIdTabCounter; // == NavWindow->DC.FocusIdxTabCounter at time of NavId processing
|
int NavIdTabCounter; // == NavWindow->DC.FocusIdxTabCounter at time of NavId processing
|
||||||
bool NavIdIsAlive; // Nav widget has been seen this frame ~~ NavRefRectRel is valid
|
bool NavIdIsAlive; // Nav widget has been seen this frame ~~ NavRectRel is valid
|
||||||
bool NavMousePosDirty; // When set we will update mouse position if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) if set (NB: this not enabled by default)
|
bool NavMousePosDirty; // When set we will update mouse position if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) if set (NB: this not enabled by default)
|
||||||
bool NavDisableHighlight; // When user starts using mouse, we hide gamepad/keyboard highlight (NB: but they are still available, which is why NavDisableHighlight isn't always != NavDisableMouseHover)
|
bool NavDisableHighlight; // When user starts using mouse, we hide gamepad/keyboard highlight (NB: but they are still available, which is why NavDisableHighlight isn't always != NavDisableMouseHover)
|
||||||
bool NavDisableMouseHover; // When user starts using gamepad/keyboard, we hide mouse hovering highlight until mouse is touched again.
|
bool NavDisableMouseHover; // When user starts using gamepad/keyboard, we hide mouse hovering highlight until mouse is touched again.
|
||||||
@ -1201,7 +1208,6 @@ struct ImGuiContext
|
|||||||
bool NavInitRequestFromMove;
|
bool NavInitRequestFromMove;
|
||||||
ImGuiID NavInitResultId; // Init request result (first item of the window, or one for which SetItemDefaultFocus() was called)
|
ImGuiID NavInitResultId; // Init request result (first item of the window, or one for which SetItemDefaultFocus() was called)
|
||||||
ImRect NavInitResultRectRel; // Init request result rectangle (relative to parent window)
|
ImRect NavInitResultRectRel; // Init request result rectangle (relative to parent window)
|
||||||
bool NavMoveFromClampedRefRect; // Set by manual scrolling, if we scroll to a point where NavId isn't visible we reset navigation from visible items
|
|
||||||
bool NavMoveRequest; // Move request for this frame
|
bool NavMoveRequest; // Move request for this frame
|
||||||
ImGuiNavMoveFlags NavMoveRequestFlags;
|
ImGuiNavMoveFlags NavMoveRequestFlags;
|
||||||
ImGuiNavForward NavMoveRequestForward; // None / ForwardQueued / ForwardActive (this is used to navigate sibling parent menus from a child menu)
|
ImGuiNavForward NavMoveRequestForward; // None / ForwardQueued / ForwardActive (this is used to navigate sibling parent menus from a child menu)
|
||||||
@ -1274,6 +1280,8 @@ struct ImGuiContext
|
|||||||
float ColorEditLastSat; // Backup of last Saturation associated to LastColor[3], so we can restore Saturation in lossy RGB<>HSV round trips
|
float ColorEditLastSat; // Backup of last Saturation associated to LastColor[3], so we can restore Saturation in lossy RGB<>HSV round trips
|
||||||
float ColorEditLastColor[3];
|
float ColorEditLastColor[3];
|
||||||
ImVec4 ColorPickerRef; // Initial/reference color at the time of opening the color picker.
|
ImVec4 ColorPickerRef; // Initial/reference color at the time of opening the color picker.
|
||||||
|
float SliderCurrentAccum; // Accumulated slider delta when using navigation controls.
|
||||||
|
bool SliderCurrentAccumDirty; // Has the accumulated slider delta changed since last time we tried to apply it?
|
||||||
bool DragCurrentAccumDirty;
|
bool DragCurrentAccumDirty;
|
||||||
float DragCurrentAccum; // Accumulator for dragging modification. Always high-precision, not rounded by end-user precision settings
|
float DragCurrentAccum; // Accumulator for dragging modification. Always high-precision, not rounded by end-user precision settings
|
||||||
float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
|
float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
|
||||||
@ -1285,6 +1293,7 @@ struct ImGuiContext
|
|||||||
// Platform support
|
// Platform support
|
||||||
ImVec2 PlatformImePos; // Cursor position request & last passed to the OS Input Method Editor
|
ImVec2 PlatformImePos; // Cursor position request & last passed to the OS Input Method Editor
|
||||||
ImVec2 PlatformImeLastPos;
|
ImVec2 PlatformImeLastPos;
|
||||||
|
char PlatformLocaleDecimalPoint; // '.' or *localeconv()->decimal_point
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
bool SettingsLoaded;
|
bool SettingsLoaded;
|
||||||
@ -1315,7 +1324,7 @@ struct ImGuiContext
|
|||||||
int WantCaptureMouseNextFrame; // Explicit capture via CaptureKeyboardFromApp()/CaptureMouseFromApp() sets those flags
|
int WantCaptureMouseNextFrame; // Explicit capture via CaptureKeyboardFromApp()/CaptureMouseFromApp() sets those flags
|
||||||
int WantCaptureKeyboardNextFrame;
|
int WantCaptureKeyboardNextFrame;
|
||||||
int WantTextInputNextFrame;
|
int WantTextInputNextFrame;
|
||||||
char TempBuffer[1024*3+1]; // Temporary text buffer
|
char TempBuffer[1024 * 3 + 1]; // Temporary text buffer
|
||||||
|
|
||||||
ImGuiContext(ImFontAtlas* shared_font_atlas) : BackgroundDrawList(&DrawListSharedData), ForegroundDrawList(&DrawListSharedData)
|
ImGuiContext(ImFontAtlas* shared_font_atlas) : BackgroundDrawList(&DrawListSharedData), ForegroundDrawList(&DrawListSharedData)
|
||||||
{
|
{
|
||||||
@ -1336,26 +1345,28 @@ struct ImGuiContext
|
|||||||
CurrentWindow = NULL;
|
CurrentWindow = NULL;
|
||||||
HoveredWindow = NULL;
|
HoveredWindow = NULL;
|
||||||
HoveredRootWindow = NULL;
|
HoveredRootWindow = NULL;
|
||||||
|
HoveredWindowUnderMovingWindow = NULL;
|
||||||
MovingWindow = NULL;
|
MovingWindow = NULL;
|
||||||
WheelingWindow = NULL;
|
WheelingWindow = NULL;
|
||||||
WheelingWindowTimer = 0.0f;
|
WheelingWindowTimer = 0.0f;
|
||||||
|
|
||||||
HoveredId = 0;
|
HoveredId = HoveredIdPreviousFrame = 0;
|
||||||
HoveredIdAllowOverlap = false;
|
HoveredIdAllowOverlap = false;
|
||||||
HoveredIdPreviousFrame = 0;
|
HoveredIdDisabled = false;
|
||||||
HoveredIdTimer = HoveredIdNotActiveTimer = 0.0f;
|
HoveredIdTimer = HoveredIdNotActiveTimer = 0.0f;
|
||||||
ActiveId = 0;
|
ActiveId = 0;
|
||||||
ActiveIdIsAlive = 0;
|
ActiveIdIsAlive = 0;
|
||||||
ActiveIdTimer = 0.0f;
|
ActiveIdTimer = 0.0f;
|
||||||
ActiveIdIsJustActivated = false;
|
ActiveIdIsJustActivated = false;
|
||||||
ActiveIdAllowOverlap = false;
|
ActiveIdAllowOverlap = false;
|
||||||
|
ActiveIdNoClearOnFocusLoss = false;
|
||||||
ActiveIdHasBeenPressedBefore = false;
|
ActiveIdHasBeenPressedBefore = false;
|
||||||
ActiveIdHasBeenEditedBefore = false;
|
ActiveIdHasBeenEditedBefore = false;
|
||||||
ActiveIdHasBeenEditedThisFrame = false;
|
ActiveIdHasBeenEditedThisFrame = false;
|
||||||
ActiveIdUsingNavDirMask = 0x00;
|
ActiveIdUsingNavDirMask = 0x00;
|
||||||
ActiveIdUsingNavInputMask = 0x00;
|
ActiveIdUsingNavInputMask = 0x00;
|
||||||
ActiveIdUsingKeyInputMask = 0x00;
|
ActiveIdUsingKeyInputMask = 0x00;
|
||||||
ActiveIdClickOffset = ImVec2(-1,-1);
|
ActiveIdClickOffset = ImVec2(-1, -1);
|
||||||
ActiveIdWindow = NULL;
|
ActiveIdWindow = NULL;
|
||||||
ActiveIdSource = ImGuiInputSource_None;
|
ActiveIdSource = ImGuiInputSource_None;
|
||||||
ActiveIdMouseButton = 0;
|
ActiveIdMouseButton = 0;
|
||||||
@ -1383,7 +1394,6 @@ struct ImGuiContext
|
|||||||
NavInitRequest = false;
|
NavInitRequest = false;
|
||||||
NavInitRequestFromMove = false;
|
NavInitRequestFromMove = false;
|
||||||
NavInitResultId = 0;
|
NavInitResultId = 0;
|
||||||
NavMoveFromClampedRefRect = false;
|
|
||||||
NavMoveRequest = false;
|
NavMoveRequest = false;
|
||||||
NavMoveRequestFlags = ImGuiNavMoveFlags_None;
|
NavMoveRequestFlags = ImGuiNavMoveFlags_None;
|
||||||
NavMoveRequestForward = ImGuiNavForward_None;
|
NavMoveRequestForward = ImGuiNavForward_None;
|
||||||
@ -1425,6 +1435,8 @@ struct ImGuiContext
|
|||||||
ColorEditOptions = ImGuiColorEditFlags__OptionsDefault;
|
ColorEditOptions = ImGuiColorEditFlags__OptionsDefault;
|
||||||
ColorEditLastHue = ColorEditLastSat = 0.0f;
|
ColorEditLastHue = ColorEditLastSat = 0.0f;
|
||||||
ColorEditLastColor[0] = ColorEditLastColor[1] = ColorEditLastColor[2] = FLT_MAX;
|
ColorEditLastColor[0] = ColorEditLastColor[1] = ColorEditLastColor[2] = FLT_MAX;
|
||||||
|
SliderCurrentAccum = 0.0f;
|
||||||
|
SliderCurrentAccumDirty = false;
|
||||||
DragCurrentAccumDirty = false;
|
DragCurrentAccumDirty = false;
|
||||||
DragCurrentAccum = 0.0f;
|
DragCurrentAccum = 0.0f;
|
||||||
DragSpeedDefaultRatio = 1.0f / 100.0f;
|
DragSpeedDefaultRatio = 1.0f / 100.0f;
|
||||||
@ -1432,6 +1444,7 @@ struct ImGuiContext
|
|||||||
TooltipOverrideCount = 0;
|
TooltipOverrideCount = 0;
|
||||||
|
|
||||||
PlatformImePos = PlatformImeLastPos = ImVec2(FLT_MAX, FLT_MAX);
|
PlatformImePos = PlatformImeLastPos = ImVec2(FLT_MAX, FLT_MAX);
|
||||||
|
PlatformLocaleDecimalPoint = '.';
|
||||||
|
|
||||||
SettingsLoaded = false;
|
SettingsLoaded = false;
|
||||||
SettingsDirtyTimer = 0.0f;
|
SettingsDirtyTimer = 0.0f;
|
||||||
@ -1484,9 +1497,8 @@ struct IMGUI_API ImGuiWindowTempData
|
|||||||
|
|
||||||
// Keyboard/Gamepad navigation
|
// Keyboard/Gamepad navigation
|
||||||
ImGuiNavLayer NavLayerCurrent; // Current layer, 0..31 (we currently only use 0..1)
|
ImGuiNavLayer NavLayerCurrent; // Current layer, 0..31 (we currently only use 0..1)
|
||||||
int NavLayerCurrentMask; // = (1 << NavLayerCurrent) used by ItemAdd prior to clipping.
|
int NavLayerActiveMask; // Which layers have been written to (result from previous frame)
|
||||||
int NavLayerActiveMask; // Which layer have been written to (result from previous frame)
|
int NavLayerActiveMaskNext; // Which layers have been written to (accumulator for current frame)
|
||||||
int NavLayerActiveMaskNext; // Which layer have been written to (buffer for current frame)
|
|
||||||
ImGuiID NavFocusScopeIdCurrent; // Current focus scope ID while appending
|
ImGuiID NavFocusScopeIdCurrent; // Current focus scope ID while appending
|
||||||
bool NavHideHighlightOneFrame;
|
bool NavHideHighlightOneFrame;
|
||||||
bool NavHasScroll; // Set when scrolling can be used (ScrollMax > 0.0f)
|
bool NavHasScroll; // Set when scrolling can be used (ScrollMax > 0.0f)
|
||||||
@ -1531,7 +1543,6 @@ struct IMGUI_API ImGuiWindowTempData
|
|||||||
|
|
||||||
NavLayerActiveMask = NavLayerActiveMaskNext = 0x00;
|
NavLayerActiveMask = NavLayerActiveMaskNext = 0x00;
|
||||||
NavLayerCurrent = ImGuiNavLayer_Main;
|
NavLayerCurrent = ImGuiNavLayer_Main;
|
||||||
NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
|
|
||||||
NavFocusScopeIdCurrent = 0;
|
NavFocusScopeIdCurrent = 0;
|
||||||
NavHideHighlightOneFrame = false;
|
NavHideHighlightOneFrame = false;
|
||||||
NavHasScroll = false;
|
NavHasScroll = false;
|
||||||
@ -1573,6 +1584,7 @@ struct IMGUI_API ImGuiWindow
|
|||||||
ImVec2 ScrollMax;
|
ImVec2 ScrollMax;
|
||||||
ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change)
|
ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change)
|
||||||
ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
|
ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
|
||||||
|
ImVec2 ScrollTargetEdgeSnapDist; // 0.0f = no snapping, >0.0f snapping threshold
|
||||||
ImVec2 ScrollbarSizes; // Size taken by each scrollbars on their smaller axis. Pay attention! ScrollbarSizes.x == width of the vertical scrollbar, ScrollbarSizes.y = height of the horizontal scrollbar.
|
ImVec2 ScrollbarSizes; // Size taken by each scrollbars on their smaller axis. Pay attention! ScrollbarSizes.x == width of the vertical scrollbar, ScrollbarSizes.y = height of the horizontal scrollbar.
|
||||||
bool ScrollbarX, ScrollbarY; // Are scrollbars visible?
|
bool ScrollbarX, ScrollbarY; // Are scrollbars visible?
|
||||||
bool Active; // Set to true on Begin(), unless Collapsed
|
bool Active; // Set to true on Begin(), unless Collapsed
|
||||||
@ -1610,9 +1622,12 @@ struct IMGUI_API ImGuiWindow
|
|||||||
ImRect OuterRectClipped; // == Window->Rect() just after setup in Begin(). == window->Rect() for root window.
|
ImRect OuterRectClipped; // == Window->Rect() just after setup in Begin(). == window->Rect() for root window.
|
||||||
ImRect InnerRect; // Inner rectangle (omit title bar, menu bar, scroll bar)
|
ImRect InnerRect; // Inner rectangle (omit title bar, menu bar, scroll bar)
|
||||||
ImRect InnerClipRect; // == InnerRect shrunk by WindowPadding*0.5f on each side, clipped within viewport or parent clip rect.
|
ImRect InnerClipRect; // == InnerRect shrunk by WindowPadding*0.5f on each side, clipped within viewport or parent clip rect.
|
||||||
ImRect WorkRect; // Cover the whole scrolling region, shrunk by WindowPadding*1.0f on each side. This is meant to replace ContentRegionRect over time (from 1.71+ onward).
|
ImRect WorkRect; // Initially covers the whole scrolling region. Reduced by containers e.g columns/tables when active. Shrunk by WindowPadding*1.0f on each side. This is meant to replace ContentRegionRect over time (from 1.71+ onward).
|
||||||
|
ImRect ParentWorkRect; // Backup of WorkRect before entering a container such as columns/tables. Used by e.g. SpanAllColumns functions to easily access. Stacked containers are responsible for maintaining this. // FIXME-WORKRECT: Could be a stack?
|
||||||
ImRect ClipRect; // Current clipping/scissoring rectangle, evolve as we are using PushClipRect(), etc. == DrawList->clip_rect_stack.back().
|
ImRect ClipRect; // Current clipping/scissoring rectangle, evolve as we are using PushClipRect(), etc. == DrawList->clip_rect_stack.back().
|
||||||
ImRect ContentRegionRect; // FIXME: This is currently confusing/misleading. It is essentially WorkRect but not handling of scrolling. We currently rely on it as right/bottom aligned sizing operation need some size to rely on.
|
ImRect ContentRegionRect; // FIXME: This is currently confusing/misleading. It is essentially WorkRect but not handling of scrolling. We currently rely on it as right/bottom aligned sizing operation need some size to rely on.
|
||||||
|
ImVec2ih HitTestHoleSize; // Define an optional rectangular hole where mouse will pass-through the window.
|
||||||
|
ImVec2ih HitTestHoleOffset;
|
||||||
|
|
||||||
int LastFrameActive; // Last frame number the window was Active.
|
int LastFrameActive; // Last frame number the window was Active.
|
||||||
float LastTimeActive; // Last timestamp the window was Active (using float as we don't need high precision there)
|
float LastTimeActive; // Last timestamp the window was Active (using float as we don't need high precision there)
|
||||||
@ -1625,7 +1640,7 @@ struct IMGUI_API ImGuiWindow
|
|||||||
ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer)
|
ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer)
|
||||||
ImDrawList DrawListInst;
|
ImDrawList DrawListInst;
|
||||||
ImGuiWindow* ParentWindow; // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL.
|
ImGuiWindow* ParentWindow; // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL.
|
||||||
ImGuiWindow* RootWindow; // Point to ourself or first ancestor that is not a child window.
|
ImGuiWindow* RootWindow; // Point to ourself or first ancestor that is not a child window == Top-level window.
|
||||||
ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.
|
ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.
|
||||||
ImGuiWindow* RootWindowForNav; // Point to ourself or first ancestor which doesn't have the NavFlattened flag.
|
ImGuiWindow* RootWindowForNav; // Point to ourself or first ancestor which doesn't have the NavFlattened flag.
|
||||||
|
|
||||||
@ -1650,7 +1665,7 @@ public:
|
|||||||
ImGuiID GetIDFromRectangle(const ImRect& r_abs);
|
ImGuiID GetIDFromRectangle(const ImRect& r_abs);
|
||||||
|
|
||||||
// We don't use g.FontSize because the window may be != g.CurrentWidow.
|
// We don't use g.FontSize because the window may be != g.CurrentWidow.
|
||||||
ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x+Size.x, Pos.y+Size.y); }
|
ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
|
||||||
float CalcFontSize() const { ImGuiContext& g = *GImGui; float scale = g.FontBaseSize * FontWindowScale; if (ParentWindow) scale *= ParentWindow->FontWindowScale; return scale; }
|
float CalcFontSize() const { ImGuiContext& g = *GImGui; float scale = g.FontBaseSize * FontWindowScale; if (ParentWindow) scale *= ParentWindow->FontWindowScale; return scale; }
|
||||||
float TitleBarHeight() const { ImGuiContext& g = *GImGui; return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + g.Style.FramePadding.y * 2.0f; }
|
float TitleBarHeight() const { ImGuiContext& g = *GImGui; return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + g.Style.FramePadding.y * 2.0f; }
|
||||||
ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); }
|
ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); }
|
||||||
@ -1659,14 +1674,14 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Backup and restore just enough data to be able to use IsItemHovered() on item A after another B in the same window has overwritten the data.
|
// Backup and restore just enough data to be able to use IsItemHovered() on item A after another B in the same window has overwritten the data.
|
||||||
struct ImGuiItemHoveredDataBackup
|
struct ImGuiLastItemDataBackup
|
||||||
{
|
{
|
||||||
ImGuiID LastItemId;
|
ImGuiID LastItemId;
|
||||||
ImGuiItemStatusFlags LastItemStatusFlags;
|
ImGuiItemStatusFlags LastItemStatusFlags;
|
||||||
ImRect LastItemRect;
|
ImRect LastItemRect;
|
||||||
ImRect LastItemDisplayRect;
|
ImRect LastItemDisplayRect;
|
||||||
|
|
||||||
ImGuiItemHoveredDataBackup() { Backup(); }
|
ImGuiLastItemDataBackup() { Backup(); }
|
||||||
void Backup() { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemStatusFlags = window->DC.LastItemStatusFlags; LastItemRect = window->DC.LastItemRect; LastItemDisplayRect = window->DC.LastItemDisplayRect; }
|
void Backup() { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemStatusFlags = window->DC.LastItemStatusFlags; LastItemRect = window->DC.LastItemRect; LastItemDisplayRect = window->DC.LastItemDisplayRect; }
|
||||||
void Restore() const { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemStatusFlags = LastItemStatusFlags; window->DC.LastItemRect = LastItemRect; window->DC.LastItemDisplayRect = LastItemDisplayRect; }
|
void Restore() const { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemStatusFlags = LastItemStatusFlags; window->DC.LastItemRect = LastItemRect; window->DC.LastItemDisplayRect = LastItemDisplayRect; }
|
||||||
};
|
};
|
||||||
@ -1686,22 +1701,26 @@ enum ImGuiTabBarFlagsPrivate_
|
|||||||
// Extend ImGuiTabItemFlags_
|
// Extend ImGuiTabItemFlags_
|
||||||
enum ImGuiTabItemFlagsPrivate_
|
enum ImGuiTabItemFlagsPrivate_
|
||||||
{
|
{
|
||||||
ImGuiTabItemFlags_NoCloseButton = 1 << 20 // Track whether p_open was set or not (we'll need this info on the next frame to recompute ContentWidth during layout)
|
ImGuiTabItemFlags_NoCloseButton = 1 << 20, // Track whether p_open was set or not (we'll need this info on the next frame to recompute ContentWidth during layout)
|
||||||
|
ImGuiTabItemFlags_Button = 1 << 21 // Used by TabItemButton, change the tab item behavior to mimic a button
|
||||||
};
|
};
|
||||||
|
|
||||||
// Storage for one active tab item (sizeof() 26~32 bytes)
|
// Storage for one active tab item (sizeof() 28~32 bytes)
|
||||||
struct ImGuiTabItem
|
struct ImGuiTabItem
|
||||||
{
|
{
|
||||||
ImGuiID ID;
|
ImGuiID ID;
|
||||||
ImGuiTabItemFlags Flags;
|
ImGuiTabItemFlags Flags;
|
||||||
int LastFrameVisible;
|
int LastFrameVisible;
|
||||||
int LastFrameSelected; // This allows us to infer an ordered list of the last activated tabs with little maintenance
|
int LastFrameSelected; // This allows us to infer an ordered list of the last activated tabs with little maintenance
|
||||||
int NameOffset; // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames
|
|
||||||
float Offset; // Position relative to beginning of tab
|
float Offset; // Position relative to beginning of tab
|
||||||
float Width; // Width currently displayed
|
float Width; // Width currently displayed
|
||||||
float ContentWidth; // Width of actual contents, stored during BeginTabItem() call
|
float ContentWidth; // Width of label, stored during BeginTabItem() call
|
||||||
|
ImS16 NameOffset; // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames
|
||||||
|
ImS8 BeginOrder; // BeginTabItem() order, used to re-order tabs after toggling ImGuiTabBarFlags_Reorderable
|
||||||
|
ImS8 IndexDuringLayout; // Index only used during TabBarLayout()
|
||||||
|
bool WantClose; // Marked as closed by SetTabItemClosed()
|
||||||
|
|
||||||
ImGuiTabItem() { ID = 0; Flags = ImGuiTabItemFlags_None; LastFrameVisible = LastFrameSelected = -1; NameOffset = -1; Offset = Width = ContentWidth = 0.0f; }
|
ImGuiTabItem() { ID = 0; Flags = ImGuiTabItemFlags_None; LastFrameVisible = LastFrameSelected = -1; NameOffset = -1; Offset = Width = ContentWidth = 0.0f; BeginOrder = -1; IndexDuringLayout = -1; WantClose = false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Storage for a tab bar (sizeof() 92~96 bytes)
|
// Storage for a tab bar (sizeof() 92~96 bytes)
|
||||||
@ -1716,19 +1735,22 @@ struct ImGuiTabBar
|
|||||||
int PrevFrameVisible;
|
int PrevFrameVisible;
|
||||||
ImRect BarRect;
|
ImRect BarRect;
|
||||||
float LastTabContentHeight; // Record the height of contents submitted below the tab bar
|
float LastTabContentHeight; // Record the height of contents submitted below the tab bar
|
||||||
float OffsetMax; // Distance from BarRect.Min.x, locked during layout
|
float WidthAllTabs; // Actual width of all tabs (locked during layout)
|
||||||
float OffsetMaxIdeal; // Ideal offset if all tabs were visible and not clipped
|
float WidthAllTabsIdeal; // Ideal width if all tabs were visible and not clipped
|
||||||
float OffsetNextTab; // Distance from BarRect.Min.x, incremented with each BeginTabItem() call, not used if ImGuiTabBarFlags_Reorderable if set.
|
|
||||||
float ScrollingAnim;
|
float ScrollingAnim;
|
||||||
float ScrollingTarget;
|
float ScrollingTarget;
|
||||||
float ScrollingTargetDistToVisibility;
|
float ScrollingTargetDistToVisibility;
|
||||||
float ScrollingSpeed;
|
float ScrollingSpeed;
|
||||||
|
float ScrollingRectMinX;
|
||||||
|
float ScrollingRectMaxX;
|
||||||
ImGuiTabBarFlags Flags;
|
ImGuiTabBarFlags Flags;
|
||||||
ImGuiID ReorderRequestTabId;
|
ImGuiID ReorderRequestTabId;
|
||||||
ImS8 ReorderRequestDir;
|
ImS8 ReorderRequestDir;
|
||||||
|
ImS8 TabsActiveCount; // Number of tabs submitted this frame.
|
||||||
bool WantLayout;
|
bool WantLayout;
|
||||||
bool VisibleTabWasSubmitted;
|
bool VisibleTabWasSubmitted;
|
||||||
short LastTabItemIdx; // For BeginTabItem()/EndTabItem()
|
bool TabsAddedNew; // Set to true when a new tab item or button has been added to the tab bar during last frame
|
||||||
|
short LastTabItemIdx; // Index of last BeginTabItem() tab for use by EndTabItem()
|
||||||
ImVec2 FramePadding; // style.FramePadding locked at the time of BeginTabBar()
|
ImVec2 FramePadding; // style.FramePadding locked at the time of BeginTabBar()
|
||||||
ImGuiTextBuffer TabsNames; // For non-docking tab bar we re-append names in a contiguous buffer.
|
ImGuiTextBuffer TabsNames; // For non-docking tab bar we re-append names in a contiguous buffer.
|
||||||
|
|
||||||
@ -1736,7 +1758,7 @@ struct ImGuiTabBar
|
|||||||
int GetTabOrder(const ImGuiTabItem* tab) const { return Tabs.index_from_ptr(tab); }
|
int GetTabOrder(const ImGuiTabItem* tab) const { return Tabs.index_from_ptr(tab); }
|
||||||
const char* GetTabName(const ImGuiTabItem* tab) const
|
const char* GetTabName(const ImGuiTabItem* tab) const
|
||||||
{
|
{
|
||||||
IM_ASSERT(tab->NameOffset != -1 && tab->NameOffset < TabsNames.Buf.Size);
|
IM_ASSERT(tab->NameOffset != -1 && (int)tab->NameOffset < TabsNames.Buf.Size);
|
||||||
return TabsNames.Buf.Data + tab->NameOffset;
|
return TabsNames.Buf.Data + tab->NameOffset;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1773,6 +1795,7 @@ namespace ImGui
|
|||||||
IMGUI_API void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond = 0);
|
IMGUI_API void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond = 0);
|
||||||
IMGUI_API void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond = 0);
|
IMGUI_API void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond = 0);
|
||||||
IMGUI_API void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond = 0);
|
IMGUI_API void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond = 0);
|
||||||
|
IMGUI_API void SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size);
|
||||||
|
|
||||||
// Windows: Display Order and Focus Order
|
// Windows: Display Order and Focus Order
|
||||||
IMGUI_API void FocusWindow(ImGuiWindow* window);
|
IMGUI_API void FocusWindow(ImGuiWindow* window);
|
||||||
@ -1807,10 +1830,10 @@ namespace ImGui
|
|||||||
|
|
||||||
// Scrolling
|
// Scrolling
|
||||||
IMGUI_API void SetNextWindowScroll(const ImVec2& scroll); // Use -1.0f on one axis to leave as-is
|
IMGUI_API void SetNextWindowScroll(const ImVec2& scroll); // Use -1.0f on one axis to leave as-is
|
||||||
IMGUI_API void SetScrollX(ImGuiWindow* window, float new_scroll_x);
|
IMGUI_API void SetScrollX(ImGuiWindow* window, float scroll_x);
|
||||||
IMGUI_API void SetScrollY(ImGuiWindow* window, float new_scroll_y);
|
IMGUI_API void SetScrollY(ImGuiWindow* window, float scroll_y);
|
||||||
IMGUI_API void SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio = 0.5f);
|
IMGUI_API void SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio);
|
||||||
IMGUI_API void SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y_ratio = 0.5f);
|
IMGUI_API void SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y_ratio);
|
||||||
IMGUI_API ImVec2 ScrollToBringRectIntoView(ImGuiWindow* window, const ImRect& item_rect);
|
IMGUI_API ImVec2 ScrollToBringRectIntoView(ImGuiWindow* window, const ImRect& item_rect);
|
||||||
|
|
||||||
// Basic Accessors
|
// Basic Accessors
|
||||||
@ -1826,6 +1849,7 @@ namespace ImGui
|
|||||||
IMGUI_API void KeepAliveID(ImGuiID id);
|
IMGUI_API void KeepAliveID(ImGuiID id);
|
||||||
IMGUI_API void MarkItemEdited(ImGuiID id); // Mark data associated to given item as "edited", used by IsItemDeactivatedAfterEdit() function.
|
IMGUI_API void MarkItemEdited(ImGuiID id); // Mark data associated to given item as "edited", used by IsItemDeactivatedAfterEdit() function.
|
||||||
IMGUI_API void PushOverrideID(ImGuiID id); // Push given value as-is at the top of the ID stack (whereas PushID combines old and new hashes)
|
IMGUI_API void PushOverrideID(ImGuiID id); // Push given value as-is at the top of the ID stack (whereas PushID combines old and new hashes)
|
||||||
|
IMGUI_API ImGuiID GetIDWithSeed(const char* str_id_begin, const char* str_id_end, ImGuiID seed);
|
||||||
|
|
||||||
// Basic Helpers for widget code
|
// Basic Helpers for widget code
|
||||||
IMGUI_API void ItemSize(const ImVec2& size, float text_baseline_y = -1.0f);
|
IMGUI_API void ItemSize(const ImVec2& size, float text_baseline_y = -1.0f);
|
||||||
@ -1833,6 +1857,7 @@ namespace ImGui
|
|||||||
IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL);
|
IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL);
|
||||||
IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id);
|
IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id);
|
||||||
IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
|
IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
|
||||||
|
IMGUI_API void SetLastItemData(ImGuiWindow* window, ImGuiID item_id, ImGuiItemStatusFlags status_flags, const ImRect& item_rect);
|
||||||
IMGUI_API bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id); // Return true if focus is requested
|
IMGUI_API bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id); // Return true if focus is requested
|
||||||
IMGUI_API void FocusableItemUnregister(ImGuiWindow* window);
|
IMGUI_API void FocusableItemUnregister(ImGuiWindow* window);
|
||||||
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_w, float default_h);
|
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_w, float default_h);
|
||||||
@ -1858,7 +1883,7 @@ namespace ImGui
|
|||||||
IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags);
|
IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags);
|
||||||
IMGUI_API ImGuiWindow* GetTopMostPopupModal();
|
IMGUI_API ImGuiWindow* GetTopMostPopupModal();
|
||||||
IMGUI_API ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window);
|
IMGUI_API ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window);
|
||||||
IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy = ImGuiPopupPositionPolicy_Default);
|
IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy);
|
||||||
|
|
||||||
// Gamepad/Keyboard Navigation
|
// Gamepad/Keyboard Navigation
|
||||||
IMGUI_API void NavInitWindow(ImGuiWindow* window, bool force_reinit);
|
IMGUI_API void NavInitWindow(ImGuiWindow* window, bool force_reinit);
|
||||||
@ -1913,7 +1938,8 @@ namespace ImGui
|
|||||||
IMGUI_API ImGuiTabItem* TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id);
|
IMGUI_API ImGuiTabItem* TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id);
|
||||||
IMGUI_API void TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id);
|
IMGUI_API void TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id);
|
||||||
IMGUI_API void TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
|
IMGUI_API void TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
|
||||||
IMGUI_API void TabBarQueueChangeTabOrder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int dir);
|
IMGUI_API void TabBarQueueReorder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int dir);
|
||||||
|
IMGUI_API bool TabBarProcessReorder(ImGuiTabBar* tab_bar);
|
||||||
IMGUI_API bool TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags);
|
IMGUI_API bool TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags);
|
||||||
IMGUI_API ImVec2 TabItemCalcSize(const char* label, bool has_close_button);
|
IMGUI_API ImVec2 TabItemCalcSize(const char* label, bool has_close_button);
|
||||||
IMGUI_API void TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col);
|
IMGUI_API void TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col);
|
||||||
@ -1941,6 +1967,7 @@ namespace ImGui
|
|||||||
IMGUI_API void RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow);
|
IMGUI_API void RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow);
|
||||||
IMGUI_API void RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col);
|
IMGUI_API void RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col);
|
||||||
IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
|
IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
|
||||||
|
IMGUI_API void RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect inner, ImU32 col, float rounding);
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
// [1.71: 2019/06/07: Updating prototypes of some of the internal functions. Leaving those for reference for a short while]
|
// [1.71: 2019/06/07: Updating prototypes of some of the internal functions. Leaving those for reference for a short while]
|
||||||
@ -1956,7 +1983,7 @@ namespace ImGui
|
|||||||
IMGUI_API bool ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags = 0);
|
IMGUI_API bool ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags = 0);
|
||||||
IMGUI_API void Scrollbar(ImGuiAxis axis);
|
IMGUI_API void Scrollbar(ImGuiAxis axis);
|
||||||
IMGUI_API bool ScrollbarEx(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* p_scroll_v, float avail_v, float contents_v, ImDrawCornerFlags rounding_corners);
|
IMGUI_API bool ScrollbarEx(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* p_scroll_v, float avail_v, float contents_v, ImDrawCornerFlags rounding_corners);
|
||||||
IMGUI_API bool ImageButtonEx(ImGuiID id, ImTextureID texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec2& padding, const ImVec4& bg_col, const ImVec4& tint_col);
|
IMGUI_API bool ImageButtonEx(ImGuiID id, ImTextureID texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec2& padding, const ImVec4& bg_col, const ImVec4& tint_col);
|
||||||
IMGUI_API ImRect GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis);
|
IMGUI_API ImRect GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis);
|
||||||
IMGUI_API ImGuiID GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis);
|
IMGUI_API ImGuiID GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis);
|
||||||
IMGUI_API ImGuiID GetWindowResizeID(ImGuiWindow* window, int n); // 0..3: corners, 4..7: borders
|
IMGUI_API ImGuiID GetWindowResizeID(ImGuiWindow* window, int n); // 0..3: corners, 4..7: borders
|
||||||
@ -1964,8 +1991,8 @@ namespace ImGui
|
|||||||
|
|
||||||
// Widgets low-level behaviors
|
// Widgets low-level behaviors
|
||||||
IMGUI_API bool ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0);
|
IMGUI_API bool ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0);
|
||||||
IMGUI_API bool DragBehavior(ImGuiID id, ImGuiDataType data_type, void* p_v, float v_speed, const void* p_min, const void* p_max, const char* format, float power, ImGuiDragFlags flags);
|
IMGUI_API bool DragBehavior(ImGuiID id, ImGuiDataType data_type, void* p_v, float v_speed, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags);
|
||||||
IMGUI_API bool SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* p_v, const void* p_min, const void* p_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb);
|
IMGUI_API bool SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* p_v, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags, ImRect* out_grab_bb);
|
||||||
IMGUI_API bool SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend = 0.0f, float hover_visibility_delay = 0.0f);
|
IMGUI_API bool SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend = 0.0f, float hover_visibility_delay = 0.0f);
|
||||||
IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
|
IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
|
||||||
IMGUI_API bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextItemOpen() data, if any. May return true when logging
|
IMGUI_API bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextItemOpen() data, if any. May return true when logging
|
||||||
@ -1974,16 +2001,18 @@ namespace ImGui
|
|||||||
// Template functions are instantiated in imgui_widgets.cpp for a finite number of types.
|
// Template functions are instantiated in imgui_widgets.cpp for a finite number of types.
|
||||||
// To use them externally (for custom widget) you may need an "extern template" statement in your code in order to link to existing instances and silence Clang warnings (see #2036).
|
// To use them externally (for custom widget) you may need an "extern template" statement in your code in order to link to existing instances and silence Clang warnings (see #2036).
|
||||||
// e.g. " extern template IMGUI_API float RoundScalarWithFormatT<float, float>(const char* format, ImGuiDataType data_type, float v); "
|
// e.g. " extern template IMGUI_API float RoundScalarWithFormatT<float, float>(const char* format, ImGuiDataType data_type, float v); "
|
||||||
template<typename T, typename SIGNED_T, typename FLOAT_T> IMGUI_API bool DragBehaviorT(ImGuiDataType data_type, T* v, float v_speed, T v_min, T v_max, const char* format, float power, ImGuiDragFlags flags);
|
template<typename T, typename SIGNED_T, typename FLOAT_T> IMGUI_API float ScaleRatioFromValueT(ImGuiDataType data_type, T v, T v_min, T v_max, bool is_logarithmic, float logarithmic_zero_epsilon, float zero_deadzone_size);
|
||||||
template<typename T, typename SIGNED_T, typename FLOAT_T> IMGUI_API bool SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, T* v, T v_min, T v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb);
|
template<typename T, typename SIGNED_T, typename FLOAT_T> IMGUI_API T ScaleValueFromRatioT(ImGuiDataType data_type, float t, T v_min, T v_max, bool is_logarithmic, float logarithmic_zero_epsilon, float zero_deadzone_size);
|
||||||
template<typename T, typename FLOAT_T> IMGUI_API float SliderCalcRatioFromValueT(ImGuiDataType data_type, T v, T v_min, T v_max, float power, float linear_zero_pos);
|
template<typename T, typename SIGNED_T, typename FLOAT_T> IMGUI_API bool DragBehaviorT(ImGuiDataType data_type, T* v, float v_speed, T v_min, T v_max, const char* format, ImGuiSliderFlags flags);
|
||||||
|
template<typename T, typename SIGNED_T, typename FLOAT_T> IMGUI_API bool SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, T* v, T v_min, T v_max, const char* format, ImGuiSliderFlags flags, ImRect* out_grab_bb);
|
||||||
template<typename T, typename SIGNED_T> IMGUI_API T RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, T v);
|
template<typename T, typename SIGNED_T> IMGUI_API T RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, T v);
|
||||||
|
|
||||||
// Data type helpers
|
// Data type helpers
|
||||||
IMGUI_API const ImGuiDataTypeInfo* DataTypeGetInfo(ImGuiDataType data_type);
|
IMGUI_API const ImGuiDataTypeInfo* DataTypeGetInfo(ImGuiDataType data_type);
|
||||||
IMGUI_API int DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* p_data, const char* format);
|
IMGUI_API int DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* p_data, const char* format);
|
||||||
IMGUI_API void DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, void* arg_1, const void* arg_2);
|
IMGUI_API void DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, const void* arg_1, const void* arg_2);
|
||||||
IMGUI_API bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* p_data, const char* format);
|
IMGUI_API bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* p_data, const char* format);
|
||||||
|
IMGUI_API int DataTypeCompare(ImGuiDataType data_type, const void* arg_1, const void* arg_2);
|
||||||
IMGUI_API bool DataTypeClamp(ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max);
|
IMGUI_API bool DataTypeClamp(ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max);
|
||||||
|
|
||||||
// InputText
|
// InputText
|
||||||
@ -2021,6 +2050,7 @@ IMGUI_API void ImFontAtlasBuildInit(ImFontAtlas* atlas);
|
|||||||
IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
|
IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
|
||||||
IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque);
|
IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque);
|
||||||
IMGUI_API void ImFontAtlasBuildFinish(ImFontAtlas* atlas);
|
IMGUI_API void ImFontAtlasBuildFinish(ImFontAtlas* atlas);
|
||||||
|
IMGUI_API void ImFontAtlasBuildRender1bppRectFromString(ImFontAtlas* atlas, int atlas_x, int atlas_y, int w, int h, const char* in_str, char in_marker_char, unsigned char in_marker_pixel_value);
|
||||||
IMGUI_API void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_multiply_factor);
|
IMGUI_API void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_multiply_factor);
|
||||||
IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride);
|
IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride);
|
||||||
|
|
||||||
@ -2028,8 +2058,8 @@ IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned ch
|
|||||||
// [SECTION] Test Engine Hooks (imgui_test_engine)
|
// [SECTION] Test Engine Hooks (imgui_test_engine)
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
//#define IMGUI_ENABLE_TEST_ENGINE
|
|
||||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||||
|
extern void ImGuiTestEngineHook_Shutdown(ImGuiContext* ctx);
|
||||||
extern void ImGuiTestEngineHook_PreNewFrame(ImGuiContext* ctx);
|
extern void ImGuiTestEngineHook_PreNewFrame(ImGuiContext* ctx);
|
||||||
extern void ImGuiTestEngineHook_PostNewFrame(ImGuiContext* ctx);
|
extern void ImGuiTestEngineHook_PostNewFrame(ImGuiContext* ctx);
|
||||||
extern void ImGuiTestEngineHook_ItemAdd(ImGuiContext* ctx, const ImRect& bb, ImGuiID id);
|
extern void ImGuiTestEngineHook_ItemAdd(ImGuiContext* ctx, const ImRect& bb, ImGuiID id);
|
||||||
|
1494
imgui_widgets.cpp
1494
imgui_widgets.cpp
File diff suppressed because it is too large
Load Diff
@ -148,6 +148,8 @@
|
|||||||
// STB_TEXTEDIT_K_RIGHT keyboard input to move cursor right
|
// STB_TEXTEDIT_K_RIGHT keyboard input to move cursor right
|
||||||
// STB_TEXTEDIT_K_UP keyboard input to move cursor up
|
// STB_TEXTEDIT_K_UP keyboard input to move cursor up
|
||||||
// STB_TEXTEDIT_K_DOWN keyboard input to move cursor down
|
// STB_TEXTEDIT_K_DOWN keyboard input to move cursor down
|
||||||
|
// STB_TEXTEDIT_K_PGUP keyboard input to move cursor up a page
|
||||||
|
// STB_TEXTEDIT_K_PGDOWN keyboard input to move cursor down a page
|
||||||
// STB_TEXTEDIT_K_LINESTART keyboard input to move cursor to start of line // e.g. HOME
|
// STB_TEXTEDIT_K_LINESTART keyboard input to move cursor to start of line // e.g. HOME
|
||||||
// STB_TEXTEDIT_K_LINEEND keyboard input to move cursor to end of line // e.g. END
|
// STB_TEXTEDIT_K_LINEEND keyboard input to move cursor to end of line // e.g. END
|
||||||
// STB_TEXTEDIT_K_TEXTSTART keyboard input to move cursor to start of text // e.g. ctrl-HOME
|
// STB_TEXTEDIT_K_TEXTSTART keyboard input to move cursor to start of text // e.g. ctrl-HOME
|
||||||
@ -170,14 +172,10 @@
|
|||||||
// STB_TEXTEDIT_K_TEXTSTART2 secondary keyboard input to move cursor to start of text
|
// STB_TEXTEDIT_K_TEXTSTART2 secondary keyboard input to move cursor to start of text
|
||||||
// STB_TEXTEDIT_K_TEXTEND2 secondary keyboard input to move cursor to end of text
|
// STB_TEXTEDIT_K_TEXTEND2 secondary keyboard input to move cursor to end of text
|
||||||
//
|
//
|
||||||
// Todo:
|
|
||||||
// STB_TEXTEDIT_K_PGUP keyboard input to move cursor up a page
|
|
||||||
// STB_TEXTEDIT_K_PGDOWN keyboard input to move cursor down a page
|
|
||||||
//
|
|
||||||
// Keyboard input must be encoded as a single integer value; e.g. a character code
|
// Keyboard input must be encoded as a single integer value; e.g. a character code
|
||||||
// and some bitflags that represent shift states. to simplify the interface, SHIFT must
|
// and some bitflags that represent shift states. to simplify the interface, SHIFT must
|
||||||
// be a bitflag, so we can test the shifted state of cursor movements to allow selection,
|
// be a bitflag, so we can test the shifted state of cursor movements to allow selection,
|
||||||
// i.e. (STB_TEXTED_K_RIGHT|STB_TEXTEDIT_K_SHIFT) should be shifted right-arrow.
|
// i.e. (STB_TEXTEDIT_K_RIGHT|STB_TEXTEDIT_K_SHIFT) should be shifted right-arrow.
|
||||||
//
|
//
|
||||||
// You can encode other things, such as CONTROL or ALT, in additional bits, and
|
// You can encode other things, such as CONTROL or ALT, in additional bits, and
|
||||||
// then test for their presence in e.g. STB_TEXTEDIT_K_WORDLEFT. For example,
|
// then test for their presence in e.g. STB_TEXTEDIT_K_WORDLEFT. For example,
|
||||||
@ -337,6 +335,10 @@ typedef struct
|
|||||||
// each textfield keeps its own insert mode state. to keep an app-wide
|
// each textfield keeps its own insert mode state. to keep an app-wide
|
||||||
// insert mode, copy this value in/out of the app state
|
// insert mode, copy this value in/out of the app state
|
||||||
|
|
||||||
|
int row_count_per_page;
|
||||||
|
// page size in number of row.
|
||||||
|
// this value MUST be set to >0 for pageup or pagedown in multilines documents.
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
//
|
//
|
||||||
// private data
|
// private data
|
||||||
@ -855,12 +857,16 @@ retry:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case STB_TEXTEDIT_K_DOWN:
|
case STB_TEXTEDIT_K_DOWN:
|
||||||
case STB_TEXTEDIT_K_DOWN | STB_TEXTEDIT_K_SHIFT: {
|
case STB_TEXTEDIT_K_DOWN | STB_TEXTEDIT_K_SHIFT:
|
||||||
|
case STB_TEXTEDIT_K_PGDOWN:
|
||||||
|
case STB_TEXTEDIT_K_PGDOWN | STB_TEXTEDIT_K_SHIFT: {
|
||||||
StbFindState find;
|
StbFindState find;
|
||||||
StbTexteditRow row;
|
StbTexteditRow row;
|
||||||
int i, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0;
|
int i, j, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0;
|
||||||
|
int is_page = (key & ~STB_TEXTEDIT_K_SHIFT) == STB_TEXTEDIT_K_PGDOWN;
|
||||||
|
int row_count = is_page ? state->row_count_per_page : 1;
|
||||||
|
|
||||||
if (state->single_line) {
|
if (!is_page && state->single_line) {
|
||||||
// on windows, up&down in single-line behave like left&right
|
// on windows, up&down in single-line behave like left&right
|
||||||
key = STB_TEXTEDIT_K_RIGHT | (key & STB_TEXTEDIT_K_SHIFT);
|
key = STB_TEXTEDIT_K_RIGHT | (key & STB_TEXTEDIT_K_SHIFT);
|
||||||
goto retry;
|
goto retry;
|
||||||
@ -869,17 +875,25 @@ retry:
|
|||||||
if (sel)
|
if (sel)
|
||||||
stb_textedit_prep_selection_at_cursor(state);
|
stb_textedit_prep_selection_at_cursor(state);
|
||||||
else if (STB_TEXT_HAS_SELECTION(state))
|
else if (STB_TEXT_HAS_SELECTION(state))
|
||||||
stb_textedit_move_to_last(str,state);
|
stb_textedit_move_to_last(str, state);
|
||||||
|
|
||||||
// compute current position of cursor point
|
// compute current position of cursor point
|
||||||
stb_textedit_clamp(str, state);
|
stb_textedit_clamp(str, state);
|
||||||
stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
|
stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
|
||||||
|
|
||||||
// now find character position down a row
|
for (j = 0; j < row_count; ++j) {
|
||||||
if (find.length) {
|
float x, goal_x = state->has_preferred_x ? state->preferred_x : find.x;
|
||||||
float goal_x = state->has_preferred_x ? state->preferred_x : find.x;
|
|
||||||
float x;
|
|
||||||
int start = find.first_char + find.length;
|
int start = find.first_char + find.length;
|
||||||
|
|
||||||
|
if (find.length == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// [DEAR IMGUI]
|
||||||
|
// going down while being on the last line shouldn't bring us to that line end
|
||||||
|
if (STB_TEXTEDIT_GETCHAR(str, find.first_char + find.length - 1) != STB_TEXTEDIT_NEWLINE)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// now find character position down a row
|
||||||
state->cursor = start;
|
state->cursor = start;
|
||||||
STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor);
|
STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor);
|
||||||
x = row.x0;
|
x = row.x0;
|
||||||
@ -901,17 +915,25 @@ retry:
|
|||||||
|
|
||||||
if (sel)
|
if (sel)
|
||||||
state->select_end = state->cursor;
|
state->select_end = state->cursor;
|
||||||
|
|
||||||
|
// go to next line
|
||||||
|
find.first_char = find.first_char + find.length;
|
||||||
|
find.length = row.num_chars;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case STB_TEXTEDIT_K_UP:
|
case STB_TEXTEDIT_K_UP:
|
||||||
case STB_TEXTEDIT_K_UP | STB_TEXTEDIT_K_SHIFT: {
|
case STB_TEXTEDIT_K_UP | STB_TEXTEDIT_K_SHIFT:
|
||||||
|
case STB_TEXTEDIT_K_PGUP:
|
||||||
|
case STB_TEXTEDIT_K_PGUP | STB_TEXTEDIT_K_SHIFT: {
|
||||||
StbFindState find;
|
StbFindState find;
|
||||||
StbTexteditRow row;
|
StbTexteditRow row;
|
||||||
int i, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0;
|
int i, j, prev_scan, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0;
|
||||||
|
int is_page = (key & ~STB_TEXTEDIT_K_SHIFT) == STB_TEXTEDIT_K_PGUP;
|
||||||
|
int row_count = is_page ? state->row_count_per_page : 1;
|
||||||
|
|
||||||
if (state->single_line) {
|
if (!is_page && state->single_line) {
|
||||||
// on windows, up&down become left&right
|
// on windows, up&down become left&right
|
||||||
key = STB_TEXTEDIT_K_LEFT | (key & STB_TEXTEDIT_K_SHIFT);
|
key = STB_TEXTEDIT_K_LEFT | (key & STB_TEXTEDIT_K_SHIFT);
|
||||||
goto retry;
|
goto retry;
|
||||||
@ -926,11 +948,14 @@ retry:
|
|||||||
stb_textedit_clamp(str, state);
|
stb_textedit_clamp(str, state);
|
||||||
stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
|
stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
|
||||||
|
|
||||||
// can only go up if there's a previous row
|
for (j = 0; j < row_count; ++j) {
|
||||||
if (find.prev_first != find.first_char) {
|
float x, goal_x = state->has_preferred_x ? state->preferred_x : find.x;
|
||||||
|
|
||||||
|
// can only go up if there's a previous row
|
||||||
|
if (find.prev_first == find.first_char)
|
||||||
|
break;
|
||||||
|
|
||||||
// now find character position up a row
|
// now find character position up a row
|
||||||
float goal_x = state->has_preferred_x ? state->preferred_x : find.x;
|
|
||||||
float x;
|
|
||||||
state->cursor = find.prev_first;
|
state->cursor = find.prev_first;
|
||||||
STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor);
|
STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor);
|
||||||
x = row.x0;
|
x = row.x0;
|
||||||
@ -952,6 +977,14 @@ retry:
|
|||||||
|
|
||||||
if (sel)
|
if (sel)
|
||||||
state->select_end = state->cursor;
|
state->select_end = state->cursor;
|
||||||
|
|
||||||
|
// go to previous line
|
||||||
|
// (we need to scan previous line the hard way. maybe we could expose this as a new API function?)
|
||||||
|
prev_scan = find.prev_first > 0 ? find.prev_first - 1 : 0;
|
||||||
|
while (prev_scan > 0 && STB_TEXTEDIT_GETCHAR(str, prev_scan - 1) != STB_TEXTEDIT_NEWLINE)
|
||||||
|
--prev_scan;
|
||||||
|
find.first_char = find.prev_first;
|
||||||
|
find.prev_first = prev_scan;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1075,10 +1108,6 @@ retry:
|
|||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO:
|
|
||||||
// STB_TEXTEDIT_K_PGUP - move cursor up a page
|
|
||||||
// STB_TEXTEDIT_K_PGDOWN - move cursor down a page
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1134,7 +1163,7 @@ static void stb_textedit_discard_redo(StbUndoState *state)
|
|||||||
state->undo_rec[i].char_storage += n;
|
state->undo_rec[i].char_storage += n;
|
||||||
}
|
}
|
||||||
// now move all the redo records towards the end of the buffer; the first one is at 'redo_point'
|
// now move all the redo records towards the end of the buffer; the first one is at 'redo_point'
|
||||||
// {DEAR IMGUI]
|
// [DEAR IMGUI]
|
||||||
size_t move_size = (size_t)((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point - 1) * sizeof(state->undo_rec[0]));
|
size_t move_size = (size_t)((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point - 1) * sizeof(state->undo_rec[0]));
|
||||||
const char* buf_begin = (char*)state->undo_rec; (void)buf_begin;
|
const char* buf_begin = (char*)state->undo_rec; (void)buf_begin;
|
||||||
const char* buf_end = (char*)state->undo_rec + sizeof(state->undo_rec); (void)buf_end;
|
const char* buf_end = (char*)state->undo_rec + sizeof(state->undo_rec); (void)buf_end;
|
||||||
@ -1350,6 +1379,7 @@ static void stb_textedit_clear_state(STB_TexteditState *state, int is_single_lin
|
|||||||
state->initialized = 1;
|
state->initialized = 1;
|
||||||
state->single_line = (unsigned char) is_single_line;
|
state->single_line = (unsigned char) is_single_line;
|
||||||
state->insert_mode = 0;
|
state->insert_mode = 0;
|
||||||
|
state->row_count_per_page = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// API initialize
|
// API initialize
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
// stb_compress* from stb.h - declaration
|
// stb_compress* from stb.h - declaration
|
||||||
typedef unsigned int stb_uint;
|
typedef unsigned int stb_uint;
|
||||||
typedef unsigned char stb_uchar;
|
typedef unsigned char stb_uchar;
|
||||||
stb_uint stb_compress(stb_uchar *out,stb_uchar *in,stb_uint len);
|
stb_uint stb_compress(stb_uchar* out, stb_uchar* in, stb_uint len);
|
||||||
|
|
||||||
static bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_base85_encoding, bool use_compression);
|
static bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_base85_encoding, bool use_compression);
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ret = binary_to_compressed_c(argv[argn], argv[argn+1], use_base85_encoding, use_compression);
|
bool ret = binary_to_compressed_c(argv[argn], argv[argn + 1], use_base85_encoding, use_compression);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
fprintf(stderr, "Error opening or reading file: '%s'\n", argv[argn]);
|
fprintf(stderr, "Error opening or reading file: '%s'\n", argv[argn]);
|
||||||
return ret ? 0 : 1;
|
return ret ? 0 : 1;
|
||||||
@ -63,7 +63,7 @@ int main(int argc, char** argv)
|
|||||||
char Encode85Byte(unsigned int x)
|
char Encode85Byte(unsigned int x)
|
||||||
{
|
{
|
||||||
x = (x % 85) + 35;
|
x = (x % 85) + 35;
|
||||||
return (x>='\\') ? x+1 : x;
|
return (x >= '\\') ? x + 1 : x;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_base85_encoding, bool use_compression)
|
bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_base85_encoding, bool use_compression)
|
||||||
@ -73,7 +73,7 @@ bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_b
|
|||||||
if (!f) return false;
|
if (!f) return false;
|
||||||
int data_sz;
|
int data_sz;
|
||||||
if (fseek(f, 0, SEEK_END) || (data_sz = (int)ftell(f)) == -1 || fseek(f, 0, SEEK_SET)) { fclose(f); return false; }
|
if (fseek(f, 0, SEEK_END) || (data_sz = (int)ftell(f)) == -1 || fseek(f, 0, SEEK_SET)) { fclose(f); return false; }
|
||||||
char* data = new char[data_sz+4];
|
char* data = new char[data_sz + 4];
|
||||||
if (fread(data, 1, data_sz, f) != (size_t)data_sz) { fclose(f); delete[] data; return false; }
|
if (fread(data, 1, data_sz, f) != (size_t)data_sz) { fclose(f); delete[] data; return false; }
|
||||||
memset((void*)(((char*)data) + data_sz), 0, 4);
|
memset((void*)(((char*)data) + data_sz), 0, 4);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
@ -83,16 +83,16 @@ bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_b
|
|||||||
char* compressed = use_compression ? new char[maxlen] : data;
|
char* compressed = use_compression ? new char[maxlen] : data;
|
||||||
int compressed_sz = use_compression ? stb_compress((stb_uchar*)compressed, (stb_uchar*)data, data_sz) : data_sz;
|
int compressed_sz = use_compression ? stb_compress((stb_uchar*)compressed, (stb_uchar*)data, data_sz) : data_sz;
|
||||||
if (use_compression)
|
if (use_compression)
|
||||||
memset(compressed + compressed_sz, 0, maxlen - compressed_sz);
|
memset(compressed + compressed_sz, 0, maxlen - compressed_sz);
|
||||||
|
|
||||||
// Output as Base85 encoded
|
// Output as Base85 encoded
|
||||||
FILE* out = stdout;
|
FILE* out = stdout;
|
||||||
fprintf(out, "// File: '%s' (%d bytes)\n", filename, (int)data_sz);
|
fprintf(out, "// File: '%s' (%d bytes)\n", filename, (int)data_sz);
|
||||||
fprintf(out, "// Exported using binary_to_compressed_c.cpp\n");
|
fprintf(out, "// Exported using binary_to_compressed_c.cpp\n");
|
||||||
const char* compressed_str = use_compression ? "compressed_" : "";
|
const char* compressed_str = use_compression ? "compressed_" : "";
|
||||||
if (use_base85_encoding)
|
if (use_base85_encoding)
|
||||||
{
|
{
|
||||||
fprintf(out, "static const char %s_%sdata_base85[%d+1] =\n \"", symbol, compressed_str, (int)((compressed_sz+3)/4)*5);
|
fprintf(out, "static const char %s_%sdata_base85[%d+1] =\n \"", symbol, compressed_str, (int)((compressed_sz + 3) / 4)*5);
|
||||||
char prev_c = 0;
|
char prev_c = 0;
|
||||||
for (int src_i = 0; src_i < compressed_sz; src_i += 4)
|
for (int src_i = 0; src_i < compressed_sz; src_i += 4)
|
||||||
{
|
{
|
||||||
@ -104,7 +104,7 @@ bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_b
|
|||||||
fprintf(out, (c == '?' && prev_c == '?') ? "\\%c" : "%c", c);
|
fprintf(out, (c == '?' && prev_c == '?') ? "\\%c" : "%c", c);
|
||||||
prev_c = c;
|
prev_c = c;
|
||||||
}
|
}
|
||||||
if ((src_i % 112) == 112-4)
|
if ((src_i % 112) == 112 - 4)
|
||||||
fprintf(out, "\"\n \"");
|
fprintf(out, "\"\n \"");
|
||||||
}
|
}
|
||||||
fprintf(out, "\";\n\n");
|
fprintf(out, "\";\n\n");
|
||||||
@ -112,7 +112,7 @@ bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_b
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(out, "static const unsigned int %s_%ssize = %d;\n", symbol, compressed_str, (int)compressed_sz);
|
fprintf(out, "static const unsigned int %s_%ssize = %d;\n", symbol, compressed_str, (int)compressed_sz);
|
||||||
fprintf(out, "static const unsigned int %s_%sdata[%d/4] =\n{", symbol, compressed_str, (int)((compressed_sz+3)/4)*4);
|
fprintf(out, "static const unsigned int %s_%sdata[%d/4] =\n{", symbol, compressed_str, (int)((compressed_sz + 3) / 4)*4);
|
||||||
int column = 0;
|
int column = 0;
|
||||||
for (int i = 0; i < compressed_sz; i += 4)
|
for (int i = 0; i < compressed_sz; i += 4)
|
||||||
{
|
{
|
||||||
@ -128,7 +128,7 @@ bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_b
|
|||||||
// Cleanup
|
// Cleanup
|
||||||
delete[] data;
|
delete[] data;
|
||||||
if (use_compression)
|
if (use_compression)
|
||||||
delete[] compressed;
|
delete[] compressed;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// - v0.60: (2019/01/10) re-factored to match big update in STB builder. fixed texture height waste. fixed redundant glyphs when merging. support for glyph padding.
|
// - v0.60: (2019/01/10) re-factored to match big update in STB builder. fixed texture height waste. fixed redundant glyphs when merging. support for glyph padding.
|
||||||
// - v0.61: (2019/01/15) added support for imgui allocators + added FreeType only override function SetAllocatorFunctions().
|
// - v0.61: (2019/01/15) added support for imgui allocators + added FreeType only override function SetAllocatorFunctions().
|
||||||
// - v0.62: (2019/02/09) added RasterizerFlags::Monochrome flag to disable font anti-aliasing (combine with ::MonoHinting for best results!)
|
// - v0.62: (2019/02/09) added RasterizerFlags::Monochrome flag to disable font anti-aliasing (combine with ::MonoHinting for best results!)
|
||||||
// - v0.63: (2020/06/04) fix for rare case where FT_Get_Char_Index() succeed but FT_Load_Glyph() fails.
|
// - v0.63: (2020/06/04) fix for rare case where FT_Get_Char_Index() succeed but FT_Load_Glyph() fails.
|
||||||
|
|
||||||
// Gamma Correct Blending:
|
// Gamma Correct Blending:
|
||||||
// FreeType assumes blending in linear space rather than gamma space.
|
// FreeType assumes blending in linear space rather than gamma space.
|
||||||
@ -338,8 +338,8 @@ bool ImFontAtlasBuildWithFreeType(FT_Library ft_library, ImFontAtlas* atlas, uns
|
|||||||
ImVector<ImFontBuildDstDataFT> dst_tmp_array;
|
ImVector<ImFontBuildDstDataFT> dst_tmp_array;
|
||||||
src_tmp_array.resize(atlas->ConfigData.Size);
|
src_tmp_array.resize(atlas->ConfigData.Size);
|
||||||
dst_tmp_array.resize(atlas->Fonts.Size);
|
dst_tmp_array.resize(atlas->Fonts.Size);
|
||||||
memset(src_tmp_array.Data, 0, (size_t)src_tmp_array.size_in_bytes());
|
memset((void*)src_tmp_array.Data, 0, (size_t)src_tmp_array.size_in_bytes());
|
||||||
memset(dst_tmp_array.Data, 0, (size_t)dst_tmp_array.size_in_bytes());
|
memset((void*)dst_tmp_array.Data, 0, (size_t)dst_tmp_array.size_in_bytes());
|
||||||
|
|
||||||
// 1. Initialize font loading structure, check font data validity
|
// 1. Initialize font loading structure, check font data validity
|
||||||
for (int src_i = 0; src_i < atlas->ConfigData.Size; src_i++)
|
for (int src_i = 0; src_i < atlas->ConfigData.Size; src_i++)
|
||||||
@ -382,7 +382,7 @@ bool ImFontAtlasBuildWithFreeType(FT_Library ft_library, ImFontAtlas* atlas, uns
|
|||||||
dst_tmp.GlyphsSet.Create(dst_tmp.GlyphsHighest + 1);
|
dst_tmp.GlyphsSet.Create(dst_tmp.GlyphsHighest + 1);
|
||||||
|
|
||||||
for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2)
|
for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2)
|
||||||
for (int codepoint = src_range[0]; codepoint <= src_range[1]; codepoint++)
|
for (int codepoint = src_range[0]; codepoint <= (int)src_range[1]; codepoint++)
|
||||||
{
|
{
|
||||||
if (dst_tmp.GlyphsSet.TestBit(codepoint)) // Don't overwrite existing glyphs. We could make this an option (e.g. MergeOverwrite)
|
if (dst_tmp.GlyphsSet.TestBit(codepoint)) // Don't overwrite existing glyphs. We could make this an option (e.g. MergeOverwrite)
|
||||||
continue;
|
continue;
|
||||||
@ -502,7 +502,7 @@ bool ImFontAtlasBuildWithFreeType(FT_Library ft_library, ImFontAtlas* atlas, uns
|
|||||||
if (atlas->TexDesiredWidth > 0)
|
if (atlas->TexDesiredWidth > 0)
|
||||||
atlas->TexWidth = atlas->TexDesiredWidth;
|
atlas->TexWidth = atlas->TexDesiredWidth;
|
||||||
else
|
else
|
||||||
atlas->TexWidth = (surface_sqrt >= 4096*0.7f) ? 4096 : (surface_sqrt >= 2048*0.7f) ? 2048 : (surface_sqrt >= 1024*0.7f) ? 1024 : 512;
|
atlas->TexWidth = (surface_sqrt >= 4096 * 0.7f) ? 4096 : (surface_sqrt >= 2048 * 0.7f) ? 2048 : (surface_sqrt >= 1024 * 0.7f) ? 1024 : 512;
|
||||||
|
|
||||||
// 5. Start packing
|
// 5. Start packing
|
||||||
// Pack our extra data rectangles first, so it will be on the upper-left corner of our texture (UV will have small values).
|
// Pack our extra data rectangles first, so it will be on the upper-left corner of our texture (UV will have small values).
|
||||||
@ -544,8 +544,11 @@ bool ImFontAtlasBuildWithFreeType(FT_Library ft_library, ImFontAtlas* atlas, uns
|
|||||||
if (src_tmp.GlyphsCount == 0)
|
if (src_tmp.GlyphsCount == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// When merging fonts with MergeMode=true:
|
||||||
|
// - We can have multiple input fonts writing into a same destination font.
|
||||||
|
// - dst_font->ConfigData is != from cfg which is our source configuration.
|
||||||
ImFontConfig& cfg = atlas->ConfigData[src_i];
|
ImFontConfig& cfg = atlas->ConfigData[src_i];
|
||||||
ImFont* dst_font = cfg.DstFont; // We can have multiple input fonts writing into a same destination font (when using MergeMode=true)
|
ImFont* dst_font = cfg.DstFont;
|
||||||
|
|
||||||
const float ascent = src_tmp.Font.Info.Ascender;
|
const float ascent = src_tmp.Font.Info.Ascender;
|
||||||
const float descent = src_tmp.Font.Info.Descender;
|
const float descent = src_tmp.Font.Info.Descender;
|
||||||
@ -576,14 +579,8 @@ bool ImFontAtlasBuildWithFreeType(FT_Library ft_library, ImFontAtlas* atlas, uns
|
|||||||
for (int y = info.Height; y > 0; y--, blit_dst += blit_dst_stride, blit_src += blit_src_stride)
|
for (int y = info.Height; y > 0; y--, blit_dst += blit_dst_stride, blit_src += blit_src_stride)
|
||||||
memcpy(blit_dst, blit_src, blit_src_stride);
|
memcpy(blit_dst, blit_src, blit_src_stride);
|
||||||
|
|
||||||
float char_advance_x_org = info.AdvanceX;
|
|
||||||
float char_advance_x_mod = ImClamp(char_advance_x_org, cfg.GlyphMinAdvanceX, cfg.GlyphMaxAdvanceX);
|
|
||||||
float char_off_x = font_off_x;
|
|
||||||
if (char_advance_x_org != char_advance_x_mod)
|
|
||||||
char_off_x += cfg.PixelSnapH ? IM_FLOOR((char_advance_x_mod - char_advance_x_org) * 0.5f) : (char_advance_x_mod - char_advance_x_org) * 0.5f;
|
|
||||||
|
|
||||||
// Register glyph
|
// Register glyph
|
||||||
float x0 = info.OffsetX + char_off_x;
|
float x0 = info.OffsetX + font_off_x;
|
||||||
float y0 = info.OffsetY + font_off_y;
|
float y0 = info.OffsetY + font_off_y;
|
||||||
float x1 = x0 + info.Width;
|
float x1 = x0 + info.Width;
|
||||||
float y1 = y0 + info.Height;
|
float y1 = y0 + info.Height;
|
||||||
@ -591,7 +588,7 @@ bool ImFontAtlasBuildWithFreeType(FT_Library ft_library, ImFontAtlas* atlas, uns
|
|||||||
float v0 = (ty) / (float)atlas->TexHeight;
|
float v0 = (ty) / (float)atlas->TexHeight;
|
||||||
float u1 = (tx + info.Width) / (float)atlas->TexWidth;
|
float u1 = (tx + info.Width) / (float)atlas->TexWidth;
|
||||||
float v1 = (ty + info.Height) / (float)atlas->TexHeight;
|
float v1 = (ty + info.Height) / (float)atlas->TexHeight;
|
||||||
dst_font->AddGlyph((ImWchar)src_glyph.Codepoint, x0, y0, x1, y1, u0, v0, u1, v1, char_advance_x_mod);
|
dst_font->AddGlyph(&cfg, (ImWchar)src_glyph.Codepoint, x0, y0, x1, y1, u0, v0, u1, v1, info.AdvanceX);
|
||||||
}
|
}
|
||||||
|
|
||||||
src_tmp.Rects = NULL;
|
src_tmp.Rects = NULL;
|
||||||
@ -609,8 +606,8 @@ bool ImFontAtlasBuildWithFreeType(FT_Library ft_library, ImFontAtlas* atlas, uns
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Default memory allocators
|
// Default memory allocators
|
||||||
static void* ImFreeTypeDefaultAllocFunc(size_t size, void* user_data) { IM_UNUSED(user_data); return IM_ALLOC(size); }
|
static void* ImFreeTypeDefaultAllocFunc(size_t size, void* user_data) { IM_UNUSED(user_data); return IM_ALLOC(size); }
|
||||||
static void ImFreeTypeDefaultFreeFunc(void* ptr, void* user_data) { IM_UNUSED(user_data); IM_FREE(ptr); }
|
static void ImFreeTypeDefaultFreeFunc(void* ptr, void* user_data) { IM_UNUSED(user_data); IM_FREE(ptr); }
|
||||||
|
|
||||||
// Current memory allocators
|
// Current memory allocators
|
||||||
static void* (*GImFreeTypeAllocFunc)(size_t size, void* user_data) = ImFreeTypeDefaultAllocFunc;
|
static void* (*GImFreeTypeAllocFunc)(size_t size, void* user_data) = ImFreeTypeDefaultAllocFunc;
|
||||||
|
Reference in New Issue
Block a user