mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-19 06:26:35 +00:00
Merge branch 'master' into viewport
# Conflicts: # examples/allegro5_example/imgui_impl_a5.cpp # examples/allegro5_example/imgui_impl_a5.h # examples/allegro5_example/imgui_impl_allegro5.cpp # examples/allegro5_example/imgui_impl_allegro5.h # examples/allegro5_example/main.cpp # examples/imgui_impl_allegro5.cpp # examples/imgui_impl_allegro5.h # imgui.cpp # imgui_internal.h
This commit is contained in:
commit
3b9b1956cd
6
.github/CONTRIBUTING.md
vendored
6
.github/CONTRIBUTING.md
vendored
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Hello!
|
Hello!
|
||||||
|
|
||||||
You may use the Issue Tracker to submit bug reports, feature requests or suggestions. You may ask for help or advice as well. However please read this wall of text before doing so. The amount of incomplete or ambiguous requests occasionally becomes overwhelming, so please do your best to clarify your request. Thank you!
|
You may use the Issue Tracker to submit bug reports, feature requests or suggestions. You may ask for help or advice as well. However please read this wall of text before doing so. The amount of incomplete or ambiguous requests due to people not following those guidelines is often overwhelming. Please do your best to clarify your request. Thank you!
|
||||||
|
|
||||||
**Prerequisites for new users of dear imgui:**
|
**Prerequisites for new users of dear imgui:**
|
||||||
- Please read the FAQ in imgui.cpp.
|
- Please read the FAQ in imgui.cpp.
|
||||||
@ -16,8 +16,8 @@ You may use the Issue Tracker to submit bug reports, feature requests or suggest
|
|||||||
- Please provide your imgui version number.
|
- Please provide your imgui version number.
|
||||||
- If you are discussing an assert or a crash, please provide a debugger callstack.
|
- If you are discussing an assert or a crash, please provide a debugger callstack.
|
||||||
- Please state if you have made substantial modifications to your copy of imgui.
|
- Please state if you have made substantial modifications to your copy of imgui.
|
||||||
- When discussing issues related to rendering or inputs, please state which OS you are using, and if you are using a vanilla copy of one of the back end (imgui_impl_xxx files), or a modified one, or if you built your own.
|
- When discussing issues related to rendering or inputs, please state the OS/back-end/renderer you are using. Please state if you are using a vanilla copy of one of the back-end (imgui_impl_xxx files), or a modified one, or if you built your own.
|
||||||
- Try to provide a Minimal, Complete and Verifiable Example ([MCVE](https://stackoverflow.com/help/mcve)) to demonstrate your problem. An ideal submission includes a small piece of code that anyone can paste in one of the examples/ application to understand and reproduce it. Narrowing your problem to its shortest and purest form is often the easiest way to understand it. Often while creating the MCVE you will end up solving the problem!
|
- Please provide a Minimal, Complete and Verifiable Example ([MCVE](https://stackoverflow.com/help/mcve)) to demonstrate your problem. An ideal submission includes a small piece of code that anyone can paste in one of the examples/ application (e.g. in main.cpp or imgui_demo.cpp) to understand and reproduce it. Narrowing your problem to its shortest and purest form is the easiest way to understand it. Please test your shortened code to ensure it actually exhibit the problem. Often while creating the MCVE you will end up solving 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.
|
||||||
- Try to attach screenshots to clarify the context. They often convey useful information that are omitted by the description. You can drag pictures/files here (prefer github attachments over 3rd party hosting).
|
- Try to attach screenshots to clarify the context. They often convey useful information that are omitted by the description. You can drag pictures/files here (prefer github attachments over 3rd party hosting).
|
||||||
- When requesting a new feature, please describe the usage context (how you intend to use it, why you need it, etc.).
|
- When requesting a new feature, please describe the usage context (how you intend to use it, why you need it, etc.).
|
||||||
- Due to frequent abuse of this service from a certain category of users, if your GitHub account is anonymous and was created five minutes ago please understand that your post will receive more scrutiny and less patience for incomplete questions.
|
- Due to frequent abuse of this service from a certain category of users, if your GitHub account is anonymous and was created five minutes ago please understand that your post will receive more scrutiny and less patience for incomplete questions.
|
||||||
|
31
.github/issue_template.md
vendored
31
.github/issue_template.md
vendored
@ -1,12 +1,29 @@
|
|||||||
You may use the Issue Tracker to ask for help and submit bug reports, feature requests or suggestions.
|
You may use the Issue Tracker to ask for help and submit bug reports, feature requests or suggestions.
|
||||||
|
|
||||||
PLEASE CAREFULLY READ THIS DOCUMENT before doing so:
|
PLEASE CAREFULLY READ THIS DOCUMENT before doing so:
|
||||||
[CONTRIBUTING.md](https://github.com/ocornut/imgui/blob/master/.github/CONTRIBUTING.md).
|
[CONTRIBUTING.md](https://github.com/ocornut/imgui/blob/master/.github/CONTRIBUTING.md).
|
||||||
|
|
||||||
You can include code snippets using `Begin()` for short in-line snippets, or:
|
SELECT "PREVIEW CHANGES" TO TURN THE URL ABOVE INTO A CLICKABLE LINK.
|
||||||
```cpp
|
|
||||||
ImGui::Begin("Hello");
|
|
||||||
ImGui::ThisIsMoreCode();
|
|
||||||
```
|
|
||||||
For multiline snippets.
|
|
||||||
|
|
||||||
(Clear this form before submitting your issue. Please read the CONTRIBUTING.md file!)
|
(Delete everything above this section before submitting your issue. Please read the CONTRIBUTING.md file!)
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
**Version/Branch of Dear ImGui:**
|
||||||
|
|
||||||
|
XXX
|
||||||
|
|
||||||
|
**Back-end/Renderer/OS:** _(if the question is related to inputs or rendering, otherwise delete this section)_
|
||||||
|
|
||||||
|
XXX
|
||||||
|
|
||||||
|
**My Issue/Question:** _(please provide context)_
|
||||||
|
|
||||||
|
**Standalone, minimal, complete and verifiable example:** _(see CONTRIBUTING.md)_
|
||||||
|
```
|
||||||
|
ImGui::Begin("Example Bug");
|
||||||
|
MoreCodeToExplainMyIssue();
|
||||||
|
ImGui::End();
|
||||||
|
```
|
||||||
|
|
||||||
|
**Screenshots/Video** _(you can drag files here)_
|
||||||
|
@ -42,7 +42,7 @@ VERSION 1.61 WIP
|
|||||||
Breaking Changes:
|
Breaking Changes:
|
||||||
(IN PROGRESS, WILL ADD TO THIS LIST AS WE WORK ON 1.61)
|
(IN PROGRESS, WILL ADD TO THIS LIST AS WE WORK ON 1.61)
|
||||||
|
|
||||||
- Misc: IM_DELETE() helper function added in 1.60 doesn't clear the input _pointer_ reference, more consistent with expectation and allows passing r-value.
|
- Misc: IM_DELETE() helper function added in 1.60 doesn't set the input pointer to NULL, more consistent with standard expectation and allows passing r-value.
|
||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
(IN PROGRESS, WILL ADD TO THIS LIST AS WE WORK ON 1.61)
|
(IN PROGRESS, WILL ADD TO THIS LIST AS WE WORK ON 1.61)
|
||||||
@ -50,8 +50,16 @@ Other Changes:
|
|||||||
- Settings: Fixed saving an empty .ini file if CreateContext/DestroyContext are called without a single call to NewFrame(). (#1741)
|
- Settings: Fixed saving an empty .ini file if CreateContext/DestroyContext are called without a single call to NewFrame(). (#1741)
|
||||||
- Window: Fixed default proportional item width lagging by one frame on resize.
|
- Window: Fixed default proportional item width lagging by one frame on resize.
|
||||||
- Window: Fixed popups/tooltips/menus not honoring style.DisplaySafeAreaPadding as well as it should have (part of menus displayed outside the safe area, etc.).
|
- Window: Fixed popups/tooltips/menus not honoring style.DisplaySafeAreaPadding as well as it should have (part of menus displayed outside the safe area, etc.).
|
||||||
|
- Window: Fixed windows using the ImGuiWindowFlags_NoSavedSettings flag from not using the same default position as other windows. (#1760)
|
||||||
|
- Window: Relaxed the internal stack size checker to allow Push/Begin/Pop/.../End patterns to be used with PushStyleColor, PushStyleVar, PushFont without causing a false positive assert. (#1767)
|
||||||
|
- Columns: Fixed a bug introduced in 1.51 where columns would affect the contents size of their container, often creating feedback loops when ImGuiWindowFlags_AlwaysAutoResize was used. (#1760)
|
||||||
- MenuBar: Made BeginMainMenuBar() honor style.DisplaySafeAreaPadding so the text can be made visible on TV settings that don't display all pixels. (#1439) [@dougbinks]
|
- MenuBar: Made BeginMainMenuBar() honor style.DisplaySafeAreaPadding so the text can be made visible on TV settings that don't display all pixels. (#1439) [@dougbinks]
|
||||||
|
- InputText: On Mac OS X, filter out characters when the Cmd modifier is held. (#1747) [@sivu]
|
||||||
|
- InputText: On Mac OS X, support Cmd+Shift+Z for Redo. Cmd+Y is also supported as major apps seems to default to support both. (#1765) [@lfnoise]
|
||||||
- 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)
|
||||||
|
- Demo: Fixed Overlay: Added a context menu item to enable freely moving the window.
|
||||||
|
- Examples: Allegro 5: Added support for 32-bit indices setup via defining ImDrawIdx, to avoid an unnecessary conversion (Allegro 5 doesn't support 16-bit indices).
|
||||||
|
- Examples: Allegro 5: Renamed bindings from imgui_impl_a5.cpp to imgui_impl_allegro5.cpp.
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
@ -60,7 +68,7 @@ Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.60
|
|||||||
|
|
||||||
The gamepad/keyboard navigation branch (which has been in the work since July 2016) has been merged.
|
The gamepad/keyboard navigation branch (which has been in the work since July 2016) has been merged.
|
||||||
Gamepad/keyboard navigation is still marked as Beta and has to be enabled explicitly.
|
Gamepad/keyboard navigation is still marked as Beta and has to be enabled explicitly.
|
||||||
Various internal refactors have also been done, as part of the navigation work and as part of the upcoing viewport/docking work.
|
Various internal refactors have also been done, as part of the navigation work and as part of the upcoming viewport/docking work.
|
||||||
|
|
||||||
VIEWPORT BRANCH
|
VIEWPORT BRANCH
|
||||||
(IN PROGRESS, WILL MERGE INTO THE MAIN LISTS WHEN WE MERGE THE BRANCH)
|
(IN PROGRESS, WILL MERGE INTO THE MAIN LISTS WHEN WE MERGE THE BRANCH)
|
||||||
@ -100,7 +108,7 @@ Breaking Changes:
|
|||||||
- Reorganized context handling to be more explicit: (#1599)
|
- Reorganized context handling to be more explicit: (#1599)
|
||||||
- YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END.
|
- YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END.
|
||||||
- removed Shutdown() function, as DestroyContext() serve this purpose. If you are using an old back-end from the examples/ folder, remove the line that calls Shutdown().
|
- removed Shutdown() function, as DestroyContext() serve this purpose. If you are using an old back-end from the examples/ folder, remove the line that calls Shutdown().
|
||||||
- you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwhise CreateContext() will create its own font atlas instance.
|
- you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwise CreateContext() will create its own font atlas instance.
|
||||||
- removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions(), and shared by all contexts.
|
- removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions(), and shared by all contexts.
|
||||||
- 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.
|
||||||
|
@ -3,7 +3,7 @@ dear imgui,
|
|||||||
[![Build Status](https://travis-ci.org/ocornut/imgui.svg?branch=master)](https://travis-ci.org/ocornut/imgui)
|
[![Build Status](https://travis-ci.org/ocornut/imgui.svg?branch=master)](https://travis-ci.org/ocornut/imgui)
|
||||||
[![Coverity Status](https://scan.coverity.com/projects/4720/badge.svg)](https://scan.coverity.com/projects/4720)
|
[![Coverity Status](https://scan.coverity.com/projects/4720/badge.svg)](https://scan.coverity.com/projects/4720)
|
||||||
|
|
||||||
_(This library is free but needs your support to sustain its development. There are many desirable features and maintenance ahead If you are an individual using dear imgui, please consider donating via Patreon or PayPal. If your company is using dear imgui, please consider financial support (e.g. sponsoring a few weeks/months of development). I can invoice for technical support, custom development etc. E-mail: omarcornut at gmail.)_
|
_(This library is free but needs your support to sustain its development. There are many desirable features and maintenance ahead. If you are an individual using dear imgui, please consider donating via Patreon or PayPal. If your company is using dear imgui, please consider financial support (e.g. sponsoring a few weeks/months of development. I can invoice for technical support, custom development etc. E-mail: omarcornut at gmail)._
|
||||||
|
|
||||||
Monthly donations via Patreon:
|
Monthly donations via Patreon:
|
||||||
<br>[![Patreon](https://cloud.githubusercontent.com/assets/8225057/5990484/70413560-a9ab-11e4-8942-1a63607c0b00.png)](http://www.patreon.com/imgui)
|
<br>[![Patreon](https://cloud.githubusercontent.com/assets/8225057/5990484/70413560-a9ab-11e4-8942-1a63607c0b00.png)](http://www.patreon.com/imgui)
|
||||||
@ -284,7 +284,7 @@ Monthly donations via Patreon:
|
|||||||
One-off donations via PayPal:
|
One-off donations via PayPal:
|
||||||
<br>[![PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
|
<br>[![PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
|
||||||
|
|
||||||
If your company uses dear imgui, please consider financial support (e.g. sponsoring a few weeks/months of development). I can invoice for private support, custom development etc. E-mail: omarcornut at gmail. Thanks!
|
If your company uses dear imgui, please consider financial support (e.g. sponsoring a few weeks/months of development. I can invoice for private support, custom development etc. E-mail: omarcornut at gmail). Thanks!
|
||||||
|
|
||||||
Credits
|
Credits
|
||||||
-------
|
-------
|
||||||
|
@ -1,15 +1,23 @@
|
|||||||
|
|
||||||
|
# Configuration
|
||||||
|
|
||||||
|
Dear ImGui outputs 16-bit vertex indices by default.
|
||||||
|
Allegro doesn't support them natively, so we have two solutions: convert the indices manually in imgui_impl_allegro5.cpp, or compile imgui with 32-bit indices.
|
||||||
|
You can either modify imconfig.h that comes with Dear ImGui (easier), or set a C++ preprocessor option IMGUI_USER_CONFIG to find to a filename.
|
||||||
|
We are providing `imconfig_allegro5.h` that enables 32-bit indices.
|
||||||
|
Note that the back-end supports _BOTH_ 16-bit and 32-bit indices, but 32-bit indices will be slightly faster as they won't require a manual conversion.
|
||||||
|
|
||||||
# How to Build
|
# How to Build
|
||||||
|
|
||||||
- On Ubuntu 14.04+
|
- On Ubuntu 14.04+
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
g++ -I ../.. main.cpp imgui_impl_a5.cpp ../../imgui*.cpp -lallegro -lallegro_primitives -o allegro5_example
|
g++ -DIMGUI_USER_CONFIG=\"examples/allegro5_example/imconfig_allegro5.h\" -I ../.. main.cpp imgui_impl_allegro5.cpp ../../imgui*.cpp -lallegro -lallegro_primitives -o allegro5_example
|
||||||
```
|
```
|
||||||
|
|
||||||
- On Windows with Visual Studio's CLI
|
- On Windows with Visual Studio's CLI
|
||||||
|
|
||||||
```
|
```
|
||||||
set ALLEGRODIR=path_to_your_allegro5_folder
|
set ALLEGRODIR=path_to_your_allegro5_folder
|
||||||
cl /Zi /MD /I %ALLEGRODIR%\include /I ..\.. main.cpp imgui_impl_a5.cpp ..\..\imgui*.cpp /link /LIBPATH:%ALLEGRODIR%\lib allegro-5.0.10-monolith-md.lib user32.lib
|
cl /Zi /MD /I %ALLEGRODIR%\include /DIMGUI_USER_CONFIG=\"examples/allegro5_example/imconfig_allegro5.h\" /I ..\.. main.cpp imgui_impl_allegro5.cpp ..\..\imgui*.cpp /link /LIBPATH:%ALLEGRODIR%\lib allegro-5.0.10-monolith-md.lib user32.lib
|
||||||
```
|
```
|
||||||
|
11
examples/allegro5_example/imconfig_allegro5.h
Normal file
11
examples/allegro5_example/imconfig_allegro5.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// COMPILE-TIME OPTIONS FOR DEAR IMGUI ALLEGRO 5 EXAMPLE
|
||||||
|
// See imconfig.h for the full template
|
||||||
|
// Because Allegro doesn't support 16-bit vertex indices, we enable the compile-time option of imgui to use 32-bit indices
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Use 32-bit vertex indices because Allegro doesn't support 16-bit ones
|
||||||
|
// This allows us to avoid converting vertices format at runtime
|
||||||
|
#define ImDrawIdx int
|
@ -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)
|
||||||
|
// 2018-04-18: Misc: Renamed file from imgui_impl_a5.cpp to imgui_impl_allegro5.cpp.
|
||||||
|
// 2018-04-18: Misc: Added support for 32-bits vertex indices to avoid conversion at runtime. Added imconfig_allegro5.h to enforce 32-bit indices when included from imgui.h.
|
||||||
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplAllegro5_RenderDrawData() in the .h file so you can call it yourself.
|
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplAllegro5_RenderDrawData() in the .h file so you can call it yourself.
|
||||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||||
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
|
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
|
||||||
@ -68,12 +70,21 @@ void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data)
|
|||||||
vertices[i] = v;
|
vertices[i] = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
|
const int* indices = NULL;
|
||||||
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
|
if (sizeof(ImDrawIdx) == 2)
|
||||||
static ImVector<int> indices;
|
{
|
||||||
indices.resize(cmd_list->IdxBuffer.Size);
|
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices.. You can '#define ImDrawIdx int' in imconfig.h to request ImGui to output 32-bit indices.
|
||||||
|
// Otherwise, we convert them from 16-bit to 32-bit at runtime here, which works perfectly but is a little wasteful.
|
||||||
|
static ImVector<int> indices_converted;
|
||||||
|
indices_converted.resize(cmd_list->IdxBuffer.Size);
|
||||||
for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
|
for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
|
||||||
indices[i] = (int)cmd_list->IdxBuffer.Data[i];
|
indices_converted[i] = (int)cmd_list->IdxBuffer.Data[i];
|
||||||
|
indices = indices_converted.Data;
|
||||||
|
}
|
||||||
|
else if (sizeof(ImDrawIdx) == 4)
|
||||||
|
{
|
||||||
|
indices = (const int*)cmd_list->IdxBuffer.Data;
|
||||||
|
}
|
||||||
|
|
||||||
int idx_offset = 0;
|
int idx_offset = 0;
|
||||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||||
|
@ -5,8 +5,9 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// A) You may edit imconfig.h (and not overwrite it when updating imgui, or maintain a patch/branch with your modifications to imconfig.h)
|
// A) You may edit imconfig.h (and not overwrite it when updating imgui, or maintain a patch/branch with your modifications to imconfig.h)
|
||||||
// B) or add configuration directives in your own file and compile with #define IMGUI_USER_CONFIG "myfilename.h"
|
// B) or add configuration directives in your own file and compile with #define IMGUI_USER_CONFIG "myfilename.h"
|
||||||
// C) Many compile-time options have an effect on data structures. They need defined consistently _everywhere_ imgui.h is included,
|
// If you do so you need to make sure that configuration settings are defined consistently _everywhere_ dear imgui is used, which include
|
||||||
// not only for the imgui*.cpp compilation units. Defining those options in imconfig.h will ensure they correctly get used everywhere.
|
// the imgui*.cpp files but also _any_ of your code that uses 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.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
134
imgui.cpp
134
imgui.cpp
@ -124,7 +124,7 @@
|
|||||||
- Call ImGui::NewFrame() to begin the frame
|
- Call ImGui::NewFrame() to begin the frame
|
||||||
- You can use any ImGui function you want between NewFrame() and Render()
|
- You can use any ImGui function you want between NewFrame() and Render()
|
||||||
- Call ImGui::Render() as late as you can to end the frame and finalize render data. it will call your io.RenderDrawListFn handler.
|
- Call ImGui::Render() as late as you can to end the frame and finalize render data. it will call your io.RenderDrawListFn handler.
|
||||||
(Even if you don't render, call Render() and ignore the callback, or call EndFrame() instead. Otherwhise some features will break)
|
(Even if you don't render, call Render() and ignore the callback, or call EndFrame() instead. Otherwise some features will break)
|
||||||
- All rendering information are stored into command-lists until ImGui::Render() is called.
|
- All rendering information are stored into command-lists until ImGui::Render() is called.
|
||||||
- Dear ImGui never touches or knows about your GPU state. the only function that knows about GPU is the RenderDrawListFn handler that you provide.
|
- Dear ImGui never touches or knows about your GPU state. the only function that knows about GPU is the RenderDrawListFn handler that you provide.
|
||||||
- Effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render" phases
|
- Effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render" phases
|
||||||
@ -275,7 +275,7 @@
|
|||||||
- 2018/02/07 (1.60) - reorganized context handling to be more explicit,
|
- 2018/02/07 (1.60) - reorganized context handling to be more explicit,
|
||||||
- YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END.
|
- YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END.
|
||||||
- removed Shutdown() function, as DestroyContext() serve this purpose.
|
- removed Shutdown() function, as DestroyContext() serve this purpose.
|
||||||
- you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwhise CreateContext() will create its own font atlas instance.
|
- you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwise CreateContext() will create its own font atlas instance.
|
||||||
- removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions(), and shared by all contexts.
|
- removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions(), and shared by all contexts.
|
||||||
- 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.
|
||||||
- 2018/01/31 (1.60) - 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.
|
- 2018/01/31 (1.60) - 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.
|
||||||
@ -777,7 +777,7 @@ static void SetClipboardTextFn_DefaultImpl(void* user_data, const ch
|
|||||||
// Context
|
// Context
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Current context pointer. Implicitely used by all ImGui functions. Always assumed to be != NULL.
|
// Current context pointer. Implicitly used by all ImGui functions. Always assumed to be != NULL.
|
||||||
// CreateContext() will automatically set this pointer if it is NULL. Change to a different context by calling ImGui::SetCurrentContext().
|
// CreateContext() will automatically set this pointer if it is NULL. Change to a different context by calling ImGui::SetCurrentContext().
|
||||||
// If you use DLL hotreloading you might need to call SetCurrentContext() after reloading code from this file.
|
// If you use DLL hotreloading you might need to call SetCurrentContext() after reloading code from this file.
|
||||||
// ImGui functions are not thread-safe because of this pointer. If you want thread-safety to allow N threads to access N different contexts, you can:
|
// ImGui functions are not thread-safe because of this pointer. If you want thread-safety to allow N threads to access N different contexts, you can:
|
||||||
@ -1927,7 +1927,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
|
|||||||
ViewportId = 0;
|
ViewportId = 0;
|
||||||
ViewportAllowPlatformMonitorExtend = -1;
|
ViewportAllowPlatformMonitorExtend = -1;
|
||||||
ViewportPos = ImVec2(FLT_MAX, FLT_MAX);
|
ViewportPos = ImVec2(FLT_MAX, FLT_MAX);
|
||||||
PosFloat = Pos = ImVec2(0.0f, 0.0f);
|
Pos = ImVec2(0.0f, 0.0f);
|
||||||
Size = SizeFull = ImVec2(0.0f, 0.0f);
|
Size = SizeFull = ImVec2(0.0f, 0.0f);
|
||||||
SizeContents = SizeContentsExplicit = ImVec2(0.0f, 0.0f);
|
SizeContents = SizeContentsExplicit = ImVec2(0.0f, 0.0f);
|
||||||
WindowPadding = ImVec2(0.0f, 0.0f);
|
WindowPadding = ImVec2(0.0f, 0.0f);
|
||||||
@ -2944,8 +2944,8 @@ static void ImGui::NavUpdateWindowing()
|
|||||||
if (move_delta.x != 0.0f || move_delta.y != 0.0f)
|
if (move_delta.x != 0.0f || move_delta.y != 0.0f)
|
||||||
{
|
{
|
||||||
const float NAV_MOVE_SPEED = 800.0f;
|
const float NAV_MOVE_SPEED = 800.0f;
|
||||||
const float move_speed = ImFloor(NAV_MOVE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y));
|
const float move_speed = ImFloor(NAV_MOVE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y)); // FIXME: Doesn't code variable framerate very well
|
||||||
g.NavWindowingTarget->PosFloat += move_delta * move_speed;
|
g.NavWindowingTarget->Pos += move_delta * move_speed;
|
||||||
g.NavDisableMouseHover = true;
|
g.NavDisableMouseHover = true;
|
||||||
MarkIniSettingsDirty(g.NavWindowingTarget);
|
MarkIniSettingsDirty(g.NavWindowingTarget);
|
||||||
}
|
}
|
||||||
@ -3351,7 +3351,7 @@ static void ImGui::UpdateMovingWindow()
|
|||||||
if (g.IO.MouseDown[0] && IsMousePosValid(&g.IO.MousePos))
|
if (g.IO.MouseDown[0] && IsMousePosValid(&g.IO.MousePos))
|
||||||
{
|
{
|
||||||
ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset;
|
ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset;
|
||||||
if (moving_window->PosFloat.x != pos.x || moving_window->PosFloat.y != pos.y)
|
if (moving_window->Pos.x != pos.x || moving_window->Pos.y != pos.y)
|
||||||
{
|
{
|
||||||
MarkIniSettingsDirty(moving_window);
|
MarkIniSettingsDirty(moving_window);
|
||||||
SetWindowPos(moving_window, pos, ImGuiCond_Always);
|
SetWindowPos(moving_window, pos, ImGuiCond_Always);
|
||||||
@ -3405,7 +3405,6 @@ static ImGuiViewportP* FindViewportHoveredFromPlatformWindowStack(const ImVec2 m
|
|||||||
static void TranslateWindow(ImGuiWindow* window, const ImVec2& delta)
|
static void TranslateWindow(ImGuiWindow* window, const ImVec2& delta)
|
||||||
{
|
{
|
||||||
window->Pos += delta;
|
window->Pos += delta;
|
||||||
window->PosFloat += delta;
|
|
||||||
window->ClipRect.Translate(delta);
|
window->ClipRect.Translate(delta);
|
||||||
window->WindowRectClipped.Translate(delta);
|
window->WindowRectClipped.Translate(delta);
|
||||||
window->InnerRect.Translate(delta);
|
window->InnerRect.Translate(delta);
|
||||||
@ -3954,7 +3953,6 @@ void ImGui::NewFrame()
|
|||||||
|
|
||||||
const ImVec2 offset = window->Size * (1.0f - scale) * (g.IO.MousePos - window->Pos) / window->Size;
|
const ImVec2 offset = window->Size * (1.0f - scale) * (g.IO.MousePos - window->Pos) / window->Size;
|
||||||
window->Pos += offset;
|
window->Pos += offset;
|
||||||
window->PosFloat += offset;
|
|
||||||
window->Size *= scale;
|
window->Size *= scale;
|
||||||
window->SizeFull *= scale;
|
window->SizeFull *= scale;
|
||||||
}
|
}
|
||||||
@ -5804,9 +5802,10 @@ static void CheckStacksSize(ImGuiWindow* window, bool write)
|
|||||||
{ int current = window->IDStack.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup == current && "PushID/PopID or TreeNode/TreePop Mismatch!"); p_backup++; } // Too few or too many PopID()/TreePop()
|
{ int current = window->IDStack.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup == current && "PushID/PopID or TreeNode/TreePop Mismatch!"); p_backup++; } // Too few or too many PopID()/TreePop()
|
||||||
{ int current = window->DC.GroupStack.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup == current && "BeginGroup/EndGroup Mismatch!"); p_backup++; } // Too few or too many EndGroup()
|
{ int current = window->DC.GroupStack.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup == current && "BeginGroup/EndGroup Mismatch!"); p_backup++; } // Too few or too many EndGroup()
|
||||||
{ int current = g.CurrentPopupStack.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup == current && "BeginMenu/EndMenu or BeginPopup/EndPopup Mismatch"); p_backup++;}// Too few or too many EndMenu()/EndPopup()
|
{ int current = g.CurrentPopupStack.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup == current && "BeginMenu/EndMenu or BeginPopup/EndPopup Mismatch"); p_backup++;}// Too few or too many EndMenu()/EndPopup()
|
||||||
{ int current = g.ColorModifiers.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup == current && "PushStyleColor/PopStyleColor Mismatch!"); p_backup++; } // Too few or too many PopStyleColor()
|
// For color, style and font stacks there is an incentive to use Push/Begin/Pop/.../End patterns, so we relax our checks a little to allow them.
|
||||||
{ int current = g.StyleModifiers.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup == current && "PushStyleVar/PopStyleVar Mismatch!"); p_backup++; } // Too few or too many PopStyleVar()
|
{ int current = g.ColorModifiers.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup >= current && "PushStyleColor/PopStyleColor Mismatch!"); p_backup++; } // Too few or too many PopStyleColor()
|
||||||
{ int current = g.FontStack.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup == current && "PushFont/PopFont Mismatch!"); p_backup++; } // Too few or too many PopFont()
|
{ int current = g.StyleModifiers.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup >= current && "PushStyleVar/PopStyleVar Mismatch!"); p_backup++; } // Too few or too many PopStyleVar()
|
||||||
|
{ int current = g.FontStack.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup >= current && "PushFont/PopFont Mismatch!"); p_backup++; } // Too few or too many PopFont()
|
||||||
IM_ASSERT(p_backup == window->DC.StackSizesBackup + IM_ARRAYSIZE(window->DC.StackSizesBackup));
|
IM_ASSERT(p_backup == window->DC.StackSizesBackup + IM_ARRAYSIZE(window->DC.StackSizesBackup));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5910,13 +5909,13 @@ static ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window)
|
|||||||
r_avoid = ImRect(-FLT_MAX, parent_window->Pos.y + parent_window->TitleBarHeight(), FLT_MAX, parent_window->Pos.y + parent_window->TitleBarHeight() + parent_window->MenuBarHeight());
|
r_avoid = ImRect(-FLT_MAX, parent_window->Pos.y + parent_window->TitleBarHeight(), FLT_MAX, parent_window->Pos.y + parent_window->TitleBarHeight() + parent_window->MenuBarHeight());
|
||||||
else
|
else
|
||||||
r_avoid = ImRect(parent_window->Pos.x + horizontal_overlap, -FLT_MAX, parent_window->Pos.x + parent_window->Size.x - horizontal_overlap - parent_window->ScrollbarSizes.x, FLT_MAX);
|
r_avoid = ImRect(parent_window->Pos.x + horizontal_overlap, -FLT_MAX, parent_window->Pos.x + parent_window->Size.x - horizontal_overlap - parent_window->ScrollbarSizes.x, FLT_MAX);
|
||||||
return FindBestWindowPosForPopupEx(window->PosFloat, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
|
return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
|
||||||
}
|
}
|
||||||
if (window->Flags & ImGuiWindowFlags_Popup)
|
if (window->Flags & ImGuiWindowFlags_Popup)
|
||||||
{
|
{
|
||||||
ImRect r_outer = FindAllowedExtentRectForWindow(window);
|
ImRect r_outer = FindAllowedExtentRectForWindow(window);
|
||||||
ImRect r_avoid = ImRect(window->PosFloat.x - 1, window->PosFloat.y - 1, window->PosFloat.x + 1, window->PosFloat.y + 1);
|
ImRect r_avoid = ImRect(window->Pos.x - 1, window->Pos.y - 1, window->Pos.x + 1, window->Pos.y + 1);
|
||||||
return FindBestWindowPosForPopupEx(window->PosFloat, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
|
return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
|
||||||
}
|
}
|
||||||
if (window->Flags & ImGuiWindowFlags_Tooltip)
|
if (window->Flags & ImGuiWindowFlags_Tooltip)
|
||||||
{
|
{
|
||||||
@ -5935,7 +5934,7 @@ static ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window)
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
IM_ASSERT(0);
|
IM_ASSERT(0);
|
||||||
return window->PosFloat;
|
return window->Pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetWindowConditionAllowFlags(ImGuiWindow* window, ImGuiCond flags, bool enabled)
|
static void SetWindowConditionAllowFlags(ImGuiWindow* window, ImGuiCond flags, bool enabled)
|
||||||
@ -5961,13 +5960,16 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
|
|||||||
window->Flags = flags;
|
window->Flags = flags;
|
||||||
g.WindowsById.SetVoidPtr(window->ID, window);
|
g.WindowsById.SetVoidPtr(window->ID, window);
|
||||||
|
|
||||||
|
// Default/arbitrary window position. Use SetNextWindowPos() with the appropriate condition flag to change the initial position of a window.
|
||||||
|
window->Pos = ImVec2(60, 60);
|
||||||
|
|
||||||
// User can disable loading and saving of settings. Tooltip and child windows also don't store settings.
|
// User can disable loading and saving of settings. Tooltip and child windows also don't store settings.
|
||||||
if (!(flags & ImGuiWindowFlags_NoSavedSettings))
|
if (!(flags & ImGuiWindowFlags_NoSavedSettings))
|
||||||
{
|
{
|
||||||
// Retrieve settings from .ini file
|
// Retrieve settings from .ini file
|
||||||
// Use SetWindowPos() or SetNextWindowPos() with the appropriate condition flag to change the initial position of a window.
|
// Use SetWindowPos() or SetNextWindowPos() with the appropriate condition flag to change the initial position of a window.
|
||||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
window->Pos = window->PosFloat = main_viewport->Pos + ImVec2(60, 60);
|
window->Pos = main_viewport->Pos + ImVec2(60, 60);
|
||||||
|
|
||||||
if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID))
|
if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID))
|
||||||
{
|
{
|
||||||
@ -5981,10 +5983,10 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
|
|||||||
{
|
{
|
||||||
window->ViewportPos = main_viewport->Pos;
|
window->ViewportPos = main_viewport->Pos;
|
||||||
}
|
}
|
||||||
window->Pos = window->PosFloat = ImFloor(settings->Pos + window->ViewportPos);
|
window->Pos = ImFloor(settings->Pos + window->ViewportPos);
|
||||||
window->Collapsed = settings->Collapsed;
|
window->Collapsed = settings->Collapsed;
|
||||||
if (ImLengthSqr(settings->Size) > 0.00001f)
|
if (ImLengthSqr(settings->Size) > 0.00001f)
|
||||||
size = settings->Size;
|
size = ImFloor(settings->Size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window->Size = window->SizeFull = window->SizeFullAtLastBegin = size;
|
window->Size = window->SizeFull = window->SizeFullAtLastBegin = size;
|
||||||
@ -6316,7 +6318,8 @@ static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
|
|||||||
|
|
||||||
// Using the FlattenChilds button flag we make the resize button accessible even if we are hovering over a child window
|
// Using the FlattenChilds button flag we make the resize button accessible even if we are hovering over a child window
|
||||||
ImRect resize_rect(corner, corner + grip.InnerDir * grip_hover_size);
|
ImRect resize_rect(corner, corner + grip.InnerDir * grip_hover_size);
|
||||||
resize_rect.FixInverted();
|
if (resize_rect.Min.x > resize_rect.Max.x) ImSwap(resize_rect.Min.x, resize_rect.Max.x);
|
||||||
|
if (resize_rect.Min.y > resize_rect.Max.y) ImSwap(resize_rect.Min.y, resize_rect.Max.y);
|
||||||
bool hovered, held;
|
bool hovered, held;
|
||||||
ButtonBehavior(resize_rect, window->GetID((void*)(intptr_t)resize_grip_n), &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus);
|
ButtonBehavior(resize_rect, window->GetID((void*)(intptr_t)resize_grip_n), &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus);
|
||||||
if (hovered || held)
|
if (hovered || held)
|
||||||
@ -6395,7 +6398,7 @@ static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
|
|||||||
}
|
}
|
||||||
if (pos_target.x != FLT_MAX)
|
if (pos_target.x != FLT_MAX)
|
||||||
{
|
{
|
||||||
window->Pos = window->PosFloat = ImFloor(pos_target);
|
window->Pos = ImFloor(pos_target);
|
||||||
MarkIniSettingsDirty(window);
|
MarkIniSettingsDirty(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6404,7 +6407,7 @@ static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
|
|||||||
|
|
||||||
static inline void ClampWindowRect(ImGuiWindow* window, const ImRect& rect, const ImVec2& padding)
|
static inline void ClampWindowRect(ImGuiWindow* window, const ImRect& rect, const ImVec2& padding)
|
||||||
{
|
{
|
||||||
window->PosFloat = ImMin(rect.Max - padding, ImMax(window->PosFloat + window->Size, rect.Min + padding) - window->Size);
|
window->Pos = ImMin(rect.Max - padding, ImMax(window->Pos + window->Size, rect.Min + padding) - window->Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push a new ImGui window to add widgets to.
|
// Push a new ImGui window to add widgets to.
|
||||||
@ -6669,7 +6672,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
{
|
{
|
||||||
window->AutoPosLastDirection = ImGuiDir_None;
|
window->AutoPosLastDirection = ImGuiDir_None;
|
||||||
if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api)
|
if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api)
|
||||||
window->Pos = window->PosFloat = g.CurrentPopupStack.back().OpenPopupPos;
|
window->Pos = g.CurrentPopupStack.back().OpenPopupPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Position child window
|
// Position child window
|
||||||
@ -6678,27 +6681,27 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
window->BeginOrderWithinParent = parent_window->DC.ChildWindows.Size;
|
window->BeginOrderWithinParent = parent_window->DC.ChildWindows.Size;
|
||||||
parent_window->DC.ChildWindows.push_back(window);
|
parent_window->DC.ChildWindows.push_back(window);
|
||||||
if (!(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api && !window_is_child_tooltip)
|
if (!(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api && !window_is_child_tooltip)
|
||||||
window->Pos = window->PosFloat = parent_window->DC.CursorPos;
|
window->Pos = parent_window->DC.CursorPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool window_pos_with_pivot = (window->SetWindowPosVal.x != FLT_MAX && window->HiddenFrames == 0);
|
const bool window_pos_with_pivot = (window->SetWindowPosVal.x != FLT_MAX && window->HiddenFrames == 0);
|
||||||
if (window_pos_with_pivot)
|
if (window_pos_with_pivot)
|
||||||
SetWindowPos(window, ImMax(style.DisplaySafeAreaPadding, window->SetWindowPosVal - window->SizeFull * window->SetWindowPosPivot), 0); // Position given a pivot (e.g. for centering)
|
SetWindowPos(window, ImMax(style.DisplaySafeAreaPadding, window->SetWindowPosVal - window->SizeFull * window->SetWindowPosPivot), 0); // Position given a pivot (e.g. for centering)
|
||||||
else if ((flags & ImGuiWindowFlags_ChildMenu) != 0)
|
else if ((flags & ImGuiWindowFlags_ChildMenu) != 0)
|
||||||
window->PosFloat = FindBestWindowPosForPopup(window);
|
window->Pos = FindBestWindowPosForPopup(window);
|
||||||
else if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api && window_just_appearing_after_hidden_for_resize)
|
else if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api && window_just_appearing_after_hidden_for_resize)
|
||||||
window->PosFloat = FindBestWindowPosForPopup(window);
|
window->Pos = FindBestWindowPosForPopup(window);
|
||||||
else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip)
|
else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip)
|
||||||
window->PosFloat = FindBestWindowPosForPopup(window);
|
window->Pos = FindBestWindowPosForPopup(window);
|
||||||
|
|
||||||
if (window->ViewportAllowPlatformMonitorExtend >= 0 && !window->ViewportOwned)
|
if (window->ViewportAllowPlatformMonitorExtend >= 0 && !window->ViewportOwned)
|
||||||
{
|
{
|
||||||
if (!window->Viewport->GetRect().Contains(ImRect(window->PosFloat, window->PosFloat + window->Size)))
|
if (!window->Viewport->GetRect().Contains(window->Rect()))
|
||||||
{
|
{
|
||||||
// Late create viewport, based on the assumption that with our calculations, the DPI will be known ahead (same as the DPI of the selection done in UpdateSelectWindowViewport)
|
// Late create viewport, based on the assumption that with our calculations, the DPI will be known ahead (same as the DPI of the selection done in UpdateSelectWindowViewport)
|
||||||
//ImGuiViewport* old_viewport = window->Viewport;
|
//ImGuiViewport* old_viewport = window->Viewport;
|
||||||
ImGuiViewportFlags viewport_flags = ImGuiViewportFlags_NoDecoration | ImGuiViewportFlags_NoFocusOnAppearing | ((window->Flags & ImGuiWindowFlags_NoInputs) ? ImGuiViewportFlags_NoInputs : 0);
|
ImGuiViewportFlags viewport_flags = ImGuiViewportFlags_NoDecoration | ImGuiViewportFlags_NoFocusOnAppearing | ((window->Flags & ImGuiWindowFlags_NoInputs) ? ImGuiViewportFlags_NoInputs : 0);
|
||||||
window->Viewport = AddUpdateViewport(window, window->ID, window->PosFloat, window->Size, viewport_flags);
|
window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, viewport_flags);
|
||||||
|
|
||||||
// FIXME-DPI
|
// FIXME-DPI
|
||||||
//IM_ASSERT(old_viewport->DpiScale == window->Viewport->DpiScale); // FIXME-DPI: Something went wrong
|
//IM_ASSERT(old_viewport->DpiScale == window->Viewport->DpiScale); // FIXME-DPI: Something went wrong
|
||||||
@ -6712,7 +6715,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
{
|
{
|
||||||
// Synchronize viewport --> window
|
// Synchronize viewport --> window
|
||||||
if (window->Viewport->PlatformRequestMove)
|
if (window->Viewport->PlatformRequestMove)
|
||||||
window->PosFloat = window->Viewport->Pos;
|
window->Pos = window->Viewport->Pos;
|
||||||
if (window->Viewport->PlatformRequestResize)
|
if (window->Viewport->PlatformRequestResize)
|
||||||
window->Size = window->SizeFull = window->Viewport->Size;
|
window->Size = window->SizeFull = window->Viewport->Size;
|
||||||
|
|
||||||
@ -6734,7 +6737,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
if (window->Viewport->PlatformMonitor == -1)
|
if (window->Viewport->PlatformMonitor == -1)
|
||||||
{
|
{
|
||||||
// Fallback for "lost" window (e.g. a monitor disconnected): we move the window back over the main viewport
|
// Fallback for "lost" window (e.g. a monitor disconnected): we move the window back over the main viewport
|
||||||
window->PosFloat = g.Viewports[0]->Pos + style.DisplayWindowPadding;
|
SetWindowPos(window, g.Viewports[0]->Pos + style.DisplayWindowPadding, ImGuiCond_Always);
|
||||||
window->ViewportTryMerge = true;
|
window->ViewportTryMerge = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -6744,7 +6747,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window->Pos = ImFloor(window->PosFloat);
|
window->Pos = ImFloor(window->Pos);
|
||||||
|
|
||||||
// Lock window rounding for the frame (so that altering them doesn't cause inconsistencies)
|
// Lock window rounding for the frame (so that altering them doesn't cause inconsistencies)
|
||||||
window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding : style.WindowRounding;
|
window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding : style.WindowRounding;
|
||||||
@ -6782,7 +6785,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
if (window->ViewportOwned)
|
if (window->ViewportOwned)
|
||||||
{
|
{
|
||||||
if (!window->Viewport->PlatformRequestMove)
|
if (!window->Viewport->PlatformRequestMove)
|
||||||
window->Viewport->Pos = window->PosFloat;
|
window->Viewport->Pos = window->Pos;
|
||||||
if (!window->Viewport->PlatformRequestResize)
|
if (!window->Viewport->PlatformRequestResize)
|
||||||
window->Viewport->Size = window->Size;
|
window->Viewport->Size = window->Size;
|
||||||
viewport_rect = window->Viewport->GetRect();
|
viewport_rect = window->Viewport->GetRect();
|
||||||
@ -7752,7 +7755,6 @@ static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond)
|
|||||||
|
|
||||||
// Set
|
// Set
|
||||||
const ImVec2 old_pos = window->Pos;
|
const ImVec2 old_pos = window->Pos;
|
||||||
window->PosFloat = pos;
|
|
||||||
window->Pos = ImFloor(pos);
|
window->Pos = ImFloor(pos);
|
||||||
window->DC.CursorPos += (window->Pos - old_pos); // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor
|
window->DC.CursorPos += (window->Pos - old_pos); // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor
|
||||||
window->DC.CursorMaxPos += (window->Pos - old_pos); // And more importantly we need to adjust this so size calculation doesn't get affected.
|
window->DC.CursorMaxPos += (window->Pos - old_pos); // And more importantly we need to adjust this so size calculation doesn't get affected.
|
||||||
@ -8856,7 +8858,7 @@ bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags)
|
|||||||
if (flags & ImGuiTreeNodeFlags_Leaf)
|
if (flags & ImGuiTreeNodeFlags_Leaf)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// We only write to the tree storage if the user clicks (or explicitely use SetNextTreeNode*** functions)
|
// We only write to the tree storage if the user clicks (or explicitly use SetNextTreeNode*** functions)
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = g.CurrentWindow;
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
ImGuiStorage* storage = window->DC.StateStorage;
|
ImGuiStorage* storage = window->DC.StateStorage;
|
||||||
@ -10921,15 +10923,15 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
|||||||
const float mouse_x = (io.MousePos.x - frame_bb.Min.x - style.FramePadding.x) + edit_state.ScrollX;
|
const float mouse_x = (io.MousePos.x - frame_bb.Min.x - style.FramePadding.x) + edit_state.ScrollX;
|
||||||
const float mouse_y = (is_multiline ? (io.MousePos.y - draw_window->DC.CursorPos.y - style.FramePadding.y) : (g.FontSize*0.5f));
|
const float mouse_y = (is_multiline ? (io.MousePos.y - draw_window->DC.CursorPos.y - style.FramePadding.y) : (g.FontSize*0.5f));
|
||||||
|
|
||||||
const bool osx_double_click_selects_words = io.OptMacOSXBehaviors; // OS X style: Double click selects by word instead of selecting whole text
|
const bool is_osx = io.OptMacOSXBehaviors;
|
||||||
if (select_all || (hovered && !osx_double_click_selects_words && io.MouseDoubleClicked[0]))
|
if (select_all || (hovered && !is_osx && io.MouseDoubleClicked[0]))
|
||||||
{
|
{
|
||||||
edit_state.SelectAll();
|
edit_state.SelectAll();
|
||||||
edit_state.SelectedAllMouseLock = true;
|
edit_state.SelectedAllMouseLock = true;
|
||||||
}
|
}
|
||||||
else if (hovered && osx_double_click_selects_words && io.MouseDoubleClicked[0])
|
else if (hovered && is_osx && io.MouseDoubleClicked[0])
|
||||||
{
|
{
|
||||||
// Select a word only, OS X style (by simulating keystrokes)
|
// Double-click select a word only, OS X style (by simulating keystrokes)
|
||||||
edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT);
|
edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT);
|
||||||
edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT);
|
edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT);
|
||||||
}
|
}
|
||||||
@ -10954,7 +10956,8 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
|||||||
{
|
{
|
||||||
// Process text input (before we check for Return because using some IME will effectively send a Return?)
|
// Process text input (before we check for Return because using some IME will effectively send a Return?)
|
||||||
// We ignore CTRL inputs, but need to allow ALT+CTRL as some keyboards (e.g. German) use AltGR (which _is_ Alt+Ctrl) to input certain characters.
|
// We ignore CTRL inputs, but need to allow ALT+CTRL as some keyboards (e.g. German) use AltGR (which _is_ Alt+Ctrl) to input certain characters.
|
||||||
if (!(io.KeyCtrl && !io.KeyAlt) && is_editable && !user_nav_input_start)
|
bool ignore_inputs = (io.KeyCtrl && !io.KeyAlt) || (is_osx && io.KeySuper);
|
||||||
|
if (!ignore_inputs && is_editable && !user_nav_input_start)
|
||||||
for (int n = 0; n < IM_ARRAYSIZE(io.InputCharacters) && io.InputCharacters[n]; n++)
|
for (int n = 0; n < IM_ARRAYSIZE(io.InputCharacters) && io.InputCharacters[n]; n++)
|
||||||
{
|
{
|
||||||
// Insert character if they pass filtering
|
// Insert character if they pass filtering
|
||||||
@ -10973,15 +10976,19 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
|||||||
{
|
{
|
||||||
// Handle key-presses
|
// Handle key-presses
|
||||||
const int k_mask = (io.KeyShift ? STB_TEXTEDIT_K_SHIFT : 0);
|
const int k_mask = (io.KeyShift ? STB_TEXTEDIT_K_SHIFT : 0);
|
||||||
const bool is_shortcut_key_only = (io.OptMacOSXBehaviors ? (io.KeySuper && !io.KeyCtrl) : (io.KeyCtrl && !io.KeySuper)) && !io.KeyAlt && !io.KeyShift; // OS X style: Shortcuts using Cmd/Super instead of Ctrl
|
const bool is_osx = io.OptMacOSXBehaviors;
|
||||||
const bool is_wordmove_key_down = io.OptMacOSXBehaviors ? io.KeyAlt : io.KeyCtrl; // OS X style: Text editing cursor movement using Alt instead of Ctrl
|
const bool is_shortcut_key = (is_osx ? (io.KeySuper && !io.KeyCtrl) : (io.KeyCtrl && !io.KeySuper)) && !io.KeyAlt && !io.KeyShift; // OS X style: Shortcuts using Cmd/Super instead of Ctrl
|
||||||
const bool is_startend_key_down = io.OptMacOSXBehaviors && io.KeySuper && !io.KeyCtrl && !io.KeyAlt; // OS X style: Line/Text Start and End using Cmd+Arrows instead of Home/End
|
const bool is_osx_shift_shortcut = is_osx && io.KeySuper && io.KeyShift && !io.KeyCtrl && !io.KeyAlt;
|
||||||
|
const bool is_wordmove_key_down = is_osx ? io.KeyAlt : io.KeyCtrl; // OS X style: Text editing cursor movement using Alt instead of Ctrl
|
||||||
|
const bool is_startend_key_down = is_osx && io.KeySuper && !io.KeyCtrl && !io.KeyAlt; // OS X style: Line/Text Start and End using Cmd+Arrows instead of Home/End
|
||||||
const bool is_ctrl_key_only = io.KeyCtrl && !io.KeyShift && !io.KeyAlt && !io.KeySuper;
|
const bool is_ctrl_key_only = io.KeyCtrl && !io.KeyShift && !io.KeyAlt && !io.KeySuper;
|
||||||
const bool is_shift_key_only = io.KeyShift && !io.KeyCtrl && !io.KeyAlt && !io.KeySuper;
|
const bool is_shift_key_only = io.KeyShift && !io.KeyCtrl && !io.KeyAlt && !io.KeySuper;
|
||||||
|
|
||||||
const bool is_cut = ((is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_X)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Delete))) && is_editable && !is_password && (!is_multiline || edit_state.HasSelection());
|
const bool is_cut = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_X)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Delete))) && is_editable && !is_password && (!is_multiline || edit_state.HasSelection());
|
||||||
const bool is_copy = ((is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_C)) || (is_ctrl_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && !is_password && (!is_multiline || edit_state.HasSelection());
|
const bool is_copy = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_C)) || (is_ctrl_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && !is_password && (!is_multiline || edit_state.HasSelection());
|
||||||
const bool is_paste = ((is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_V)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && is_editable;
|
const bool is_paste = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_V)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && is_editable;
|
||||||
|
const bool is_undo = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_Z)) && is_editable && is_undoable);
|
||||||
|
const bool is_redo = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_Y)) || (is_osx_shift_shortcut && IsKeyPressedMap(ImGuiKey_Z))) && is_editable && is_undoable;
|
||||||
|
|
||||||
if (IsKeyPressedMap(ImGuiKey_LeftArrow)) { edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINESTART : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDLEFT : STB_TEXTEDIT_K_LEFT) | k_mask); }
|
if (IsKeyPressedMap(ImGuiKey_LeftArrow)) { edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINESTART : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDLEFT : STB_TEXTEDIT_K_LEFT) | k_mask); }
|
||||||
else if (IsKeyPressedMap(ImGuiKey_RightArrow)) { edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINEEND : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDRIGHT : STB_TEXTEDIT_K_RIGHT) | k_mask); }
|
else if (IsKeyPressedMap(ImGuiKey_RightArrow)) { edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINEEND : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDRIGHT : STB_TEXTEDIT_K_RIGHT) | k_mask); }
|
||||||
@ -10995,7 +11002,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
|||||||
if (!edit_state.HasSelection())
|
if (!edit_state.HasSelection())
|
||||||
{
|
{
|
||||||
if (is_wordmove_key_down) edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT|STB_TEXTEDIT_K_SHIFT);
|
if (is_wordmove_key_down) edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT|STB_TEXTEDIT_K_SHIFT);
|
||||||
else if (io.OptMacOSXBehaviors && io.KeySuper && !io.KeyAlt && !io.KeyCtrl) edit_state.OnKeyPressed(STB_TEXTEDIT_K_LINESTART|STB_TEXTEDIT_K_SHIFT);
|
else if (is_osx && io.KeySuper && !io.KeyAlt && !io.KeyCtrl) edit_state.OnKeyPressed(STB_TEXTEDIT_K_LINESTART|STB_TEXTEDIT_K_SHIFT);
|
||||||
}
|
}
|
||||||
edit_state.OnKeyPressed(STB_TEXTEDIT_K_BACKSPACE | k_mask);
|
edit_state.OnKeyPressed(STB_TEXTEDIT_K_BACKSPACE | k_mask);
|
||||||
}
|
}
|
||||||
@ -11019,10 +11026,20 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
|||||||
if (InputTextFilterCharacter(&c, flags, callback, user_data))
|
if (InputTextFilterCharacter(&c, flags, callback, user_data))
|
||||||
edit_state.OnKeyPressed((int)c);
|
edit_state.OnKeyPressed((int)c);
|
||||||
}
|
}
|
||||||
else if (IsKeyPressedMap(ImGuiKey_Escape)) { clear_active_id = cancel_edit = true; }
|
else if (IsKeyPressedMap(ImGuiKey_Escape))
|
||||||
else if (is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_Z) && is_editable && is_undoable) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_UNDO); edit_state.ClearSelection(); }
|
{
|
||||||
else if (is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_Y) && is_editable && is_undoable) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_REDO); edit_state.ClearSelection(); }
|
clear_active_id = cancel_edit = true;
|
||||||
else if (is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_A)) { edit_state.SelectAll(); edit_state.CursorFollow = true; }
|
}
|
||||||
|
else if (is_undo || is_redo)
|
||||||
|
{
|
||||||
|
edit_state.OnKeyPressed(is_undo ? STB_TEXTEDIT_K_UNDO : STB_TEXTEDIT_K_REDO);
|
||||||
|
edit_state.ClearSelection();
|
||||||
|
}
|
||||||
|
else if (is_shortcut_key && IsKeyPressedMap(ImGuiKey_A))
|
||||||
|
{
|
||||||
|
edit_state.SelectAll();
|
||||||
|
edit_state.CursorFollow = true;
|
||||||
|
}
|
||||||
else if (is_cut || is_copy)
|
else if (is_cut || is_copy)
|
||||||
{
|
{
|
||||||
// Cut, Copy
|
// Cut, Copy
|
||||||
@ -11034,7 +11051,6 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
|||||||
ImTextStrToUtf8(edit_state.TempTextBuffer.Data, edit_state.TempTextBuffer.Size, edit_state.Text.Data+ib, edit_state.Text.Data+ie);
|
ImTextStrToUtf8(edit_state.TempTextBuffer.Data, edit_state.TempTextBuffer.Size, edit_state.Text.Data+ib, edit_state.Text.Data+ie);
|
||||||
SetClipboardText(edit_state.TempTextBuffer.Data);
|
SetClipboardText(edit_state.TempTextBuffer.Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_cut)
|
if (is_cut)
|
||||||
{
|
{
|
||||||
if (!edit_state.HasSelection())
|
if (!edit_state.HasSelection())
|
||||||
@ -11045,7 +11061,6 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
|||||||
}
|
}
|
||||||
else if (is_paste)
|
else if (is_paste)
|
||||||
{
|
{
|
||||||
// Paste
|
|
||||||
if (const char* clipboard = GetClipboardText())
|
if (const char* clipboard = GetClipboardText())
|
||||||
{
|
{
|
||||||
// Filter pasted buffer
|
// Filter pasted buffer
|
||||||
@ -13530,7 +13545,7 @@ void ImGui::EndColumns()
|
|||||||
columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y);
|
columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y);
|
||||||
window->DC.CursorPos.y = columns->LineMaxY;
|
window->DC.CursorPos.y = columns->LineMaxY;
|
||||||
if (!(columns->Flags & ImGuiColumnsFlags_GrowParentContentsSize))
|
if (!(columns->Flags & ImGuiColumnsFlags_GrowParentContentsSize))
|
||||||
window->DC.CursorMaxPos.x = ImMax(columns->StartMaxPosX, columns->MaxX); // Restore cursor max pos, as columns don't grow parent
|
window->DC.CursorMaxPos.x = columns->StartMaxPosX; // Restore cursor max pos, as columns don't grow parent
|
||||||
|
|
||||||
// Draw columns borders and handle resize
|
// Draw columns borders and handle resize
|
||||||
bool is_being_resized = false;
|
bool is_being_resized = false;
|
||||||
@ -14047,7 +14062,7 @@ static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
|
|||||||
static void ScaleWindow(ImGuiWindow* window, float scale)
|
static void ScaleWindow(ImGuiWindow* window, float scale)
|
||||||
{
|
{
|
||||||
ImVec2 origin = window->Viewport->Pos;
|
ImVec2 origin = window->Viewport->Pos;
|
||||||
window->Pos = window->PosFloat = ImFloor((window->PosFloat - origin) * scale + origin);
|
window->Pos = ImFloor((window->Pos - origin) * scale + origin);
|
||||||
window->Size = ImFloor(window->Size * scale);
|
window->Size = ImFloor(window->Size * scale);
|
||||||
window->SizeFull = ImFloor(window->SizeFull * scale);
|
window->SizeFull = ImFloor(window->SizeFull * scale);
|
||||||
window->SizeContents = ImFloor(window->SizeContents * scale);
|
window->SizeContents = ImFloor(window->SizeContents * scale);
|
||||||
@ -14231,13 +14246,14 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
ImGui::BulletText("Active: %d, WriteAccessed: %d, BeginOrderWithinContext: %d", window->Active, window->WriteAccessed, (window->Active || window->WasActive) ? window->BeginOrderWithinContext : -1);
|
ImGui::BulletText("Active: %d, WriteAccessed: %d, BeginOrderWithinContext: %d", window->Active, window->WriteAccessed, (window->Active || window->WasActive) ? window->BeginOrderWithinContext : -1);
|
||||||
ImGui::BulletText("NavLastIds: 0x%08X,0x%08X, NavLayerActiveMask: %X", window->NavLastIds[0], window->NavLastIds[1], window->DC.NavLayerActiveMask);
|
ImGui::BulletText("NavLastIds: 0x%08X,0x%08X, NavLayerActiveMask: %X", window->NavLastIds[0], window->NavLastIds[1], window->DC.NavLayerActiveMask);
|
||||||
ImGui::BulletText("NavLastChildNavWindow: %s", window->NavLastChildNavWindow ? window->NavLastChildNavWindow->Name : "NULL");
|
ImGui::BulletText("NavLastChildNavWindow: %s", window->NavLastChildNavWindow ? window->NavLastChildNavWindow->Name : "NULL");
|
||||||
if (window->NavRectRel[0].IsInverted())
|
if (!window->NavRectRel[0].IsInverted())
|
||||||
ImGui::BulletText("NavRectRel[0]: (%.1f,%.1f)(%.1f,%.1f)", window->NavRectRel[0].Min.x, window->NavRectRel[0].Min.y, window->NavRectRel[0].Max.x, window->NavRectRel[0].Max.y);
|
ImGui::BulletText("NavRectRel[0]: (%.1f,%.1f)(%.1f,%.1f)", window->NavRectRel[0].Min.x, window->NavRectRel[0].Min.y, window->NavRectRel[0].Max.x, window->NavRectRel[0].Max.y);
|
||||||
else
|
else
|
||||||
ImGui::BulletText("NavRectRel[0]: <None>");
|
ImGui::BulletText("NavRectRel[0]: <None>");
|
||||||
ImGui::BulletText("Viewport: %d, ViewportId: 0x%08X, ViewportPos: (%.1f,%.1f)", window->Viewport ? window->Viewport->Idx : -1, window->ViewportId, window->ViewportPos.x, window->ViewportPos.y);
|
ImGui::BulletText("Viewport: %d, ViewportId: 0x%08X, ViewportPos: (%.1f,%.1f)", window->Viewport ? window->Viewport->Idx : -1, window->ViewportId, window->ViewportPos.x, window->ViewportPos.y);
|
||||||
ImGui::BulletText("ViewportMonitor: %d", window->Viewport->PlatformMonitor);
|
ImGui::BulletText("ViewportMonitor: %d", window->Viewport->PlatformMonitor);
|
||||||
if (window->RootWindow != window) NodeWindow(window->RootWindow, "RootWindow");
|
if (window->RootWindow != window) NodeWindow(window->RootWindow, "RootWindow");
|
||||||
|
if (window->ParentWindow != NULL) NodeWindow(window->ParentWindow, "ParentWindow");
|
||||||
if (window->DC.ChildWindows.Size > 0) NodeWindows(window->DC.ChildWindows, "ChildWindows");
|
if (window->DC.ChildWindows.Size > 0) NodeWindows(window->DC.ChildWindows, "ChildWindows");
|
||||||
if (window->ColumnsStorage.Size > 0 && ImGui::TreeNode("Columns", "Columns sets (%d)", window->ColumnsStorage.Size))
|
if (window->ColumnsStorage.Size > 0 && ImGui::TreeNode("Columns", "Columns sets (%d)", window->ColumnsStorage.Size))
|
||||||
{
|
{
|
||||||
@ -14265,7 +14281,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
{
|
{
|
||||||
ImGuiWindowFlags flags = viewport->Flags;
|
ImGuiWindowFlags flags = viewport->Flags;
|
||||||
ImGui::BulletText("Pos: (%.0f,%.0f), Monitor: %d", viewport->Pos.x, viewport->Pos.y, viewport->PlatformMonitor);
|
ImGui::BulletText("Pos: (%.0f,%.0f), Monitor: %d", viewport->Pos.x, viewport->Pos.y, viewport->PlatformMonitor);
|
||||||
if (viewport->Idx > 0) { ImGui::SameLine(); if (ImGui::SmallButton("Reset")) { viewport->Pos = ImVec2(200,200); if (viewport->Window) viewport->Window->Pos = viewport->Window->PosFloat = ImVec2(200,200); } }
|
if (viewport->Idx > 0) { ImGui::SameLine(); if (ImGui::SmallButton("Reset")) { viewport->Pos = ImVec2(200,200); if (viewport->Window) viewport->Window->Pos = ImVec2(200,200); } }
|
||||||
ImGui::BulletText("Size: (%0.f,%.0f), DpiScale: %.0f%%", viewport->Size.x, viewport->Size.y, viewport->DpiScale * 100.0f);
|
ImGui::BulletText("Size: (%0.f,%.0f), DpiScale: %.0f%%", viewport->Size.x, viewport->Size.y, viewport->DpiScale * 100.0f);
|
||||||
ImGui::BulletText("Flags: 0x%04X =%s%s%s%s%s", viewport->Flags,
|
ImGui::BulletText("Flags: 0x%04X =%s%s%s%s%s", viewport->Flags,
|
||||||
(flags & ImGuiViewportFlags_CanHostOtherWindows) ? " CanHostOtherWindows" : "", (flags & ImGuiViewportFlags_NoDecoration) ? " NoDecoration" : "",
|
(flags & ImGuiViewportFlags_CanHostOtherWindows) ? " CanHostOtherWindows" : "", (flags & ImGuiViewportFlags_NoDecoration) ? " NoDecoration" : "",
|
||||||
@ -14343,8 +14359,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
ImFormatString(buf, IM_ARRAYSIZE(buf), "%d", window->BeginOrderWithinContext);
|
ImFormatString(buf, IM_ARRAYSIZE(buf), "%d", window->BeginOrderWithinContext);
|
||||||
float font_size = ImGui::GetFontSize() * 2;
|
float font_size = ImGui::GetFontSize() * 2;
|
||||||
ImDrawList* overlay_draw_list = GetOverlayDrawList(window->Viewport);
|
ImDrawList* overlay_draw_list = GetOverlayDrawList(window->Viewport);
|
||||||
overlay_draw_list->AddRectFilled(window->PosFloat, window->PosFloat + ImVec2(font_size, font_size), IM_COL32(200, 100, 100, 255));
|
overlay_draw_list->AddRectFilled(window->Pos, window->Pos + ImVec2(font_size, font_size), IM_COL32(200, 100, 100, 255));
|
||||||
overlay_draw_list->AddText(NULL, font_size, window->PosFloat, IM_COL32(255, 255, 255, 255), buf);
|
overlay_draw_list->AddText(NULL, font_size, window->Pos, IM_COL32(255, 255, 255, 255), buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
imgui.h
2
imgui.h
@ -235,7 +235,7 @@ namespace ImGui
|
|||||||
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val);
|
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val);
|
||||||
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val);
|
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val);
|
||||||
IMGUI_API void PopStyleVar(int count = 1);
|
IMGUI_API void PopStyleVar(int count = 1);
|
||||||
IMGUI_API const ImVec4& GetStyleColorVec4(ImGuiCol idx); // retrieve style color as stored in ImGuiStyle structure. use to feed back into PushStyleColor(), otherwhise use GetColorU32() to get style color with style alpha baked in.
|
IMGUI_API const ImVec4& GetStyleColorVec4(ImGuiCol idx); // retrieve style color as stored in ImGuiStyle structure. use to feed back into PushStyleColor(), otherwise use GetColorU32() to get style color with style alpha baked in.
|
||||||
IMGUI_API ImFont* GetFont(); // get current font
|
IMGUI_API ImFont* GetFont(); // get current font
|
||||||
IMGUI_API float GetFontSize(); // get current font size (= height in pixels) of current font with current scale applied
|
IMGUI_API float GetFontSize(); // get current font size (= height in pixels) of current font with current scale applied
|
||||||
IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API
|
IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API
|
||||||
|
@ -2480,15 +2480,20 @@ static void ShowExampleAppFixedOverlay(bool* p_open)
|
|||||||
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||||
ImVec2 window_pos = ImVec2((corner & 1) ? (viewport->Pos.x + viewport->Size.x - DISTANCE) : (viewport->Pos.x + DISTANCE), (corner & 2) ? (viewport->Pos.y + viewport->Size.y - DISTANCE) : (viewport->Pos.y + DISTANCE));
|
ImVec2 window_pos = ImVec2((corner & 1) ? (viewport->Pos.x + viewport->Size.x - DISTANCE) : (viewport->Pos.x + DISTANCE), (corner & 2) ? (viewport->Pos.y + viewport->Size.y - DISTANCE) : (viewport->Pos.y + DISTANCE));
|
||||||
ImVec2 window_pos_pivot = ImVec2((corner & 1) ? 1.0f : 0.0f, (corner & 2) ? 1.0f : 0.0f);
|
ImVec2 window_pos_pivot = ImVec2((corner & 1) ? 1.0f : 0.0f, (corner & 2) ? 1.0f : 0.0f);
|
||||||
|
if (corner != -1)
|
||||||
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
|
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
|
||||||
ImGui::SetNextWindowBgAlpha(0.3f); // Transparent background
|
ImGui::SetNextWindowBgAlpha(0.3f); // Transparent background
|
||||||
if (ImGui::Begin("Example: Fixed Overlay", p_open, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_NoFocusOnAppearing|ImGuiWindowFlags_NoNav))
|
if (ImGui::Begin("Example: Fixed Overlay", p_open, (corner != -1 ? ImGuiWindowFlags_NoMove : 0) | ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_NoFocusOnAppearing|ImGuiWindowFlags_NoNav))
|
||||||
{
|
{
|
||||||
ImGui::Text("Simple overlay\nin the corner of the screen.\n(right-click to change position)");
|
ImGui::Text("Simple overlay\n" "in the corner of the screen.\n" "(right-click to change position)");
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
if (ImGui::IsMousePosValid())
|
||||||
ImGui::Text("Mouse Position: (%.1f,%.1f)", ImGui::GetIO().MousePos.x, ImGui::GetIO().MousePos.y);
|
ImGui::Text("Mouse Position: (%.1f,%.1f)", ImGui::GetIO().MousePos.x, ImGui::GetIO().MousePos.y);
|
||||||
|
else
|
||||||
|
ImGui::Text("Mouse Position: <invalid>");
|
||||||
if (ImGui::BeginPopupContextWindow())
|
if (ImGui::BeginPopupContextWindow())
|
||||||
{
|
{
|
||||||
|
if (ImGui::MenuItem("Custom", NULL, corner == -1)) corner = -1;
|
||||||
if (ImGui::MenuItem("Top-left", NULL, corner == 0)) corner = 0;
|
if (ImGui::MenuItem("Top-left", NULL, corner == 0)) corner = 0;
|
||||||
if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1;
|
if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1;
|
||||||
if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2;
|
if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2;
|
||||||
|
@ -327,7 +327,6 @@ struct IMGUI_API ImRect
|
|||||||
void ClipWith(const ImRect& r) { Min = ImMax(Min, r.Min); Max = ImMin(Max, r.Max); } // Simple version, may lead to an inverted rectangle, which is fine for Contains/Overlaps test but not for display.
|
void ClipWith(const ImRect& r) { Min = ImMax(Min, r.Min); Max = ImMin(Max, r.Max); } // Simple version, may lead to an inverted rectangle, which is fine for Contains/Overlaps test but not for display.
|
||||||
void ClipWithFull(const ImRect& r) { Min = ImClamp(Min, r.Min, r.Max); Max = ImClamp(Max, r.Min, r.Max); } // Full version, ensure both points are fully clipped.
|
void ClipWithFull(const ImRect& r) { Min = ImClamp(Min, r.Min, r.Max); Max = ImClamp(Max, r.Min, r.Max); } // Full version, ensure both points are fully clipped.
|
||||||
void Floor() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
|
void Floor() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
|
||||||
void FixInverted() { if (Min.x > Max.x) ImSwap(Min.x, Max.x); if (Min.y > Max.y) ImSwap(Min.y, Max.y); }
|
|
||||||
bool IsInverted() const { return Min.x > Max.x || Min.y > Max.y; }
|
bool IsInverted() const { return Min.x > Max.x || Min.y > Max.y; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -948,7 +947,6 @@ struct IMGUI_API ImGuiWindow
|
|||||||
ImGuiID ViewportId; // We backup the viewport id (since the viewport may disappear or never be created if the window is inactive)
|
ImGuiID ViewportId; // We backup the viewport id (since the viewport may disappear or never be created if the window is inactive)
|
||||||
ImVec2 ViewportPos; // We backup the viewport position (since the viewport may disappear or never be created if the window is inactive)
|
ImVec2 ViewportPos; // We backup the viewport position (since the viewport may disappear or never be created if the window is inactive)
|
||||||
int ViewportAllowPlatformMonitorExtend; // Reset to -1 every frame (index is guaranteed to be valid between NewFrame..EndFrame), only used in the Appearing frame of a tooltip/popup to enforce clamping to a given monitor
|
int ViewportAllowPlatformMonitorExtend; // Reset to -1 every frame (index is guaranteed to be valid between NewFrame..EndFrame), only used in the Appearing frame of a tooltip/popup to enforce clamping to a given monitor
|
||||||
ImVec2 PosFloat;
|
|
||||||
ImVec2 Pos; // Position rounded-up to nearest pixel
|
ImVec2 Pos; // Position rounded-up to nearest pixel
|
||||||
ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
|
ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
|
||||||
ImVec2 SizeFull; // Size when non collapsed
|
ImVec2 SizeFull; // Size when non collapsed
|
||||||
|
Loading…
Reference in New Issue
Block a user