mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-14 19:17:48 +01:00
Merge branch 'master' into docking
This commit is contained in:
commit
ebcfcd8da3
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@ -0,0 +1 @@
|
||||
blank_issues_enabled: false
|
90
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
Normal file
90
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
name: "Ask a question, report a bug, request a feature, etc."
|
||||
description: "Ask any question, discuss best practices, report a bug, request a feature."
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
FOR FIRST-TIME USERS ISSUES COMPILING/LINKING/RUNNING or LOADING FONTS, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions)
|
||||
For anything else: we are happy to use 'GitHub Issues' for many types of open-ended questions. We are encouraging 'Issues' becoming a large, centralized and cross-referenced database of Dear ImGui contents.
|
||||
|
||||
Be mindful that messages are being sent to the e-mail box of "Watching" users. Try to proof-read your messages before sending them. Edits are not seen by those users.
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
**Prerequisites:**
|
||||
- I have read [Frequently Asked Questions](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md).
|
||||
- I have read [Contributing Guidelines -> General Advices](https://github.com/ocornut/imgui/blob/master/docs/CONTRIBUTING.md#getting-started--general-advice).
|
||||
- I have read [Contributing Guidelines -> How to open an Issue](https://github.com/ocornut/imgui/blob/master/docs/CONTRIBUTING.md#how-to-open-an-issue).
|
||||
- I have searched [Github Issues and PR](https://github.com/ocornut/imgui/issues?q=) for discussion of similar topics.
|
||||
|
||||
----
|
||||
- type: input
|
||||
id: specs_version
|
||||
attributes:
|
||||
label: "Version/Branch of Dear ImGui:"
|
||||
description: "(please specify if you have made substantial modifications to your copy)"
|
||||
value: "Version 1.XX, Branch: XXX (master/docking/etc.)"
|
||||
placeholder: "Version 1.XX, Branch: XXX (master/docking/etc.)"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: specs_backend
|
||||
attributes:
|
||||
label: "Back-ends:"
|
||||
description: (or specify when using custom engine/back-ends)
|
||||
value: "imgui_impl_XXX.cpp + imgui_impl_XXX.cpp"
|
||||
placeholder: "imgui_impl_XXX.cpp + imgui_impl_XXX.cpp or n/a"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: specs_compiler_os
|
||||
attributes:
|
||||
label: "Compiler, OS:"
|
||||
placeholder: "e.g. Windows 11 + MSVC 2022, macOS + Clang 12, Linux + GCC etc."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: specs_full
|
||||
attributes:
|
||||
label: "Full config/build information:"
|
||||
placeholder: |
|
||||
(If you can run, you may go to 'Demo->Tools->About Dear ImGui->Config/Build Info' to obtain detailed information that you can paste here)
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: issue_description
|
||||
attributes:
|
||||
label: "Details:"
|
||||
description: "Try to be explicit with your goals, your expectations and what you have tried. Be mindful of [The XY Problem](https://xyproblem.info). What you have in mind or in your code is not obvious to other people. People frequently discuss problems and suggest incorrect solutions without first clarifying their goals. When requesting a new feature, please describe the usage context (how you intend to use it, why you need it, etc.). If you tried something and it failed, show us what you tried. If you are reporting a bug, explain what's the bug, how does it occur, etc. If you are reporting a crash, please include a debugger callstack."
|
||||
value: |
|
||||
**My Issue/Question:**
|
||||
|
||||
XXX _(please provide as much context as possible)_
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: screenshots
|
||||
attributes:
|
||||
label: "Screenshots/Video:"
|
||||
description: "Attach screenshots or gif/videos to clarify the context. They often convey useful information that is omitted by the description."
|
||||
placeholder: "(You can drag files here)"
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: repro_code
|
||||
attributes:
|
||||
label: "Minimal, Complete and Verifiable Example code:"
|
||||
description: "Provide an [MCVE](https://stackoverflow.com/help/mcve) to demonstrate your problem. An ideal submission includes a small piece of code that anyone can paste into one of the examples applications (examples/*/main.cpp) or the demo (imgui_demo.cpp) to understand and reproduce it. Narrowing your problem to its shortest and purest form is the easiest way to understand it, explain it and fix it. Please test your shortened code to ensure it exhibits the problem. Often while creating the MCVE you will solve the problem! Many questions that are missing a standalone verifiable example are missing the actual cause of their issue in the description, which ends up wasting everyone's time."
|
||||
value: |
|
||||
```cpp
|
||||
// Here's some code anyone can copy and paste to reproduce your issue
|
||||
ImGui::Begin("Example Bug");
|
||||
MoreCodeToExplainMyIssue();
|
||||
ImGui::End();
|
||||
```
|
||||
validations:
|
||||
required: false
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thank you for taking the time to read prerequisites, filling this template and double-checking your message and your code!
|
46
.github/issue_template.md
vendored
46
.github/issue_template.md
vendored
@ -1,46 +0,0 @@
|
||||
(Click "Preview" above ^ to turn URL into clickable links)
|
||||
|
||||
1. FOR FIRST-TIME USERS PROBLEMS COMPILING/LINKING/RUNNING or LOADING FONTS, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions). EVERYTHING ELSE CAN BE POSTED HERE!
|
||||
|
||||
2. PLEASE CAREFULLY READ: [FAQ](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md)
|
||||
|
||||
3. PLEASE CAREFULLY READ: [Contributing Guidelines](https://github.com/ocornut/imgui/blob/master/docs/CONTRIBUTING.md)
|
||||
|
||||
4. PLEASE MAKE SURE that you have: read the FAQ; explored the contents of `ShowDemoWindow()` including the Examples menu; searched among Issues; used your IDE to search for keywords in all sources and text files; and read the links above.
|
||||
|
||||
5. Be mindful that messages are being sent to the e-mail box of "Watching" users. Try to proof-read your messages before sending them. Edits are not seen by those users.
|
||||
|
||||
6. Delete points 1-6 and PLEASE FILL THE TEMPLATE BELOW before submitting your issue.
|
||||
|
||||
Thank you!
|
||||
|
||||
----
|
||||
|
||||
_(you may also go to Demo>About Window, and click "Config/Build Information" to obtain a bunch of detailed information that you can paste here)_
|
||||
|
||||
**Version/Branch of Dear ImGui:**
|
||||
|
||||
Version: XXX
|
||||
Branch: XXX _(master/viewport/docking/etc.)_
|
||||
|
||||
**Back-end/Renderer/Compiler/OS**
|
||||
|
||||
Back-ends: imgui_impl_XXX.cpp + imgui_impl_XXX.cpp _(or specify if using a custom engine/back-end)_
|
||||
Compiler: XXX _(if the question is related to building or platform specific features)_
|
||||
Operating System: XXX
|
||||
|
||||
**My Issue/Question:**
|
||||
|
||||
XXX _(please provide as much context as possible)_
|
||||
|
||||
**Screenshots/Video**
|
||||
|
||||
XXX _(you can drag files here)_
|
||||
|
||||
**Standalone, minimal, complete and verifiable example:** _(see https://github.com/ocornut/imgui/issues/2261)_
|
||||
```
|
||||
// Here's some code anyone can copy and paste to reproduce your issue
|
||||
ImGui::Begin("Example Bug");
|
||||
MoreCodeToExplainMyIssue();
|
||||
ImGui::End();
|
||||
```
|
@ -42,8 +42,6 @@ HOW TO UPDATE?
|
||||
|
||||
Breaking changes:
|
||||
|
||||
- DragScalarN, SliderScalarN, InputScalarN: Fixed incorrect pushes into ItemWidth
|
||||
stack when number of components is 1. [#7095] [@Nahor]
|
||||
- imgui_freetype: commented out ImGuiFreeType::BuildFontAtlas() obsoleted in 1.81.
|
||||
Prefer using #define IMGUI_ENABLE_FREETYPE or see commented code for manual calls.
|
||||
- Removed CalcListClipping() marked obsolete in 1.86. (#3841)
|
||||
@ -56,6 +54,8 @@ Other changes:
|
||||
|
||||
- Windows: BeginChild(): Fixed auto-resizing erroneously limiting size to host viewport
|
||||
minus padding. There are no limit to a child width/height. (#7063) [@Devyre]
|
||||
- Windows: BeginChild(): Resize borders rendered even when ImGuiWindowFlags_NoBackground
|
||||
is specified. (#1710, #7194)
|
||||
- Windows: Fixed some auto-resizing path using style.WindowMinSize.x (instead of x/y)
|
||||
for both axises since 1.90. (#7106) [@n0bodysec]
|
||||
- Scrolling: internal scrolling value is rounded instead of truncated, as a way to reduce
|
||||
@ -70,12 +70,15 @@ Other changes:
|
||||
- InputTextMultiline: Tabbing through a multi-line text editor which allows Tab character inputs
|
||||
(using the ImGuiInputTextFlags_AllowTabInput flag) doesn't automatically activate it, in order
|
||||
to allow passing through multiple widgets easily. (#3092, #5759, #787)
|
||||
- DragScalarN, SliderScalarN, InputScalarN: Fixed incorrect pushes into ItemWidth
|
||||
stack when number of components is 1. [#7095] [@Nahor]
|
||||
- Drags, Sliders, Inputs: removed all attempts to filter non-numerical characters during text
|
||||
editing. Invalid inputs not applied to value, visibly reverted after validation. (#6810, #7096)
|
||||
- Drags, Sliders, Inputs: removal of filter means that "nan" and "inf" values may be input. (#7096)
|
||||
- DragScalarN, SliderScalarN, InputScalarN, PushMultiItemsWidths: improve multi-components
|
||||
width computation to better distribute the error. (#7120, #7121) [@Nahor]
|
||||
- ColorEdit4: Layout tweaks for very small sizes. (#7120, #7121)
|
||||
- ColorEdit: Layout tweaks for very small sizes. (#7120, #7121)
|
||||
- ColorPicker: Fixed saturation/value cursor radius not scaling properly.
|
||||
- Menus: Tweaked hover slack logic, adding a timer to avoid situations where a slow vertical
|
||||
movements toward another parent BeginMenu() can keep the wrong child menu open. (#6671, #6926)
|
||||
- Settings: Fixed an issue marking settings as dirty when merely clicking on a border or resize
|
||||
@ -93,6 +96,7 @@ Other changes:
|
||||
on a codebase where another copy of the library is used.
|
||||
- Misc: During shutdown, check that io.BackendPlatformUserData and io.BackendRendererUserData are NULL
|
||||
in order to catch cases where backend was not shut down. (#7175)
|
||||
- Misc: Reworked Issue Template to with a shinier and better form. (#5927) [@Panquesito7, @PathogenDavid, @ocornut]
|
||||
- Backends: GLFW, Emscripten: Added ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback() to
|
||||
register canvas selector and auto-resize GLFW window. (#6751) [@Traveller23, @ypujante]
|
||||
- Backends: GLFW: Fixed Windows specific hooks to use Unicode version of WndProc even when
|
||||
|
@ -426,7 +426,7 @@ Finally, you may call `ImGui::ShowMetricsWindow()` to explore/visualize/understa
|
||||
|
||||
### Q: How can I use maths operators with ImVec2?
|
||||
|
||||
We do not export maths operators by default in imgui.h in order to not conflict with the use of your own maths types and maths operators. As a convenience, you may use `#defne IMGUI_DEFINE_MATH_OPERATORS` + `#include "imgui.h"` to access our basic maths operators.
|
||||
We do not export maths operators by default in imgui.h in order to not conflict with the use of your own maths types and maths operators. As a convenience, you may use `#define IMGUI_DEFINE_MATH_OPERATORS` + `#include "imgui.h"` to access our basic maths operators.
|
||||
|
||||
##### [Return to Index](#index)
|
||||
|
||||
|
@ -482,7 +482,7 @@ Some fonts files are available in the `misc/fonts/` folder:
|
||||
#### MONOSPACE FONTS
|
||||
|
||||
Pixel Perfect:
|
||||
- Proggy Fonts, by Tristan Grimmer http://www.proggyfonts.net or http://upperbounds.net
|
||||
- Proggy Fonts, by Tristan Grimmer http://www.proggyfonts.net or http://upperboundsinteractive.com/fonts.php
|
||||
- Sweet16, Sweet16 Mono, by Martin Sedlak (Latin + Supplemental + Extended A) https://github.com/kmar/Sweet16Font (also include an .inl file to use directly in dear imgui.)
|
||||
|
||||
Regular:
|
||||
|
@ -110,7 +110,7 @@ Reading the changelogs is a good way to keep up to date with the things Dear ImG
|
||||
Calling the `ImGui::ShowDemoWindow()` function will create a demo window showcasing a variety of features and examples. The code is always available for reference in `imgui_demo.cpp`. [Here's how the demo looks](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v167/v167-misc.png).
|
||||
|
||||
You should be able to build the examples from sources. 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-20230704.zip](https://www.dearimgui.com/binaries/imgui-demo-binaries-20230704.zip) (Windows, 1.89.7, built 2023/07/04, master) or [older binaries](https://www.dearimgui.com/binaries).
|
||||
- [imgui-demo-binaries-20240105.zip](https://www.dearimgui.com/binaries/imgui-demo-binaries-20240105.zip) (Windows, 1.90.1 WIP, built 2024/01/05, master) or [older binaries](https://www.dearimgui.com/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 a different scale and scale your style with `style.ScaleAllSizes()` (see [FAQ](https://www.dearimgui.com/faq)).
|
||||
|
||||
@ -207,7 +207,7 @@ Sponsoring, maintenance/support contracts and other B2B transactions are hosted
|
||||
|
||||
Omar: "I first discovered the IMGUI paradigm at [Q-Games](https://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](https://www.proggyfonts.net) font by Tristan Grimmer (MIT license).
|
||||
<br>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. Also thank you to everyone posting feedback, questions and patches on GitHub.
|
||||
|
@ -64,7 +64,7 @@ int main(int, char**)
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN);
|
||||
Uint32 window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN;
|
||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+OpenGL3 example", 1280, 720, window_flags);
|
||||
if (window == nullptr)
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ int main(int, char**)
|
||||
SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");
|
||||
|
||||
// Create window with SDL_Renderer graphics context
|
||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN);
|
||||
Uint32 window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN;
|
||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+SDL_Renderer example", 1280, 720, window_flags);
|
||||
if (window == nullptr)
|
||||
{
|
||||
|
83
imgui.cpp
83
imgui.cpp
@ -6390,28 +6390,40 @@ static inline void ClampWindowPos(ImGuiWindow* window, const ImRect& visibility_
|
||||
window->Pos = ImClamp(window->Pos, visibility_rect.Min - size_for_clamping, visibility_rect.Max);
|
||||
}
|
||||
|
||||
static void RenderWindowOuterSingleBorder(ImGuiWindow* window, int border_n, ImU32 border_col, float border_size)
|
||||
{
|
||||
const ImGuiResizeBorderDef& def = resize_border_def[border_n];
|
||||
const float rounding = window->WindowRounding;
|
||||
const ImRect border_r = GetResizeBorderRect(window, border_n, rounding, 0.0f);
|
||||
window->DrawList->PathArcTo(ImLerp(border_r.Min, border_r.Max, def.SegmentN1) + ImVec2(0.5f, 0.5f) + def.InnerDir * rounding, rounding, def.OuterAngle - IM_PI * 0.25f, def.OuterAngle);
|
||||
window->DrawList->PathArcTo(ImLerp(border_r.Min, border_r.Max, def.SegmentN2) + ImVec2(0.5f, 0.5f) + def.InnerDir * rounding, rounding, def.OuterAngle, def.OuterAngle + IM_PI * 0.25f);
|
||||
window->DrawList->PathStroke(border_col, ImDrawFlags_None, border_size);
|
||||
}
|
||||
|
||||
static void ImGui::RenderWindowOuterBorders(ImGuiWindow* window)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
float rounding = window->WindowRounding;
|
||||
float border_size = window->WindowBorderSize;
|
||||
if (border_size > 0.0f && !(window->Flags & ImGuiWindowFlags_NoBackground))
|
||||
window->DrawList->AddRect(window->Pos, window->Pos + window->Size, GetColorU32(ImGuiCol_Border), rounding, 0, border_size);
|
||||
|
||||
const float border_size = window->WindowBorderSize;
|
||||
const ImU32 border_col = GetColorU32(ImGuiCol_Border);
|
||||
if (border_size > 0.0f && (window->Flags & ImGuiWindowFlags_NoBackground) == 0)
|
||||
window->DrawList->AddRect(window->Pos, window->Pos + window->Size, border_col, window->WindowRounding, 0, window->WindowBorderSize);
|
||||
else if (border_size > 0.0f)
|
||||
{
|
||||
if (window->ChildFlags & ImGuiChildFlags_ResizeX) // Similar code as 'resize_border_mask' computation in UpdateWindowManualResize() but we specifically only always draw explicit child resize border.
|
||||
RenderWindowOuterSingleBorder(window, 1, border_col, border_size);
|
||||
if (window->ChildFlags & ImGuiChildFlags_ResizeY)
|
||||
RenderWindowOuterSingleBorder(window, 3, border_col, border_size);
|
||||
}
|
||||
if (window->ResizeBorderHovered != -1 || window->ResizeBorderHeld != -1)
|
||||
{
|
||||
const int border_n = (window->ResizeBorderHeld != -1) ? window->ResizeBorderHeld : window->ResizeBorderHovered;
|
||||
const ImGuiResizeBorderDef& def = resize_border_def[border_n];
|
||||
const ImRect border_r = GetResizeBorderRect(window, border_n, rounding, 0.0f);
|
||||
const ImU32 border_col = GetColorU32((window->ResizeBorderHeld != -1) ? ImGuiCol_SeparatorActive : ImGuiCol_SeparatorHovered);
|
||||
window->DrawList->PathArcTo(ImLerp(border_r.Min, border_r.Max, def.SegmentN1) + ImVec2(0.5f, 0.5f) + def.InnerDir * rounding, rounding, def.OuterAngle - IM_PI * 0.25f, def.OuterAngle);
|
||||
window->DrawList->PathArcTo(ImLerp(border_r.Min, border_r.Max, def.SegmentN2) + ImVec2(0.5f, 0.5f) + def.InnerDir * rounding, rounding, def.OuterAngle, def.OuterAngle + IM_PI * 0.25f);
|
||||
window->DrawList->PathStroke(border_col, 0, ImMax(2.0f, border_size)); // Thicker than usual
|
||||
const ImU32 border_col_resizing = GetColorU32((window->ResizeBorderHeld != -1) ? ImGuiCol_SeparatorActive : ImGuiCol_SeparatorHovered);
|
||||
RenderWindowOuterSingleBorder(window, border_n, border_col_resizing, ImMax(2.0f, window->WindowBorderSize)); // Thicker than usual
|
||||
}
|
||||
if (g.Style.FrameBorderSize > 0 && !(window->Flags & ImGuiWindowFlags_NoTitleBar) && !window->DockIsActive)
|
||||
{
|
||||
float y = window->Pos.y + window->TitleBarHeight() - 1;
|
||||
window->DrawList->AddLine(ImVec2(window->Pos.x + border_size, y), ImVec2(window->Pos.x + window->Size.x - border_size, y), GetColorU32(ImGuiCol_Border), g.Style.FrameBorderSize);
|
||||
window->DrawList->AddLine(ImVec2(window->Pos.x + border_size, y), ImVec2(window->Pos.x + window->Size.x - border_size, y), border_col, g.Style.FrameBorderSize);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9016,13 +9028,28 @@ bool ImGui::IsKeyPressed(ImGuiKey key, ImGuiID owner_id, ImGuiInputFlags flags)
|
||||
if (t < 0.0f)
|
||||
return false;
|
||||
IM_ASSERT((flags & ~ImGuiInputFlags_SupportedByIsKeyPressed) == 0); // Passing flags not supported by this function!
|
||||
if (flags & (ImGuiInputFlags_RepeatRateMask_ | ImGuiInputFlags_RepeatUntilMask_)) // Setting any _RepeatXXX option enables _Repeat
|
||||
flags |= ImGuiInputFlags_Repeat;
|
||||
|
||||
bool pressed = (t == 0.0f);
|
||||
if (!pressed && ((flags & ImGuiInputFlags_Repeat) != 0))
|
||||
if (!pressed && (flags & ImGuiInputFlags_Repeat) != 0)
|
||||
{
|
||||
float repeat_delay, repeat_rate;
|
||||
GetTypematicRepeatRate(flags, &repeat_delay, &repeat_rate);
|
||||
pressed = (t > repeat_delay) && GetKeyPressedAmount(key, repeat_delay, repeat_rate) > 0;
|
||||
if (pressed && (flags & ImGuiInputFlags_RepeatUntilMask_))
|
||||
{
|
||||
// Slightly bias 'key_pressed_time' as DownDuration is an accumulation of DeltaTime which we compare to an absolute time value.
|
||||
// Ideally we'd replace DownDuration with KeyPressedTime but it would break user's code.
|
||||
ImGuiContext& g = *GImGui;
|
||||
double key_pressed_time = g.Time - t + 0.00001f;
|
||||
if ((flags & ImGuiInputFlags_RepeatUntilKeyModsChange) && (g.LastKeyModsChangeTime > key_pressed_time))
|
||||
pressed = false;
|
||||
if ((flags & ImGuiInputFlags_RepeatUntilKeyModsChangeFromNone) && (g.LastKeyModsChangeFromNoneTime > key_pressed_time))
|
||||
pressed = false;
|
||||
if ((flags & ImGuiInputFlags_RepeatUntilOtherKeyPress) && (g.LastKeyboardKeyPressTime > key_pressed_time))
|
||||
pressed = false;
|
||||
}
|
||||
}
|
||||
if (!pressed)
|
||||
return false;
|
||||
@ -9074,7 +9101,7 @@ bool ImGui::IsMouseClicked(ImGuiMouseButton button, ImGuiID owner_id, ImGuiInput
|
||||
const float t = g.IO.MouseDownDuration[button];
|
||||
if (t < 0.0f)
|
||||
return false;
|
||||
IM_ASSERT((flags & ~ImGuiInputFlags_SupportedByIsKeyPressed) == 0); // Passing flags not supported by this function!
|
||||
IM_ASSERT((flags & ~ImGuiInputFlags_SupportedByIsMouseClicked) == 0); // Passing flags not supported by this function! // FIXME: Could support RepeatRate and RepeatUntil flags here.
|
||||
|
||||
const bool repeat = (flags & ImGuiInputFlags_Repeat) != 0;
|
||||
const bool pressed = (t == 0.0f) || (repeat && t > g.IO.KeyRepeatDelay && CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay, g.IO.KeyRepeatRate) > 0);
|
||||
@ -9314,7 +9341,9 @@ static void ImGui::UpdateKeyboardInputs()
|
||||
GetKeyData(ImGuiMod_Super)->Down = io.KeySuper;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Import legacy ImGuiNavInput_ io inputs and convert to gamepad keys
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||
const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
|
||||
if (io.BackendUsingLegacyNavInputArray && nav_gamepad_active)
|
||||
@ -9337,7 +9366,6 @@ static void ImGui::UpdateKeyboardInputs()
|
||||
MAP_LEGACY_NAV_INPUT_TO_KEY1(ImGuiKey_GamepadLStickDown, ImGuiNavInput_LStickDown);
|
||||
#undef NAV_MAP_KEY
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Update aliases
|
||||
@ -9346,15 +9374,20 @@ static void ImGui::UpdateKeyboardInputs()
|
||||
UpdateAliasKey(ImGuiKey_MouseWheelX, io.MouseWheelH != 0.0f, io.MouseWheelH);
|
||||
UpdateAliasKey(ImGuiKey_MouseWheelY, io.MouseWheel != 0.0f, io.MouseWheel);
|
||||
|
||||
// Synchronize io.KeyMods and io.KeyXXX values.
|
||||
// Synchronize io.KeyMods and io.KeyCtrl/io.KeyShift/etc. values.
|
||||
// - New backends (1.87+): send io.AddKeyEvent(ImGuiMod_XXX) -> -> (here) deriving io.KeyMods + io.KeyXXX from key array.
|
||||
// - Legacy backends: set io.KeyXXX bools -> (above) set key array from io.KeyXXX -> (here) deriving io.KeyMods + io.KeyXXX from key array.
|
||||
// So with legacy backends the 4 values will do a unnecessary back-and-forth but it makes the code simpler and future facing.
|
||||
const ImGuiKeyChord prev_key_mods = io.KeyMods;
|
||||
io.KeyMods = GetMergedModsFromKeys();
|
||||
io.KeyCtrl = (io.KeyMods & ImGuiMod_Ctrl) != 0;
|
||||
io.KeyShift = (io.KeyMods & ImGuiMod_Shift) != 0;
|
||||
io.KeyAlt = (io.KeyMods & ImGuiMod_Alt) != 0;
|
||||
io.KeySuper = (io.KeyMods & ImGuiMod_Super) != 0;
|
||||
if (prev_key_mods != io.KeyMods)
|
||||
g.LastKeyModsChangeTime = g.Time;
|
||||
if (prev_key_mods != io.KeyMods && prev_key_mods == 0)
|
||||
g.LastKeyModsChangeFromNoneTime = g.Time;
|
||||
|
||||
// Clear gamepad data if disabled
|
||||
if ((io.BackendFlags & ImGuiBackendFlags_HasGamepad) == 0)
|
||||
@ -9370,6 +9403,14 @@ static void ImGui::UpdateKeyboardInputs()
|
||||
ImGuiKeyData* key_data = &io.KeysData[i];
|
||||
key_data->DownDurationPrev = key_data->DownDuration;
|
||||
key_data->DownDuration = key_data->Down ? (key_data->DownDuration < 0.0f ? 0.0f : key_data->DownDuration + io.DeltaTime) : -1.0f;
|
||||
if (key_data->DownDuration == 0.0f)
|
||||
{
|
||||
ImGuiKey key = (ImGuiKey)(ImGuiKey_NamedKey_BEGIN + i);
|
||||
if (IsKeyboardKey(key))
|
||||
g.LastKeyboardKeyPressTime = g.Time;
|
||||
else if (key == ImGuiKey_ReservedForModCtrl || key == ImGuiKey_ReservedForModShift || key == ImGuiKey_ReservedForModAlt || key == ImGuiKey_ReservedForModSuper)
|
||||
g.LastKeyboardKeyPressTime = g.Time;
|
||||
}
|
||||
}
|
||||
|
||||
// Update keys/input owner (named keys only): one entry per key
|
||||
@ -9383,6 +9424,7 @@ static void ImGui::UpdateKeyboardInputs()
|
||||
owner_data->LockThisFrame = owner_data->LockUntilRelease = owner_data->LockUntilRelease && key_data->Down; // Clear LockUntilRelease when key is not Down anymore
|
||||
}
|
||||
|
||||
// Update key routing (for e.g. shortcuts)
|
||||
UpdateKeyRoutingTable(&g.KeysRoutingTable);
|
||||
}
|
||||
|
||||
@ -9899,7 +9941,7 @@ bool ImGui::IsKeyChordPressed(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiIn
|
||||
ImGuiKey key = (ImGuiKey)(key_chord & ~ImGuiMod_Mask_);
|
||||
if (key == ImGuiKey_None)
|
||||
key = ConvertSingleModFlagToKey(&g, mods);
|
||||
if (!IsKeyPressed(key, owner_id, (flags & (ImGuiInputFlags_Repeat | (ImGuiInputFlags)ImGuiInputFlags_RepeatRateMask_))))
|
||||
if (!IsKeyPressed(key, owner_id, (flags & ImGuiInputFlags_RepeatMask_)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@ -9912,6 +9954,11 @@ bool ImGui::Shortcut(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiInputFlags
|
||||
if (!SetShortcutRouting(key_chord, owner_id, flags))
|
||||
return false;
|
||||
|
||||
// Default repeat behavior for Shortcut()
|
||||
// So e.g. pressing Ctrl+W and releasing Ctrl while holding W will not trigger the W shortcut.
|
||||
if ((flags & ImGuiInputFlags_RepeatUntilMask_) == 0)
|
||||
flags |= ImGuiInputFlags_RepeatUntilKeyModsChange;
|
||||
|
||||
if (!IsKeyChordPressed(key_chord, owner_id, flags))
|
||||
return false;
|
||||
IM_ASSERT((flags & ~ImGuiInputFlags_SupportedByShortcut) == 0); // Passing flags not supported by this function!
|
||||
@ -12502,7 +12549,7 @@ void ImGui::NavUpdateCreateMoveRequest()
|
||||
g.NavMoveScrollFlags = ImGuiScrollFlags_None;
|
||||
if (window && !g.NavWindowingTarget && !(window->Flags & ImGuiWindowFlags_NoNavInputs))
|
||||
{
|
||||
const ImGuiInputFlags repeat_mode = ImGuiInputFlags_Repeat | (ImGuiInputFlags)ImGuiInputFlags_RepeatRateNavMove;
|
||||
const ImGuiInputFlags repeat_mode = ImGuiInputFlags_Repeat | ImGuiInputFlags_RepeatRateNavMove;
|
||||
if (!IsActiveIdUsingNavDir(ImGuiDir_Left) && ((nav_gamepad_active && IsKeyPressed(ImGuiKey_GamepadDpadLeft, ImGuiKeyOwner_None, repeat_mode)) || (nav_keyboard_active && IsKeyPressed(ImGuiKey_LeftArrow, ImGuiKeyOwner_None, repeat_mode)))) { g.NavMoveDir = ImGuiDir_Left; }
|
||||
if (!IsActiveIdUsingNavDir(ImGuiDir_Right) && ((nav_gamepad_active && IsKeyPressed(ImGuiKey_GamepadDpadRight, ImGuiKeyOwner_None, repeat_mode)) || (nav_keyboard_active && IsKeyPressed(ImGuiKey_RightArrow, ImGuiKeyOwner_None, repeat_mode)))) { g.NavMoveDir = ImGuiDir_Right; }
|
||||
if (!IsActiveIdUsingNavDir(ImGuiDir_Up) && ((nav_gamepad_active && IsKeyPressed(ImGuiKey_GamepadDpadUp, ImGuiKeyOwner_None, repeat_mode)) || (nav_keyboard_active && IsKeyPressed(ImGuiKey_UpArrow, ImGuiKeyOwner_None, repeat_mode)))) { g.NavMoveDir = ImGuiDir_Up; }
|
||||
|
4
imgui.h
4
imgui.h
@ -24,7 +24,7 @@
|
||||
// Library Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||
#define IMGUI_VERSION "1.90.1 WIP"
|
||||
#define IMGUI_VERSION_NUM 19002
|
||||
#define IMGUI_VERSION_NUM 19003
|
||||
#define IMGUI_HAS_TABLE
|
||||
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
|
||||
#define IMGUI_HAS_DOCK // Docking WIP branch
|
||||
@ -541,6 +541,7 @@ namespace ImGui
|
||||
|
||||
// Widgets: Images
|
||||
// - Read about ImTextureID here: https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples
|
||||
// - 'uv0' and 'uv1' are texture coordinates. Read about them from the same link above.
|
||||
// - Note that Image() may add +2.0f to provided size if a border is visible, ImageButton() adds style.FramePadding*2.0f to provided size.
|
||||
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& image_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(const char* str_id, ImTextureID user_texture_id, const ImVec2& image_size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), const ImVec4& bg_col = ImVec4(0, 0, 0, 0), const ImVec4& tint_col = ImVec4(1, 1, 1, 1));
|
||||
@ -1369,6 +1370,7 @@ enum ImGuiSortDirection_
|
||||
// Since >= 1.89 we increased typing (went from int to enum), some legacy code may need a cast to ImGuiKey.
|
||||
// Read details about the 1.87 and 1.89 transition : https://github.com/ocornut/imgui/issues/4921
|
||||
// Note that "Keys" related to physical keys and are not the same concept as input "Characters", the later are submitted via io.AddInputCharacter().
|
||||
// The keyboard key enum values are named after the keys on a standard US keyboard, and on other keyboard types the keys reported may not match the keycaps.
|
||||
enum ImGuiKey : int
|
||||
{
|
||||
// Keyboard
|
||||
|
151
imgui_demo.cpp
151
imgui_demo.cpp
@ -54,7 +54,7 @@
|
||||
// Because we can't assume anything about your support of maths operators, we cannot use them in imgui_demo.cpp.
|
||||
|
||||
// Navigating this file:
|
||||
// - In Visual Studio IDE: CTRL+comma ("Edit.GoToAll") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
||||
// - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
||||
// - With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments.
|
||||
|
||||
/*
|
||||
@ -172,7 +172,8 @@ Index of this file:
|
||||
#define IM_MAX(A, B) (((A) >= (B)) ? (A) : (B))
|
||||
#define IM_CLAMP(V, MN, MX) ((V) < (MN) ? (MN) : (V) > (MX) ? (MX) : (V))
|
||||
|
||||
// Enforce cdecl calling convention for functions called by the standard library, in case compilation settings changed the default to e.g. __vectorcall
|
||||
// Enforce cdecl calling convention for functions called by the standard library,
|
||||
// in case compilation settings changed the default to e.g. __vectorcall
|
||||
#ifndef IMGUI_CDECL
|
||||
#ifdef _MSC_VER
|
||||
#define IMGUI_CDECL __cdecl
|
||||
@ -818,7 +819,8 @@ static void ShowDemoWindowWidgets()
|
||||
static int item_current = 0;
|
||||
ImGui::Combo("combo", &item_current, items, IM_ARRAYSIZE(items));
|
||||
ImGui::SameLine(); HelpMarker(
|
||||
"Using the simplified one-liner Combo API here.\nRefer to the \"Combo\" section below for an explanation of how to use the more flexible and general BeginCombo/EndCombo API.");
|
||||
"Using the simplified one-liner Combo API here.\n"
|
||||
"Refer to the \"Combo\" section below for an explanation of how to use the more flexible and general BeginCombo/EndCombo API.");
|
||||
}
|
||||
|
||||
{
|
||||
@ -829,7 +831,8 @@ static void ShowDemoWindowWidgets()
|
||||
static int item_current = 1;
|
||||
ImGui::ListBox("listbox", &item_current, items, IM_ARRAYSIZE(items), 4);
|
||||
ImGui::SameLine(); HelpMarker(
|
||||
"Using the simplified one-liner ListBox API here.\nRefer to the \"List boxes\" section below for an explanation of how to use the more flexible and general BeginListBox/EndListBox API.");
|
||||
"Using the simplified one-liner ListBox API here.\n"
|
||||
"Refer to the \"List boxes\" section below for an explanation of how to use the more flexible and general BeginListBox/EndListBox API.");
|
||||
}
|
||||
|
||||
ImGui::TreePop();
|
||||
@ -1147,7 +1150,7 @@ static void ShowDemoWindowWidgets()
|
||||
"CJK text will only appear if the font was loaded with the appropriate CJK character ranges. "
|
||||
"Call io.Fonts->AddFontFromFileTTF() manually to load extra character ranges. "
|
||||
"Read docs/FONTS.md for details.");
|
||||
ImGui::Text("Hiragana: \xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91\xe3\x81\x93 (kakikukeko)"); // Normally we would use u8"blah blah" with the proper characters directly in the string.
|
||||
ImGui::Text("Hiragana: \xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91\xe3\x81\x93 (kakikukeko)");
|
||||
ImGui::Text("Kanjis: \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e (nihongo)");
|
||||
static char buf[32] = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e";
|
||||
//static char buf[32] = u8"NIHONGO"; // <- this is how you would write it with C++11, using real kanjis
|
||||
@ -1191,7 +1194,7 @@ static void ShowDemoWindowWidgets()
|
||||
ImVec2 pos = ImGui::GetCursorScreenPos();
|
||||
ImVec2 uv_min = ImVec2(0.0f, 0.0f); // Top-left
|
||||
ImVec2 uv_max = ImVec2(1.0f, 1.0f); // Lower-right
|
||||
ImVec4 tint_col = use_text_color_for_tint ? ImGui::GetStyleColorVec4(ImGuiCol_Text) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint
|
||||
ImVec4 tint_col = use_text_color_for_tint ? ImGui::GetStyleColorVec4(ImGuiCol_Text) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint
|
||||
ImVec4 border_col = ImGui::GetStyleColorVec4(ImGuiCol_Border);
|
||||
ImGui::Image(my_tex_id, ImVec2(my_tex_w, my_tex_h), uv_min, uv_max, tint_col, border_col);
|
||||
if (ImGui::BeginItemTooltip())
|
||||
@ -1250,9 +1253,9 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::CheckboxFlags("ImGuiComboFlags_PopupAlignLeft", &flags, ImGuiComboFlags_PopupAlignLeft);
|
||||
ImGui::SameLine(); HelpMarker("Only makes a difference if the popup is larger than the combo");
|
||||
if (ImGui::CheckboxFlags("ImGuiComboFlags_NoArrowButton", &flags, ImGuiComboFlags_NoArrowButton))
|
||||
flags &= ~ImGuiComboFlags_NoPreview; // Clear the other flag, as we cannot combine both
|
||||
flags &= ~ImGuiComboFlags_NoPreview; // Clear incompatible flags
|
||||
if (ImGui::CheckboxFlags("ImGuiComboFlags_NoPreview", &flags, ImGuiComboFlags_NoPreview))
|
||||
flags &= ~(ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_WidthFitPreview); // Clear the other flag, as we cannot combine both
|
||||
flags &= ~(ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_WidthFitPreview); // Clear incompatible flags
|
||||
if (ImGui::CheckboxFlags("ImGuiComboFlags_WidthFitPreview", &flags, ImGuiComboFlags_WidthFitPreview))
|
||||
flags &= ~ImGuiComboFlags_NoPreview;
|
||||
|
||||
@ -1269,7 +1272,10 @@ static void ShowDemoWindowWidgets()
|
||||
// stored in the object itself, etc.)
|
||||
const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO" };
|
||||
static int item_current_idx = 0; // Here we store our selection data as an index.
|
||||
const char* combo_preview_value = items[item_current_idx]; // Pass in the preview value visible before opening the combo (it could be anything)
|
||||
|
||||
// Pass in the preview value visible before opening the combo (it could technically be different contents or not pulled from items[])
|
||||
const char* combo_preview_value = items[item_current_idx];
|
||||
|
||||
if (ImGui::BeginCombo("combo 1", combo_preview_value, flags))
|
||||
{
|
||||
for (int n = 0; n < IM_ARRAYSIZE(items); n++)
|
||||
@ -1309,8 +1315,10 @@ static void ShowDemoWindowWidgets()
|
||||
IMGUI_DEMO_MARKER("Widgets/List Boxes");
|
||||
if (ImGui::TreeNode("List boxes"))
|
||||
{
|
||||
// BeginListBox() is essentially a thin wrapper to using BeginChild()/EndChild() with the ImGuiChildFlags_FrameStyle flag for stylistic changes + displaying a label.
|
||||
// You may be tempted to simply use BeginChild() directly, however note that BeginChild() requires EndChild() to always be called (inconsistent with BeginListBox()/EndListBox()).
|
||||
// BeginListBox() is essentially a thin wrapper to using BeginChild()/EndChild()
|
||||
// using the ImGuiChildFlags_FrameStyle flag for stylistic changes + displaying a label.
|
||||
// You may be tempted to simply use BeginChild() directly. However note that BeginChild() requires EndChild()
|
||||
// to always be called (inconsistent with BeginListBox()/EndListBox()).
|
||||
|
||||
// Using the generic BeginListBox() API, you have full control over how to display the combo contents.
|
||||
// (your selection data could be an index, a pointer to the object, an id for the object, a flag intrusively
|
||||
@ -1629,16 +1637,21 @@ static void ShowDemoWindowWidgets()
|
||||
};
|
||||
static char buf1[64];
|
||||
ImGui::InputText("Completion", buf1, 64, ImGuiInputTextFlags_CallbackCompletion, Funcs::MyCallback);
|
||||
ImGui::SameLine(); HelpMarker("Here we append \"..\" each time Tab is pressed. See 'Examples>Console' for a more meaningful demonstration of using this callback.");
|
||||
ImGui::SameLine(); HelpMarker(
|
||||
"Here we append \"..\" each time Tab is pressed. "
|
||||
"See 'Examples>Console' for a more meaningful demonstration of using this callback.");
|
||||
|
||||
static char buf2[64];
|
||||
ImGui::InputText("History", buf2, 64, ImGuiInputTextFlags_CallbackHistory, Funcs::MyCallback);
|
||||
ImGui::SameLine(); HelpMarker("Here we replace and select text each time Up/Down are pressed. See 'Examples>Console' for a more meaningful demonstration of using this callback.");
|
||||
ImGui::SameLine(); HelpMarker(
|
||||
"Here we replace and select text each time Up/Down are pressed. "
|
||||
"See 'Examples>Console' for a more meaningful demonstration of using this callback.");
|
||||
|
||||
static char buf3[64];
|
||||
static int edit_count = 0;
|
||||
ImGui::InputText("Edit", buf3, 64, ImGuiInputTextFlags_CallbackEdit, Funcs::MyCallback, (void*)&edit_count);
|
||||
ImGui::SameLine(); HelpMarker("Here we toggle the casing of the first character on every edit + count edits.");
|
||||
ImGui::SameLine(); HelpMarker(
|
||||
"Here we toggle the casing of the first character on every edit + count edits.");
|
||||
ImGui::SameLine(); ImGui::Text("(%d)", edit_count);
|
||||
|
||||
ImGui::TreePop();
|
||||
@ -1813,8 +1826,9 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
// Demo Trailing Tabs: click the "+" button to add a new tab (in your app you may want to use a font icon instead of the "+")
|
||||
// Note that we submit it before the regular tabs, but because of the ImGuiTabItemFlags_Trailing flag it will always appear at the end.
|
||||
// Demo Trailing Tabs: click the "+" button to add a new tab.
|
||||
// (In your app you may want to use a font icon instead of the "+")
|
||||
// We submit it before the regular tabs, but thanks to the ImGuiTabItemFlags_Trailing flag it will always appear at the end.
|
||||
if (show_trailing_button)
|
||||
if (ImGui::TabItemButton("+", ImGuiTabItemFlags_Trailing | ImGuiTabItemFlags_NoTooltip))
|
||||
active_tabs.push_back(next_tab_id++); // Add new tab
|
||||
@ -2098,7 +2112,8 @@ static void ShowDemoWindowWidgets()
|
||||
if (ImGui::Button("Default: Float + HDR + Hue Wheel"))
|
||||
ImGui::SetColorEditOptions(ImGuiColorEditFlags_Float | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_PickerHueWheel);
|
||||
|
||||
// Always both a small version of both types of pickers (to make it more visible in the demo to people who are skimming quickly through it)
|
||||
// Always display a small version of both types of pickers
|
||||
// (that's in order to make it more visible in the demo to people who are skimming quickly through it)
|
||||
ImGui::Text("Both types:");
|
||||
float w = (ImGui::GetContentRegionAvail().x - ImGui::GetStyle().ItemSpacing.y) * 0.40f;
|
||||
ImGui::SetNextItemWidth(w);
|
||||
@ -3455,7 +3470,9 @@ static void ShowDemoWindowLayout()
|
||||
IMGUI_DEMO_MARKER("Layout/Scrolling/Horizontal contents size demo window");
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(2, 0));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2, 0));
|
||||
HelpMarker("Test of different widgets react and impact the work rectangle growing when horizontal scrolling is enabled.\n\nUse 'Metrics->Tools->Show windows rectangles' to visualize rectangles.");
|
||||
HelpMarker(
|
||||
"Test how different widgets react and impact the work rectangle growing when horizontal scrolling is enabled.\n\n"
|
||||
"Use 'Metrics->Tools->Show windows rectangles' to visualize rectangles.");
|
||||
ImGui::Checkbox("H-scrollbar", &show_h_scrollbar);
|
||||
ImGui::Checkbox("Button", &show_button); // Will grow contents size (unless explicitly overwritten)
|
||||
ImGui::Checkbox("Tree nodes", &show_tree_nodes); // Will grow contents size and display highlight over full width
|
||||
@ -3611,7 +3628,8 @@ static void ShowDemoWindowLayout()
|
||||
|
||||
HelpMarker(
|
||||
"Hit-testing is by default performed in item submission order, which generally is perceived as 'back-to-front'.\n\n"
|
||||
"By using SetNextItemAllowOverlap() you can notify that an item may be overlapped by another. Doing so alters the hovering logic: items using AllowOverlap mode requires an extra frame to accept hovered state.");
|
||||
"By using SetNextItemAllowOverlap() you can notify that an item may be overlapped by another. "
|
||||
"Doing so alters the hovering logic: items using AllowOverlap mode requires an extra frame to accept hovered state.");
|
||||
ImGui::Checkbox("Enable AllowOverlap", &enable_allow_overlap);
|
||||
|
||||
ImVec2 button1_pos = ImGui::GetCursorScreenPos();
|
||||
@ -3998,7 +4016,8 @@ struct MyItem
|
||||
}
|
||||
|
||||
// qsort() is instable so always return a way to differenciate items.
|
||||
// Your own compare function may want to avoid fallback on implicit sort specs e.g. a Name compare if it wasn't already part of the sort specs.
|
||||
// Your own compare function may want to avoid fallback on implicit sort specs.
|
||||
// e.g. a Name compare if it wasn't already part of the sort specs.
|
||||
return (a->ID - b->ID);
|
||||
}
|
||||
};
|
||||
@ -4181,8 +4200,9 @@ static void ShowDemoWindowTables()
|
||||
// as TableNextColumn() will automatically wrap around and create new rows as needed.
|
||||
// This is generally more convenient when your cells all contains the same type of data.
|
||||
HelpMarker(
|
||||
"Only using TableNextColumn(), which tends to be convenient for tables where every cell contains the same type of contents.\n"
|
||||
"This is also more similar to the old NextColumn() function of the Columns API, and provided to facilitate the Columns->Tables API transition.");
|
||||
"Only using TableNextColumn(), which tends to be convenient for tables where every cell contains "
|
||||
"the same type of contents.\n This is also more similar to the old NextColumn() function of the "
|
||||
"Columns API, and provided to facilitate the Columns->Tables API transition.");
|
||||
if (ImGui::BeginTable("table3", 3))
|
||||
{
|
||||
for (int item = 0; item < 14; item++)
|
||||
@ -4238,8 +4258,8 @@ static void ShowDemoWindowTables()
|
||||
|
||||
if (ImGui::BeginTable("table1", 3, flags))
|
||||
{
|
||||
// Display headers so we can inspect their interaction with borders.
|
||||
// (Headers are not the main purpose of this section of the demo, so we are not elaborating on them too much. See other sections for details)
|
||||
// Display headers so we can inspect their interaction with borders
|
||||
// (Headers are not the main purpose of this section of the demo, so we are not elaborating on them now. See other sections for details)
|
||||
if (display_headers)
|
||||
{
|
||||
ImGui::TableSetupColumn("One");
|
||||
@ -4278,7 +4298,9 @@ static void ShowDemoWindowTables()
|
||||
PushStyleCompact();
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersV", &flags, ImGuiTableFlags_BordersV);
|
||||
ImGui::SameLine(); HelpMarker("Using the _Resizable flag automatically enables the _BordersInnerV flag as well, this is why the resize borders are still showing when unchecking this.");
|
||||
ImGui::SameLine(); HelpMarker(
|
||||
"Using the _Resizable flag automatically enables the _BordersInnerV flag as well, "
|
||||
"this is why the resize borders are still showing when unchecking this.");
|
||||
PopStyleCompact();
|
||||
|
||||
if (ImGui::BeginTable("table1", 3, flags))
|
||||
@ -4419,7 +4441,8 @@ static void ShowDemoWindowTables()
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
// Use outer_size.x == 0.0f instead of default to make the table as tight as possible (only valid when no scrolling and no stretch column)
|
||||
// Use outer_size.x == 0.0f instead of default to make the table as tight as possible
|
||||
// (only valid when no scrolling and no stretch column)
|
||||
if (ImGui::BeginTable("table2", 3, flags | ImGuiTableFlags_SizingFixedFit, ImVec2(0.0f, 0.0f)))
|
||||
{
|
||||
ImGui::TableSetupColumn("One");
|
||||
@ -4452,7 +4475,8 @@ static void ShowDemoWindowTables()
|
||||
"e.g.:\n"
|
||||
"- BorderOuterV\n"
|
||||
"- any form of row selection\n"
|
||||
"Because of this, activating BorderOuterV sets the default to PadOuterX. Using PadOuterX or NoPadOuterX you can override the default.\n\n"
|
||||
"Because of this, activating BorderOuterV sets the default to PadOuterX. "
|
||||
"Using PadOuterX or NoPadOuterX you can override the default.\n\n"
|
||||
"Actual padding values are using style.CellPadding.\n\n"
|
||||
"In this demo we don't show horizontal borders to emphasize how they don't affect default horizontal padding.");
|
||||
|
||||
@ -4568,7 +4592,8 @@ static void ShowDemoWindowTables()
|
||||
EditTableSizingFlags(&sizing_policy_flags[table_n]);
|
||||
|
||||
// To make it easier to understand the different sizing policy,
|
||||
// For each policy: we display one table where the columns have equal contents width, and one where the columns have different contents width.
|
||||
// For each policy: we display one table where the columns have equal contents width,
|
||||
// and one where the columns have different contents width.
|
||||
if (ImGui::BeginTable("table1", 3, sizing_policy_flags[table_n] | flags1))
|
||||
{
|
||||
for (int row = 0; row < 3; row++)
|
||||
@ -4597,7 +4622,9 @@ static void ShowDemoWindowTables()
|
||||
ImGui::Spacing();
|
||||
ImGui::TextUnformatted("Advanced");
|
||||
ImGui::SameLine();
|
||||
HelpMarker("This section allows you to interact and see the effect of various sizing policies depending on whether Scroll is enabled and the contents of your columns.");
|
||||
HelpMarker(
|
||||
"This section allows you to interact and see the effect of various sizing policies "
|
||||
"depending on whether Scroll is enabled and the contents of your columns.");
|
||||
|
||||
enum ContentsType { CT_ShowWidth, CT_ShortText, CT_LongText, CT_Button, CT_FillButton, CT_InputText };
|
||||
static ImGuiTableFlags flags = ImGuiTableFlags_ScrollY | ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_Resizable;
|
||||
@ -4612,7 +4639,9 @@ static void ShowDemoWindowTables()
|
||||
if (contents_type == CT_FillButton)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
HelpMarker("Be mindful that using right-alignment (e.g. size.x = -FLT_MIN) creates a feedback loop where contents width can feed into auto-column width can feed into contents width.");
|
||||
HelpMarker(
|
||||
"Be mindful that using right-alignment (e.g. size.x = -FLT_MIN) creates a feedback loop "
|
||||
"where contents width can feed into auto-column width can feed into contents width.");
|
||||
}
|
||||
ImGui::DragInt("Columns", &column_count, 0.1f, 1, 64, "%d", ImGuiSliderFlags_AlwaysClamp);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable);
|
||||
@ -4658,7 +4687,9 @@ static void ShowDemoWindowTables()
|
||||
IMGUI_DEMO_MARKER("Tables/Vertical scrolling, with clipping");
|
||||
if (ImGui::TreeNode("Vertical scrolling, with clipping"))
|
||||
{
|
||||
HelpMarker("Here we activate ScrollY, which will create a child window container to allow hosting scrollable contents.\n\nWe also demonstrate using ImGuiListClipper to virtualize the submission of many items.");
|
||||
HelpMarker(
|
||||
"Here we activate ScrollY, which will create a child window container to allow hosting scrollable contents.\n\n"
|
||||
"We also demonstrate using ImGuiListClipper to virtualize the submission of many items.");
|
||||
static ImGuiTableFlags flags = ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable;
|
||||
|
||||
PushStyleCompact();
|
||||
@ -4704,8 +4735,9 @@ static void ShowDemoWindowTables()
|
||||
HelpMarker(
|
||||
"When ScrollX is enabled, the default sizing policy becomes ImGuiTableFlags_SizingFixedFit, "
|
||||
"as automatically stretching columns doesn't make much sense with horizontal scrolling.\n\n"
|
||||
"Also note that as of the current version, you will almost always want to enable ScrollY along with ScrollX,"
|
||||
"because the container window won't automatically extend vertically to fix contents (this may be improved in future versions).");
|
||||
"Also note that as of the current version, you will almost always want to enable ScrollY along with ScrollX, "
|
||||
"because the container window won't automatically extend vertically to fix contents "
|
||||
"(this may be improved in future versions).");
|
||||
static ImGuiTableFlags flags = ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable;
|
||||
static int freeze_cols = 1;
|
||||
static int freeze_rows = 1;
|
||||
@ -4762,7 +4794,8 @@ static void ShowDemoWindowTables()
|
||||
HelpMarker(
|
||||
"Showcase using Stretch columns + ScrollX together: "
|
||||
"this is rather unusual and only makes sense when specifying an 'inner_width' for the table!\n"
|
||||
"Without an explicit value, inner_width is == outer_size.x and therefore using Stretch columns + ScrollX together doesn't make sense.");
|
||||
"Without an explicit value, inner_width is == outer_size.x and therefore using Stretch columns "
|
||||
"along with ScrollX doesn't make sense.");
|
||||
static ImGuiTableFlags flags2 = ImGuiTableFlags_SizingStretchSame | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_RowBg | ImGuiTableFlags_ContextMenuInBody;
|
||||
static float inner_width = 1000.0f;
|
||||
PushStyleCompact();
|
||||
@ -4820,8 +4853,9 @@ static void ShowDemoWindowTables()
|
||||
}
|
||||
|
||||
// Create the real table we care about for the example!
|
||||
// We use a scrolling table to be able to showcase the difference between the _IsEnabled and _IsVisible flags above, otherwise in
|
||||
// a non-scrolling table columns are always visible (unless using ImGuiTableFlags_NoKeepColumnsVisible + resizing the parent window down)
|
||||
// We use a scrolling table to be able to showcase the difference between the _IsEnabled and _IsVisible flags above,
|
||||
// otherwise in a non-scrolling table columns are always visible (unless using ImGuiTableFlags_NoKeepColumnsVisible
|
||||
// + resizing the parent window down).
|
||||
const ImGuiTableFlags flags
|
||||
= ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY
|
||||
| ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV
|
||||
@ -4843,7 +4877,8 @@ static void ShowDemoWindowTables()
|
||||
float indent_step = (float)((int)TEXT_BASE_WIDTH / 2);
|
||||
for (int row = 0; row < 8; row++)
|
||||
{
|
||||
ImGui::Indent(indent_step); // Add some indentation to demonstrate usage of per-column IndentEnable/IndentDisable flags.
|
||||
// Add some indentation to demonstrate usage of per-column IndentEnable/IndentDisable flags.
|
||||
ImGui::Indent(indent_step);
|
||||
ImGui::TableNextRow();
|
||||
for (int column = 0; column < column_count; column++)
|
||||
{
|
||||
@ -4892,7 +4927,9 @@ static void ShowDemoWindowTables()
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
HelpMarker("Using TableSetupColumn() to setup explicit width.\n\nUnless _NoKeepColumnsVisible is set, fixed columns with set width may still be shrunk down if there's not enough space in the host.");
|
||||
HelpMarker(
|
||||
"Using TableSetupColumn() to setup explicit width.\n\nUnless _NoKeepColumnsVisible is set, "
|
||||
"fixed columns with set width may still be shrunk down if there's not enough space in the host.");
|
||||
|
||||
static ImGuiTableFlags flags2 = ImGuiTableFlags_None;
|
||||
PushStyleCompact();
|
||||
@ -4902,7 +4939,8 @@ static void ShowDemoWindowTables()
|
||||
PopStyleCompact();
|
||||
if (ImGui::BeginTable("table2", 4, flags2))
|
||||
{
|
||||
// We could also set ImGuiTableFlags_SizingFixedFit on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed.
|
||||
// We could also set ImGuiTableFlags_SizingFixedFit on the table and then all columns
|
||||
// will default to ImGuiTableColumnFlags_WidthFixed.
|
||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 100.0f);
|
||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 15.0f);
|
||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 30.0f);
|
||||
@ -4974,7 +5012,10 @@ static void ShowDemoWindowTables()
|
||||
IMGUI_DEMO_MARKER("Tables/Row height");
|
||||
if (ImGui::TreeNode("Row height"))
|
||||
{
|
||||
HelpMarker("You can pass a 'min_row_height' to TableNextRow().\n\nRows are padded with 'style.CellPadding.y' on top and bottom, so effectively the minimum row height will always be >= 'style.CellPadding.y * 2.0f'.\n\nWe cannot honor a _maximum_ row height as that would require a unique clipping rectangle per row.");
|
||||
HelpMarker(
|
||||
"You can pass a 'min_row_height' to TableNextRow().\n\nRows are padded with 'style.CellPadding.y' on top and bottom, "
|
||||
"so effectively the minimum row height will always be >= 'style.CellPadding.y * 2.0f'.\n\n"
|
||||
"We cannot honor a _maximum_ row height as that would require a unique clipping rectangle per row.");
|
||||
if (ImGui::BeginTable("table_row_height", 1, ImGuiTableFlags_Borders))
|
||||
{
|
||||
for (int row = 0; row < 8; row++)
|
||||
@ -4987,7 +5028,10 @@ static void ShowDemoWindowTables()
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
HelpMarker("Showcase using SameLine(0,0) to share Current Line Height between cells.\n\nPlease note that Tables Row Height is not the same thing as Current Line Height, as a table cell may contains multiple lines.");
|
||||
HelpMarker(
|
||||
"Showcase using SameLine(0,0) to share Current Line Height between cells.\n\n"
|
||||
"Please note that Tables Row Height is not the same thing as Current Line Height, "
|
||||
"as a table cell may contains multiple lines.");
|
||||
if (ImGui::BeginTable("table_share_lineheight", 2, ImGuiTableFlags_Borders))
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
@ -5237,7 +5281,8 @@ static void ShowDemoWindowTables()
|
||||
{
|
||||
HelpMarker(
|
||||
"Showcase using PushItemWidth() and how it is preserved on a per-column basis.\n\n"
|
||||
"Note that on auto-resizing non-resizable fixed columns, querying the content width for e.g. right-alignment doesn't make sense.");
|
||||
"Note that on auto-resizing non-resizable fixed columns, querying the content width for "
|
||||
"e.g. right-alignment doesn't make sense.");
|
||||
if (ImGui::BeginTable("table_item_width", 3, ImGuiTableFlags_Borders))
|
||||
{
|
||||
ImGui::TableSetupColumn("small");
|
||||
@ -5376,13 +5421,16 @@ static void ShowDemoWindowTables()
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
// Demonstrate creating custom context menus inside columns, while playing it nice with context menus provided by TableHeadersRow()/TableHeader()
|
||||
// Demonstrate creating custom context menus inside columns,
|
||||
// while playing it nice with context menus provided by TableHeadersRow()/TableHeader()
|
||||
if (open_action != -1)
|
||||
ImGui::SetNextItemOpen(open_action != 0);
|
||||
IMGUI_DEMO_MARKER("Tables/Context menus");
|
||||
if (ImGui::TreeNode("Context menus"))
|
||||
{
|
||||
HelpMarker("By default, right-clicking over a TableHeadersRow()/TableHeader() line will open the default context-menu.\nUsing ImGuiTableFlags_ContextMenuInBody we also allow right-clicking over columns body.");
|
||||
HelpMarker(
|
||||
"By default, right-clicking over a TableHeadersRow()/TableHeader() line will open the default context-menu.\n"
|
||||
"Using ImGuiTableFlags_ContextMenuInBody we also allow right-clicking over columns body.");
|
||||
static ImGuiTableFlags flags1 = ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders | ImGuiTableFlags_ContextMenuInBody;
|
||||
|
||||
PushStyleCompact();
|
||||
@ -5419,7 +5467,9 @@ static void ShowDemoWindowTables()
|
||||
// [2.1] Right-click on the TableHeadersRow() line to open the default table context menu.
|
||||
// [2.2] Right-click on the ".." to open a custom popup
|
||||
// [2.3] Right-click in columns to open another custom popup
|
||||
HelpMarker("Demonstrate mixing table context menu (over header), item context button (over button) and custom per-colum context menu (over column body).");
|
||||
HelpMarker(
|
||||
"Demonstrate mixing table context menu (over header), item context button (over button) "
|
||||
"and custom per-colunm context menu (over column body).");
|
||||
ImGuiTableFlags flags2 = ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders;
|
||||
if (ImGui::BeginTable("table_context_menu_2", COLUMNS_COUNT, flags2))
|
||||
{
|
||||
@ -5878,7 +5928,7 @@ static void ShowDemoWindowTables()
|
||||
// Here we demonstrate marking our data set as needing to be sorted again if we modified a quantity,
|
||||
// and we are currently sorting on the column showing the Quantity.
|
||||
// To avoid triggering a sort while holding the button, we only trigger it when the button has been released.
|
||||
// You will probably need a more advanced system in your code if you want to automatically sort when a specific entry changes.
|
||||
// You will probably need some extra logic if you want to automatically sort when a specific entry changes.
|
||||
if (ImGui::TableSetColumnIndex(2))
|
||||
{
|
||||
if (ImGui::SmallButton("Chop")) { item->Quantity += 1; }
|
||||
@ -6166,8 +6216,10 @@ static void ShowDemoWindowInputs()
|
||||
for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseDown(i)) { ImGui::SameLine(); ImGui::Text("b%d (%.02f secs)", i, io.MouseDownDuration[i]); }
|
||||
ImGui::Text("Mouse wheel: %.1f", io.MouseWheel);
|
||||
|
||||
// We iterate both legacy native range and named ImGuiKey ranges, which is a little odd but this allows displaying the data for old/new backends.
|
||||
// User code should never have to go through such hoops! You can generally iterate between ImGuiKey_NamedKey_BEGIN and ImGuiKey_NamedKey_END.
|
||||
// We iterate both legacy native range and named ImGuiKey ranges. This is a little unusual/odd but this allows
|
||||
// displaying the data for old/new backends.
|
||||
// User code should never have to go through such hoops!
|
||||
// You can generally iterate between ImGuiKey_NamedKey_BEGIN and ImGuiKey_NamedKey_END.
|
||||
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||
struct funcs { static bool IsLegacyNativeDupe(ImGuiKey) { return false; } };
|
||||
ImGuiKey start_key = ImGuiKey_NamedKey_BEGIN;
|
||||
@ -6206,7 +6258,8 @@ static void ShowDemoWindowInputs()
|
||||
{
|
||||
HelpMarker(
|
||||
"Hovering the colored canvas will override io.WantCaptureXXX fields.\n"
|
||||
"Notice how normally (when set to none), the value of io.WantCaptureKeyboard would be false when hovering and true when clicking.");
|
||||
"Notice how normally (when set to none), the value of io.WantCaptureKeyboard would be false when hovering "
|
||||
"and true when clicking.");
|
||||
static int capture_override_mouse = -1;
|
||||
static int capture_override_keyboard = -1;
|
||||
const char* capture_override_desc[] = { "None", "Set to false", "Set to true" };
|
||||
|
@ -4231,8 +4231,8 @@ static unsigned int stb_decompress(unsigned char *output, const unsigned char *i
|
||||
//-----------------------------------------------------------------------------
|
||||
// ProggyClean.ttf
|
||||
// Copyright (c) 2004, 2005 Tristan Grimmer
|
||||
// MIT license (see License.txt in http://www.upperbounds.net/download/ProggyClean.ttf.zip)
|
||||
// Download and more information at http://upperbounds.net
|
||||
// MIT license (see License.txt in http://www.proggyfonts.net/index.php?menu=download)
|
||||
// Download and more information at http://www.proggyfonts.net or http://upperboundsinteractive.com/fonts.php
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: 'ProggyClean.ttf' (41208 bytes)
|
||||
// Exported using misc/fonts/binary_to_compressed_c.cpp (with compression + base85 string encoding).
|
||||
|
@ -1425,23 +1425,29 @@ struct ImGuiKeyOwnerData
|
||||
// Don't mistake with ImGuiInputTextFlags! (for ImGui::InputText() function)
|
||||
enum ImGuiInputFlags_
|
||||
{
|
||||
// Flags for IsKeyPressed(), IsMouseClicked(), Shortcut()
|
||||
// Flags for IsKeyPressed(), IsKeyChordPressed(), IsMouseClicked(), Shortcut()
|
||||
ImGuiInputFlags_None = 0,
|
||||
ImGuiInputFlags_Repeat = 1 << 0, // Return true on successive repeats. Default for legacy IsKeyPressed(). NOT Default for legacy IsMouseClicked(). MUST BE == 1.
|
||||
ImGuiInputFlags_RepeatRateDefault = 1 << 1, // Repeat rate: Regular (default)
|
||||
ImGuiInputFlags_RepeatRateNavMove = 1 << 2, // Repeat rate: Fast
|
||||
ImGuiInputFlags_RepeatRateNavTweak = 1 << 3, // Repeat rate: Faster
|
||||
ImGuiInputFlags_RepeatRateMask_ = ImGuiInputFlags_RepeatRateDefault | ImGuiInputFlags_RepeatRateNavMove | ImGuiInputFlags_RepeatRateNavTweak,
|
||||
|
||||
// Specify when repeating key pressed can be interrupted.
|
||||
// In theory ImGuiInputFlags_RepeatUntilOtherKeyPress may be a desirable default, but it would break too many behavior so everything is opt-in.
|
||||
ImGuiInputFlags_RepeatUntilRelease = 1 << 4, // Stop repeating when released (default for all functions except Shortcut). This only exists to allow overriding Shortcut() default behavior.
|
||||
ImGuiInputFlags_RepeatUntilKeyModsChange = 1 << 5, // Stop repeating when released OR if keyboard mods are changed (default for Shortcut)
|
||||
ImGuiInputFlags_RepeatUntilKeyModsChangeFromNone = 1 << 6, // Stop repeating when released OR if keyboard mods are leaving the None state. Allows going from Mod+Key to Key by releasing Mod.
|
||||
ImGuiInputFlags_RepeatUntilOtherKeyPress = 1 << 7, // Stop repeating when released OR if any other keyboard key is pressed during the repeat
|
||||
|
||||
// Flags for SetItemKeyOwner()
|
||||
ImGuiInputFlags_CondHovered = 1 << 4, // Only set if item is hovered (default to both)
|
||||
ImGuiInputFlags_CondActive = 1 << 5, // Only set if item is active (default to both)
|
||||
ImGuiInputFlags_CondHovered = 1 << 8, // Only set if item is hovered (default to both)
|
||||
ImGuiInputFlags_CondActive = 1 << 9, // Only set if item is active (default to both)
|
||||
ImGuiInputFlags_CondDefault_ = ImGuiInputFlags_CondHovered | ImGuiInputFlags_CondActive,
|
||||
ImGuiInputFlags_CondMask_ = ImGuiInputFlags_CondHovered | ImGuiInputFlags_CondActive,
|
||||
|
||||
// Flags for SetKeyOwner(), SetItemKeyOwner()
|
||||
ImGuiInputFlags_LockThisFrame = 1 << 6, // Access to key data will require EXPLICIT owner ID (ImGuiKeyOwner_Any/0 will NOT accepted for polling). Cleared at end of frame. This is useful to make input-owner-aware code steal keys from non-input-owner-aware code.
|
||||
ImGuiInputFlags_LockUntilRelease = 1 << 7, // Access to key data will require EXPLICIT owner ID (ImGuiKeyOwner_Any/0 will NOT accepted for polling). Cleared when the key is released or at end of each frame if key is released. This is useful to make input-owner-aware code steal keys from non-input-owner-aware code.
|
||||
ImGuiInputFlags_LockThisFrame = 1 << 10, // Access to key data will require EXPLICIT owner ID (ImGuiKeyOwner_Any/0 will NOT accepted for polling). Cleared at end of frame. This is useful to make input-owner-aware code steal keys from non-input-owner-aware code.
|
||||
ImGuiInputFlags_LockUntilRelease = 1 << 11, // Access to key data will require EXPLICIT owner ID (ImGuiKeyOwner_Any/0 will NOT accepted for polling). Cleared when the key is released or at end of each frame if key is released. This is useful to make input-owner-aware code steal keys from non-input-owner-aware code.
|
||||
|
||||
// Routing policies for Shortcut() + low-level SetShortcutRouting()
|
||||
// - The general idea is that several callers register interest in a shortcut, and only one owner gets it.
|
||||
@ -1453,18 +1459,22 @@ enum ImGuiInputFlags_
|
||||
// - Using ImGuiInputFlags_RouteAlways is roughly equivalent to doing e.g. IsKeyPressed(key) + testing mods.
|
||||
// - Priorities: GlobalHigh > Focused (when owner is active item) > Global > Focused (when focused window) > GlobalLow.
|
||||
// - Can select only 1 policy among all available.
|
||||
ImGuiInputFlags_RouteFocused = 1 << 8, // (Default) Register focused route: Accept inputs if window is in focus stack. Deep-most focused window takes inputs. ActiveId takes inputs over deep-most focused window.
|
||||
ImGuiInputFlags_RouteGlobalLow = 1 << 9, // Register route globally (lowest priority: unless a focused window or active item registered the route) -> recommended Global priority.
|
||||
ImGuiInputFlags_RouteGlobal = 1 << 10, // Register route globally (medium priority: unless an active item registered the route, e.g. CTRL+A registered by InputText).
|
||||
ImGuiInputFlags_RouteGlobalHigh = 1 << 11, // Register route globally (highest priority: unlikely you need to use that: will interfere with every active items)
|
||||
ImGuiInputFlags_RouteFocused = 1 << 12, // (Default) Register focused route: Accept inputs if window is in focus stack. Deep-most focused window takes inputs. ActiveId takes inputs over deep-most focused window.
|
||||
ImGuiInputFlags_RouteGlobalLow = 1 << 13, // Register route globally (lowest priority: unless a focused window or active item registered the route) -> recommended Global priority.
|
||||
ImGuiInputFlags_RouteGlobal = 1 << 14, // Register route globally (medium priority: unless an active item registered the route, e.g. CTRL+A registered by InputText).
|
||||
ImGuiInputFlags_RouteGlobalHigh = 1 << 15, // Register route globally (highest priority: unlikely you need to use that: will interfere with every active items)
|
||||
ImGuiInputFlags_RouteMask_ = ImGuiInputFlags_RouteFocused | ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteGlobalLow | ImGuiInputFlags_RouteGlobalHigh, // _Always not part of this!
|
||||
ImGuiInputFlags_RouteAlways = 1 << 12, // Do not register route, poll keys directly.
|
||||
ImGuiInputFlags_RouteUnlessBgFocused= 1 << 13, // Global routes will not be applied if underlying background/void is focused (== no Dear ImGui windows are focused). Useful for overlay applications.
|
||||
ImGuiInputFlags_RouteAlways = 1 << 16, // Do not register route, poll keys directly.
|
||||
ImGuiInputFlags_RouteUnlessBgFocused= 1 << 17, // Global routes will not be applied if underlying background/void is focused (== no Dear ImGui windows are focused). Useful for overlay applications.
|
||||
ImGuiInputFlags_RouteExtraMask_ = ImGuiInputFlags_RouteAlways | ImGuiInputFlags_RouteUnlessBgFocused,
|
||||
|
||||
// [Internal] Mask of which function support which flags
|
||||
ImGuiInputFlags_SupportedByIsKeyPressed = ImGuiInputFlags_Repeat | ImGuiInputFlags_RepeatRateMask_,
|
||||
ImGuiInputFlags_SupportedByShortcut = ImGuiInputFlags_Repeat | ImGuiInputFlags_RepeatRateMask_ | ImGuiInputFlags_RouteMask_ | ImGuiInputFlags_RouteExtraMask_,
|
||||
ImGuiInputFlags_RepeatRateMask_ = ImGuiInputFlags_RepeatRateDefault | ImGuiInputFlags_RepeatRateNavMove | ImGuiInputFlags_RepeatRateNavTweak,
|
||||
ImGuiInputFlags_RepeatUntilMask_ = ImGuiInputFlags_RepeatUntilRelease | ImGuiInputFlags_RepeatUntilKeyModsChange | ImGuiInputFlags_RepeatUntilKeyModsChangeFromNone | ImGuiInputFlags_RepeatUntilOtherKeyPress,
|
||||
ImGuiInputFlags_RepeatMask_ = ImGuiInputFlags_Repeat | ImGuiInputFlags_RepeatRateMask_ | ImGuiInputFlags_RepeatUntilMask_,
|
||||
ImGuiInputFlags_SupportedByIsKeyPressed = ImGuiInputFlags_RepeatMask_,
|
||||
ImGuiInputFlags_SupportedByIsMouseClicked = ImGuiInputFlags_Repeat,
|
||||
ImGuiInputFlags_SupportedByShortcut = ImGuiInputFlags_RepeatMask_ | ImGuiInputFlags_RouteMask_ | ImGuiInputFlags_RouteExtraMask_,
|
||||
ImGuiInputFlags_SupportedBySetKeyOwner = ImGuiInputFlags_LockThisFrame | ImGuiInputFlags_LockUntilRelease,
|
||||
ImGuiInputFlags_SupportedBySetItemKeyOwner = ImGuiInputFlags_SupportedBySetKeyOwner | ImGuiInputFlags_CondMask_,
|
||||
};
|
||||
@ -2129,6 +2139,9 @@ struct ImGuiContext
|
||||
// - The idea is that instead of "eating" a given key, we can link to an owner.
|
||||
// - Input query can then read input by specifying ImGuiKeyOwner_Any (== 0), ImGuiKeyOwner_None (== -1) or a custom ID.
|
||||
// - Routing is requested ahead of time for a given chord (Key + Mods) and granted in NewFrame().
|
||||
double LastKeyModsChangeTime; // Record the last time key mods changed (affect repeat delay when using shortcut logic)
|
||||
double LastKeyModsChangeFromNoneTime; // Record the last time key mods changed away from being 0 (affect repeat delay when using shortcut logic)
|
||||
double LastKeyboardKeyPressTime; // Record the last time a keyboard key (ignore mouse/gamepad ones) was pressed.
|
||||
ImGuiKeyOwnerData KeysOwnerData[ImGuiKey_NamedKey_COUNT];
|
||||
ImGuiKeyRoutingTable KeysRoutingTable;
|
||||
ImU32 ActiveIdUsingNavDirMask; // Active widget will want to read those nav move requests (e.g. can activate a button and move away from it)
|
||||
@ -2432,6 +2445,8 @@ struct ImGuiContext
|
||||
LastActiveId = 0;
|
||||
LastActiveIdTimer = 0.0f;
|
||||
|
||||
LastKeyboardKeyPressTime = LastKeyModsChangeTime = LastKeyModsChangeFromNoneTime = -1.0;
|
||||
|
||||
ActiveIdUsingNavDirMask = 0x00;
|
||||
ActiveIdUsingAllKeyboardKeys = false;
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||
|
@ -1013,6 +1013,8 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, ImS6
|
||||
return held;
|
||||
}
|
||||
|
||||
// - Read about ImTextureID here: https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples
|
||||
// - 'uv0' and 'uv1' are texture coordinates. Read about them from the same link above.
|
||||
void ImGui::Image(ImTextureID user_texture_id, const ImVec2& image_size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
@ -5719,7 +5721,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
||||
}
|
||||
|
||||
// Render cursor/preview circle (clamp S/V within 0..1 range because floating points colors may lead HSV values to be out of range)
|
||||
float sv_cursor_rad = value_changed_sv ? 10.0f : 6.0f;
|
||||
float sv_cursor_rad = value_changed_sv ? wheel_thickness * 0.55f : wheel_thickness * 0.40f;
|
||||
int sv_cursor_segments = draw_list->_CalcCircleAutoSegmentCount(sv_cursor_rad); // Lock segment count so the +1 one matches others.
|
||||
draw_list->AddCircleFilled(sv_cursor_pos, sv_cursor_rad, user_col32_striped_of_alpha, sv_cursor_segments);
|
||||
draw_list->AddCircle(sv_cursor_pos, sv_cursor_rad + 1, col_midgrey, sv_cursor_segments);
|
||||
|
@ -437,7 +437,7 @@ bool ImFontAtlasBuildWithFreeTypeEx(FT_Library ft_library, ImFontAtlas* atlas, u
|
||||
ImFontAtlasBuildInit(atlas);
|
||||
|
||||
// Clear atlas
|
||||
atlas->TexID = (ImTextureID)nullptr;
|
||||
atlas->TexID = 0;
|
||||
atlas->TexWidth = atlas->TexHeight = 0;
|
||||
atlas->TexUvScale = ImVec2(0.0f, 0.0f);
|
||||
atlas->TexUvWhitePixel = ImVec2(0.0f, 0.0f);
|
||||
|
Loading…
Reference in New Issue
Block a user