mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 09:27:00 +00:00
Merge branch 'master' into docking
# Conflicts: # imgui.cpp # imgui.h
This commit is contained in:
commit
03b64defa5
@ -110,13 +110,22 @@ Other Changes:
|
|||||||
- InputText: Work-around for buggy standard libraries where isprint('\t') returns true. (#2467, #1336)
|
- InputText: Work-around for buggy standard libraries where isprint('\t') returns true. (#2467, #1336)
|
||||||
- InputText: Fixed ImGuiInputTextFlags_AllowTabInput leading to two tabs characters being inserted
|
- InputText: Fixed ImGuiInputTextFlags_AllowTabInput leading to two tabs characters being inserted
|
||||||
if the back-end provided both Key and Character input. (#2467, #1336)
|
if the back-end provided both Key and Character input. (#2467, #1336)
|
||||||
|
- Added SetNextItemWidth() helper to avoid using PushItemWidth/PopItemWidth() for single items.
|
||||||
|
Note that SetNextItemWidth() currently only affect the same subset of items as PushItemWidth(),
|
||||||
|
generally referred to as the large framed+labeled items.
|
||||||
|
Because the new SetNextItemWidth() function is explicit
|
||||||
- GetMouseDragDelta(): also returns the delta on the mouse button released frame. (#2419)
|
- GetMouseDragDelta(): also returns the delta on the mouse button released frame. (#2419)
|
||||||
- GetMouseDragDelta(): verify that mouse positions are valid otherwise returns zero.
|
- GetMouseDragDelta(): verify that mouse positions are valid otherwise returns zero.
|
||||||
- Inputs: Also add support for horizontal scroll with Shift+Mouse Wheel. (#2424, #1463) [@LucaRood]
|
- Inputs: Also add support for horizontal scroll with Shift+Mouse Wheel. (#2424, #1463) [@LucaRood]
|
||||||
- PlotLines, PlotHistogram: Ignore NaN values when calculating min/max bounds. (#2485)
|
- PlotLines, PlotHistogram: Ignore NaN values when calculating min/max bounds. (#2485)
|
||||||
- Window: Window close button is horizontally aligned with style.FramePadding.x.
|
- Window: Window close button is horizontally aligned with style.FramePadding.x.
|
||||||
|
- Columns: Fixed boundary of clipping being off by 1 pixel within the left column.
|
||||||
|
- Combo, Slider, Scrollbar: Improve rendering in situation when there's only a few pixels available (<3 pixels).
|
||||||
|
- Misc: Fixed PushItemWidth(-width) (for right-side alignment) laying out certain items (button, listbox, etc.)
|
||||||
|
with negative sizes if the 'width' argument was smaller than the available width at the time of item submission,
|
||||||
- Misc: Added IM_MALLOC/IM_FREE macros mimicking IM_NEW/IM_DELETE so user doesn't need to revert
|
- Misc: Added IM_MALLOC/IM_FREE macros mimicking IM_NEW/IM_DELETE so user doesn't need to revert
|
||||||
to using the ImGui::MemAlloc()/MemFree() calls directly.
|
to using the ImGui::MemAlloc()/MemFree() calls directly.
|
||||||
|
- Metrics: Added "Show windows rectangles" tool to visualize the different rectangles.
|
||||||
- Examples: OpenGL: Added a dummy GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized
|
- Examples: OpenGL: Added a dummy GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized
|
||||||
GL function loaders early, and help users understand what they are missing. (#2421)
|
GL function loaders early, and help users understand what they are missing. (#2421)
|
||||||
- Examples: Emscripten: Added Emscripten+SDL+GLES2 example. (#2494, #2492, #2351, #336) [@nicolasnoble]
|
- Examples: Emscripten: Added Emscripten+SDL+GLES2 example. (#2494, #2492, #2351, #336) [@nicolasnoble]
|
||||||
|
@ -29,13 +29,14 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- window/opt: freeze window flag: if not focused/hovered, return false, render with previous ImDrawList. and/or reduce refresh rate. -> this may require enforcing that it is illegal to submit contents if Begin returns false.
|
- window/opt: freeze window flag: if not focused/hovered, return false, render with previous ImDrawList. and/or reduce refresh rate. -> this may require enforcing that it is illegal to submit contents if Begin returns false.
|
||||||
- window/child: the first draw command of a child window could be moved into the current draw command of the parent window (unless child+tooltip?).
|
- window/child: the first draw command of a child window could be moved into the current draw command of the parent window (unless child+tooltip?).
|
||||||
- window/clipping: some form of clipping when DisplaySize (or corresponding viewport) is zero.
|
- window/clipping: some form of clipping when DisplaySize (or corresponding viewport) is zero.
|
||||||
|
- window/tab: add a way to signify that a window or docked window requires attention (e.g. blinking title bar).
|
||||||
- scrolling: while holding down a scrollbar, try to keep the same contents visible (at least while not moving mouse)
|
- scrolling: while holding down a scrollbar, try to keep the same contents visible (at least while not moving mouse)
|
||||||
- scrolling: allow immediately effective change of scroll after Begin() if we haven't appended items yet.
|
- scrolling: allow immediately effective change of scroll after Begin() if we haven't appended items yet.
|
||||||
- scrolling/clipping: separator on the initial position of a window is not visible (cursorpos.y <= clippos.y). (2017-08-20: can't repro)
|
- scrolling/clipping: separator on the initial position of a window is not visible (cursorpos.y <= clippos.y). (2017-08-20: can't repro)
|
||||||
- scrolling/style: shadows on scrollable areas to denote that there is more contents
|
- scrolling/style: shadows on scrollable areas to denote that there is more contents
|
||||||
|
|
||||||
- drawdata: make it easy to clone (or swap?) a ImDrawData so user can easily save that data if they use threaded rendering.
|
- drawdata: make it easy to clone (or swap?) a ImDrawData so user can easily save that data if they use threaded rendering.
|
||||||
- drawlist: add calctextsize func to facilitate consistent code from user pov
|
! drawlist: add calctextsize func to facilitate consistent code from user pov (currently need to use ImGui or ImFont alternatives!)
|
||||||
- drawlist: end-user probably can't call Clear() directly because we expect a texture to be pushed in the stack.
|
- drawlist: end-user probably can't call Clear() directly because we expect a texture to be pushed in the stack.
|
||||||
- drawlist: maintaining bounding box per command would allow to merge draw command when clipping isn't relied on (typical non-scrolling window or non-overflowing column would merge with previous command).
|
- drawlist: maintaining bounding box per command would allow to merge draw command when clipping isn't relied on (typical non-scrolling window or non-overflowing column would merge with previous command).
|
||||||
- drawlist: primitives/helpers to manipulate vertices post submission, so e.g. a quad/rect can be resized to fit later submitted content, _without_ using the ChannelSplit api
|
- drawlist: primitives/helpers to manipulate vertices post submission, so e.g. a quad/rect can be resized to fit later submitted content, _without_ using the ChannelSplit api
|
||||||
@ -45,6 +46,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- drawlist: rendering: provide a way for imgui to output to a single/global vertex buffer, re-order indices only at the end of the frame (ref: https://gist.github.com/floooh/10388a0afbe08fce9e617d8aefa7d302)
|
- drawlist: rendering: provide a way for imgui to output to a single/global vertex buffer, re-order indices only at the end of the frame (ref: https://gist.github.com/floooh/10388a0afbe08fce9e617d8aefa7d302)
|
||||||
- drawlist: callback: add an extra void* in ImDrawCallback to allow passing render-local data to the callback (would break API).
|
- drawlist: callback: add an extra void* in ImDrawCallback to allow passing render-local data to the callback (would break API).
|
||||||
- drawlist: AddRect vs AddLine position confusing (#2441)
|
- drawlist: AddRect vs AddLine position confusing (#2441)
|
||||||
|
- drawlist: channel splitter should be external helper and not stored in ImDrawList.
|
||||||
- drawlist/opt: store rounded corners in texture to use 1 quad per corner (filled and wireframe) to lower the cost of rounding. (#1962)
|
- drawlist/opt: store rounded corners in texture to use 1 quad per corner (filled and wireframe) to lower the cost of rounding. (#1962)
|
||||||
- drawlist/opt: AddRect() axis aligned pixel aligned (no-aa) could use 8 triangles instead of 16 and no normal calculation.
|
- drawlist/opt: AddRect() axis aligned pixel aligned (no-aa) could use 8 triangles instead of 16 and no normal calculation.
|
||||||
- drawlist/opt: thick AA line could be doable in same number of triangles as 1.0 AA line by storing gradient+full color in atlas.
|
- drawlist/opt: thick AA line could be doable in same number of triangles as 1.0 AA line by storing gradient+full color in atlas.
|
||||||
@ -372,6 +374,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- examples: glfw: could go idle when minimized? if (glfwGetWindowAttrib(window, GLFW_ICONIFIED)) { glfwWaitEvents(); continue; } // issue: DeltaTime will be super high on resume, perhaps provide a way to let impl know (#440)
|
- examples: glfw: could go idle when minimized? if (glfwGetWindowAttrib(window, GLFW_ICONIFIED)) { glfwWaitEvents(); continue; } // issue: DeltaTime will be super high on resume, perhaps provide a way to let impl know (#440)
|
||||||
- examples: opengl: rename imgui_impl_opengl2 to impl_opengl_legacy and imgui_impl_opengl3 to imgui_impl_opengl? (#1900)
|
- examples: opengl: rename imgui_impl_opengl2 to impl_opengl_legacy and imgui_impl_opengl3 to imgui_impl_opengl? (#1900)
|
||||||
- examples: opengl: could use a single vertex buffer and glBufferSubData for uploads?
|
- examples: opengl: could use a single vertex buffer and glBufferSubData for uploads?
|
||||||
|
- examples: opengl: explicitly disable GL_STENCIL_TEST in bindings.
|
||||||
- examples: vulkan: viewport: support for synchronized swapping of multiple swap chains.
|
- examples: vulkan: viewport: support for synchronized swapping of multiple swap chains.
|
||||||
- optimization: replace vsnprintf with stb_printf? or enable the defines/infrastructure to allow it (#1038)
|
- optimization: replace vsnprintf with stb_printf? or enable the defines/infrastructure to allow it (#1038)
|
||||||
- optimization: add clipping for multi-component widgets (SliderFloatX, ColorEditX, etc.). one problem is that nav branch can't easily clip parent group when there is a move request.
|
- optimization: add clipping for multi-component widgets (SliderFloatX, ColorEditX, etc.). one problem is that nav branch can't easily clip parent group when there is a move request.
|
||||||
|
@ -2,150 +2,61 @@
|
|||||||
<html lang="en-us">
|
<html lang="en-us">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
|
||||||
<title>Dear ImGui Emscripten example</title>
|
<title>Dear ImGui Emscripten example</title>
|
||||||
<style>
|
<style>
|
||||||
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
|
body { margin: 0; background-color: black }
|
||||||
textarea.emscripten { font-family: monospace; width: 80%; }
|
.emscripten {
|
||||||
div.emscripten { text-align: center; }
|
position: absolute;
|
||||||
/* div.emscripten_border { border: 1px solid black; } */
|
top: 0px;
|
||||||
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */
|
left: 0px;
|
||||||
canvas.emscripten { border: 0px none; background-color: black; }
|
margin: 0px;
|
||||||
|
border: 0;
|
||||||
a:link { color: #000000; }
|
width: 100%;
|
||||||
a:visited { color: #000000; }
|
height: 100%;
|
||||||
a:active { color: #000000; }
|
overflow: hidden;
|
||||||
|
display: block;
|
||||||
.spinner {
|
image-rendering: optimizeSpeed;
|
||||||
height: 50px;
|
image-rendering: -moz-crisp-edges;
|
||||||
width: 50px;
|
image-rendering: -o-crisp-edges;
|
||||||
margin: 0px auto;
|
image-rendering: -webkit-optimize-contrast;
|
||||||
-webkit-animation: rotation .8s linear infinite;
|
image-rendering: optimize-contrast;
|
||||||
-moz-animation: rotation .8s linear infinite;
|
image-rendering: crisp-edges;
|
||||||
-o-animation: rotation .8s linear infinite;
|
image-rendering: pixelated;
|
||||||
animation: rotation 0.8s linear infinite;
|
-ms-interpolation-mode: nearest-neighbor;
|
||||||
border-left: 10px solid rgb(0,150,240);
|
|
||||||
border-right: 10px solid rgb(0,150,240);
|
|
||||||
border-bottom: 10px solid rgb(0,150,240);
|
|
||||||
border-top: 10px solid rgb(100,0,200);
|
|
||||||
border-radius: 100%;
|
|
||||||
background-color: rgb(200,100,250);
|
|
||||||
}
|
}
|
||||||
@-webkit-keyframes rotation {
|
|
||||||
from {-webkit-transform: rotate(0deg);}
|
|
||||||
to {-webkit-transform: rotate(360deg);}
|
|
||||||
}
|
|
||||||
@-moz-keyframes rotation {
|
|
||||||
from {-moz-transform: rotate(0deg);}
|
|
||||||
to {-moz-transform: rotate(360deg);}
|
|
||||||
}
|
|
||||||
@-o-keyframes rotation {
|
|
||||||
from {-o-transform: rotate(0deg);}
|
|
||||||
to {-o-transform: rotate(360deg);}
|
|
||||||
}
|
|
||||||
@keyframes rotation {
|
|
||||||
from {transform: rotate(0deg);}
|
|
||||||
to {transform: rotate(360deg);}
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<figure style="overflow:visible;" id="spinner"><div class="spinner"></div><center style="margin-top:0.5em"><strong>emscripten</strong></center></figure>
|
|
||||||
<div class="emscripten" id="status">Downloading...</div>
|
|
||||||
<div class="emscripten">
|
|
||||||
<progress value="0" max="100" id="progress" hidden=1></progress>
|
|
||||||
</div>
|
|
||||||
<div class="emscripten">
|
|
||||||
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
|
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
|
||||||
Example compiled from <a href="https://github.com/ocornut/imgui">https://github.com/ocornut/imgui</a>
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
<div class="emscripten">
|
|
||||||
<input type="button" value="Fullscreen" onclick="Module.requestFullscreen(false, false)">
|
|
||||||
<!-- <input type="checkbox" id="resize">Resize canvas -->
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<textarea class="emscripten" id="output" rows="4"></textarea>
|
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
var statusElement = document.getElementById('status');
|
|
||||||
var progressElement = document.getElementById('progress');
|
|
||||||
var spinnerElement = document.getElementById('spinner');
|
|
||||||
|
|
||||||
var Module = {
|
var Module = {
|
||||||
preRun: [],
|
preRun: [],
|
||||||
postRun: [],
|
postRun: [],
|
||||||
print: (function() {
|
print: (function() {
|
||||||
var element = document.getElementById('output');
|
|
||||||
if (element) element.value = ''; // clear browser cache
|
|
||||||
return function(text) {
|
return function(text) {
|
||||||
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
|
text = Array.prototype.slice.call(arguments).join(' ');
|
||||||
// These replacements are necessary if you render to raw HTML
|
|
||||||
//text = text.replace(/&/g, "&");
|
|
||||||
//text = text.replace(/</g, "<");
|
|
||||||
//text = text.replace(/>/g, ">");
|
|
||||||
//text = text.replace('\n', '<br>', 'g');
|
|
||||||
console.log(text);
|
console.log(text);
|
||||||
if (element) {
|
|
||||||
element.value += text + "\n";
|
|
||||||
element.scrollTop = element.scrollHeight; // focus on bottom
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
})(),
|
})(),
|
||||||
printErr: function(text) {
|
printErr: function(text) {
|
||||||
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
|
text = Array.prototype.slice.call(arguments).join(' ');
|
||||||
if (0) { // XXX disabled for safety typeof dump == 'function') {
|
|
||||||
dump(text + '\n'); // fast, straight to the real console
|
|
||||||
} else {
|
|
||||||
console.error(text);
|
console.error(text);
|
||||||
}
|
|
||||||
},
|
},
|
||||||
canvas: (function() {
|
canvas: (function() {
|
||||||
var canvas = document.getElementById('canvas');
|
var canvas = document.getElementById('canvas');
|
||||||
|
//canvas.addEventListener("webglcontextlost", function(e) { alert('FIXME: WebGL context lost, please reload the page'); e.preventDefault(); }, false);
|
||||||
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
|
|
||||||
// application robust, you may want to override this behavior before shipping!
|
|
||||||
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
|
|
||||||
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
|
|
||||||
|
|
||||||
return canvas;
|
return canvas;
|
||||||
})(),
|
})(),
|
||||||
setStatus: function(text) {
|
setStatus: function(text) {
|
||||||
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
|
console.log("status: " + text);
|
||||||
if (text === Module.setStatus.last.text) return;
|
|
||||||
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
|
|
||||||
var now = Date.now();
|
|
||||||
if (m && now - Module.setStatus.last.time < 30) return; // if this is a progress update, skip it if too soon
|
|
||||||
Module.setStatus.last.time = now;
|
|
||||||
Module.setStatus.last.text = text;
|
|
||||||
if (m) {
|
|
||||||
text = m[1];
|
|
||||||
progressElement.value = parseInt(m[2])*100;
|
|
||||||
progressElement.max = parseInt(m[4])*100;
|
|
||||||
progressElement.hidden = false;
|
|
||||||
spinnerElement.hidden = false;
|
|
||||||
} else {
|
|
||||||
progressElement.value = null;
|
|
||||||
progressElement.max = null;
|
|
||||||
progressElement.hidden = true;
|
|
||||||
if (!text) spinnerElement.hidden = true;
|
|
||||||
}
|
|
||||||
statusElement.innerHTML = text;
|
|
||||||
},
|
},
|
||||||
totalDependencies: 0,
|
|
||||||
monitorRunDependencies: function(left) {
|
monitorRunDependencies: function(left) {
|
||||||
this.totalDependencies = Math.max(this.totalDependencies, left);
|
// no run dependencies to log
|
||||||
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Module.setStatus('Downloading...');
|
|
||||||
window.onerror = function() {
|
window.onerror = function() {
|
||||||
Module.setStatus('Exception thrown, see JavaScript console');
|
console.log("onerror: " + event);
|
||||||
spinnerElement.style.display = 'none';
|
|
||||||
Module.setStatus = function(text) {
|
|
||||||
if (text) Module.printErr('[post-exception status] ' + text);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
{{{ SCRIPT }}}
|
{{{ SCRIPT }}}
|
||||||
|
@ -89,7 +89,7 @@ void ImGui_ImplMetal_Shutdown()
|
|||||||
|
|
||||||
void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor *renderPassDescriptor)
|
void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor *renderPassDescriptor)
|
||||||
{
|
{
|
||||||
IM_ASSERT(g_sharedMetalContext != nil && "No Metal context. Did you call ImGui_ImplMetal_Init?");
|
IM_ASSERT(g_sharedMetalContext != nil && "No Metal context. Did you call ImGui_ImplMetal_Init() ?");
|
||||||
|
|
||||||
g_sharedMetalContext.framebufferDescriptor = [[FramebufferDescriptor alloc] initWithRenderPassDescriptor:renderPassDescriptor];
|
g_sharedMetalContext.framebufferDescriptor = [[FramebufferDescriptor alloc] initWithRenderPassDescriptor:renderPassDescriptor];
|
||||||
}
|
}
|
||||||
|
265
imgui.cpp
265
imgui.cpp
@ -2112,10 +2112,8 @@ ImGuiTextFilter::ImGuiTextFilter(const char* default_filter)
|
|||||||
bool ImGuiTextFilter::Draw(const char* label, float width)
|
bool ImGuiTextFilter::Draw(const char* label, float width)
|
||||||
{
|
{
|
||||||
if (width != 0.0f)
|
if (width != 0.0f)
|
||||||
ImGui::PushItemWidth(width);
|
ImGui::SetNextItemWidth(width);
|
||||||
bool value_changed = ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf));
|
bool value_changed = ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf));
|
||||||
if (width != 0.0f)
|
|
||||||
ImGui::PopItemWidth();
|
|
||||||
if (value_changed)
|
if (value_changed)
|
||||||
Build();
|
Build();
|
||||||
return value_changed;
|
return value_changed;
|
||||||
@ -2581,7 +2579,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
|
|||||||
: DrawListInst(&context->DrawListSharedData)
|
: DrawListInst(&context->DrawListSharedData)
|
||||||
{
|
{
|
||||||
Name = ImStrdup(name);
|
Name = ImStrdup(name);
|
||||||
ID = ImHashStr(name, 0);
|
ID = ImHashStr(name);
|
||||||
IDStack.push_back(ID);
|
IDStack.push_back(ID);
|
||||||
Flags = FlagsPreviousFrame = ImGuiWindowFlags_None;
|
Flags = FlagsPreviousFrame = ImGuiWindowFlags_None;
|
||||||
Viewport = NULL;
|
Viewport = NULL;
|
||||||
@ -3035,27 +3033,14 @@ void ImGui::FocusableItemUnregister(ImGuiWindow* window)
|
|||||||
window->DC.FocusCounterTab--;
|
window->DC.FocusCounterTab--;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImVec2 ImGui::CalcItemSize(ImVec2 size, float default_x, float default_y)
|
|
||||||
{
|
|
||||||
ImGuiContext& g = *GImGui;
|
|
||||||
ImVec2 content_max;
|
|
||||||
if (size.x < 0.0f || size.y < 0.0f)
|
|
||||||
content_max = g.CurrentWindow->Pos + GetContentRegionMax();
|
|
||||||
if (size.x <= 0.0f)
|
|
||||||
size.x = (size.x == 0.0f) ? default_x : ImMax(content_max.x - g.CurrentWindow->DC.CursorPos.x, 4.0f) + size.x;
|
|
||||||
if (size.y <= 0.0f)
|
|
||||||
size.y = (size.y == 0.0f) ? default_y : ImMax(content_max.y - g.CurrentWindow->DC.CursorPos.y, 4.0f) + size.y;
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
|
float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
|
||||||
{
|
{
|
||||||
if (wrap_pos_x < 0.0f)
|
if (wrap_pos_x < 0.0f)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
ImGuiWindow* window = GetCurrentWindowRead();
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
if (wrap_pos_x == 0.0f)
|
if (wrap_pos_x == 0.0f)
|
||||||
wrap_pos_x = GetContentRegionMax().x + window->Pos.x;
|
wrap_pos_x = GetContentRegionMaxScreen().x;
|
||||||
else if (wrap_pos_x > 0.0f)
|
else if (wrap_pos_x > 0.0f)
|
||||||
wrap_pos_x += window->Pos.x - window->Scroll.x; // wrap_pos_x is provided is window local space
|
wrap_pos_x += window->Pos.x - window->Scroll.x; // wrap_pos_x is provided is window local space
|
||||||
|
|
||||||
@ -3153,7 +3138,7 @@ void ImGui::DestroyContext(ImGuiContext* ctx)
|
|||||||
|
|
||||||
ImGuiIO& ImGui::GetIO()
|
ImGuiIO& ImGui::GetIO()
|
||||||
{
|
{
|
||||||
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() or ImGui::SetCurrentContext()?");
|
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
|
||||||
return GImGui->IO;
|
return GImGui->IO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3165,7 +3150,7 @@ ImGuiPlatformIO& ImGui::GetPlatformIO()
|
|||||||
|
|
||||||
ImGuiStyle& ImGui::GetStyle()
|
ImGuiStyle& ImGui::GetStyle()
|
||||||
{
|
{
|
||||||
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() or ImGui::SetCurrentContext()?");
|
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
|
||||||
return GImGui->Style;
|
return GImGui->Style;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3563,7 +3548,7 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
|
|||||||
|
|
||||||
void ImGui::NewFrame()
|
void ImGui::NewFrame()
|
||||||
{
|
{
|
||||||
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() or ImGui::SetCurrentContext()?");
|
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
|
|
||||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||||
@ -3832,7 +3817,7 @@ void ImGui::Initialize(ImGuiContext* context)
|
|||||||
// Add .ini handle for ImGuiWindow type
|
// Add .ini handle for ImGuiWindow type
|
||||||
ImGuiSettingsHandler ini_handler;
|
ImGuiSettingsHandler ini_handler;
|
||||||
ini_handler.TypeName = "Window";
|
ini_handler.TypeName = "Window";
|
||||||
ini_handler.TypeHash = ImHashStr("Window", 0);
|
ini_handler.TypeHash = ImHashStr("Window");
|
||||||
ini_handler.ReadOpenFn = SettingsHandlerWindow_ReadOpen;
|
ini_handler.ReadOpenFn = SettingsHandlerWindow_ReadOpen;
|
||||||
ini_handler.ReadLineFn = SettingsHandlerWindow_ReadLine;
|
ini_handler.ReadLineFn = SettingsHandlerWindow_ReadLine;
|
||||||
ini_handler.WriteAllFn = SettingsHandlerWindow_WriteAll;
|
ini_handler.WriteAllFn = SettingsHandlerWindow_WriteAll;
|
||||||
@ -4889,7 +4874,7 @@ ImGuiWindow* ImGui::FindWindowByID(ImGuiID id)
|
|||||||
|
|
||||||
ImGuiWindow* ImGui::FindWindowByName(const char* name)
|
ImGuiWindow* ImGui::FindWindowByName(const char* name)
|
||||||
{
|
{
|
||||||
ImGuiID id = ImHashStr(name, 0);
|
ImGuiID id = ImHashStr(name);
|
||||||
return FindWindowByID(id);
|
return FindWindowByID(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6331,6 +6316,12 @@ void ImGui::FocusPreviousWindowIgnoringOne(ImGuiWindow* ignore_window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGui::SetNextItemWidth(float item_width)
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
|
window->DC.NextItemWidth = item_width;
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui::PushItemWidth(float item_width)
|
void ImGui::PushItemWidth(float item_width)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
@ -6342,8 +6333,6 @@ void ImGui::PushMultiItemsWidths(int components, float w_full)
|
|||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
const ImGuiStyle& style = GImGui->Style;
|
const ImGuiStyle& style = GImGui->Style;
|
||||||
if (w_full <= 0.0f)
|
|
||||||
w_full = CalcItemWidth();
|
|
||||||
const float w_item_one = ImMax(1.0f, (float)(int)((w_full - (style.ItemInnerSpacing.x) * (components-1)) / (float)components));
|
const float w_item_one = ImMax(1.0f, (float)(int)((w_full - (style.ItemInnerSpacing.x) * (components-1)) / (float)components));
|
||||||
const float w_item_last = ImMax(1.0f, (float)(int)(w_full - (w_item_one + style.ItemInnerSpacing.x) * (components-1)));
|
const float w_item_last = ImMax(1.0f, (float)(int)(w_full - (w_item_one + style.ItemInnerSpacing.x) * (components-1)));
|
||||||
window->DC.ItemWidthStack.push_back(w_item_last);
|
window->DC.ItemWidthStack.push_back(w_item_last);
|
||||||
@ -6359,20 +6348,66 @@ void ImGui::PopItemWidth()
|
|||||||
window->DC.ItemWidth = window->DC.ItemWidthStack.empty() ? window->ItemWidthDefault : window->DC.ItemWidthStack.back();
|
window->DC.ItemWidth = window->DC.ItemWidthStack.empty() ? window->ItemWidthDefault : window->DC.ItemWidthStack.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
float ImGui::CalcItemWidth()
|
// Calculate default item width given value passed to PushItemWidth() or SetNextItemWidth(),
|
||||||
|
// Then consume the
|
||||||
|
float ImGui::GetNextItemWidth()
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindowRead();
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
float w = window->DC.ItemWidth;
|
float w;
|
||||||
|
if (window->DC.NextItemWidth != FLT_MAX)
|
||||||
|
{
|
||||||
|
w = window->DC.NextItemWidth;
|
||||||
|
window->DC.NextItemWidth = FLT_MAX;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
w = window->DC.ItemWidth;
|
||||||
|
}
|
||||||
if (w < 0.0f)
|
if (w < 0.0f)
|
||||||
{
|
{
|
||||||
// Align to a right-side limit. We include 1 frame padding in the calculation because this is how the width is always used (we add 2 frame padding to it), but we could move that responsibility to the widget as well.
|
float region_max_x = GetContentRegionMaxScreen().x;
|
||||||
float width_to_right_edge = GetContentRegionAvail().x;
|
w = ImMax(1.0f, region_max_x - window->DC.CursorPos.x + w);
|
||||||
w = ImMax(1.0f, width_to_right_edge + w);
|
|
||||||
}
|
}
|
||||||
w = (float)(int)w;
|
w = (float)(int)w;
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calculate item width *without* popping/consuming NextItemWidth if it was set.
|
||||||
|
// (rarely used, which is why we avoid calling this from GetNextItemWidth() and instead do a backup/restore here)
|
||||||
|
float ImGui::CalcItemWidth()
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
|
float backup_next_item_width = window->DC.NextItemWidth;
|
||||||
|
float w = GetNextItemWidth();
|
||||||
|
window->DC.NextItemWidth = backup_next_item_width;
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
// [Internal] Calculate full item size given user provided 'size' parameter and default width/height. Default width is often == GetNextItemWidth().
|
||||||
|
// Those two functions CalcItemWidth vs CalcItemSize are awkwardly named because they are not fully symmetrical.
|
||||||
|
// Note that only CalcItemWidth() is publicly exposed.
|
||||||
|
// The 4.0f here may be changed to match GetNextItemWidth() and/or BeginChild() (right now we have a mismatch which is harmless but undesirable)
|
||||||
|
ImVec2 ImGui::CalcItemSize(ImVec2 size, float default_w, float default_h)
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
|
|
||||||
|
ImVec2 region_max;
|
||||||
|
if (size.x < 0.0f || size.y < 0.0f)
|
||||||
|
region_max = GetContentRegionMaxScreen();
|
||||||
|
|
||||||
|
if (size.x == 0.0f)
|
||||||
|
size.x = default_w;
|
||||||
|
else if (size.x < 0.0f)
|
||||||
|
size.x = ImMax(4.0f, region_max.x - window->DC.CursorPos.x + size.x);
|
||||||
|
|
||||||
|
if (size.y == 0.0f)
|
||||||
|
size.y = default_h;
|
||||||
|
else if (size.y < 0.0f)
|
||||||
|
size.y = ImMax(4.0f, region_max.y - window->DC.CursorPos.y + size.y);
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui::SetCurrentFont(ImFont* font)
|
void ImGui::SetCurrentFont(ImFont* font)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
@ -6989,17 +7024,27 @@ void ImGui::SetNextWindowClass(const ImGuiWindowClass* window_class)
|
|||||||
// FIXME: This is in window space (not screen space!)
|
// FIXME: This is in window space (not screen space!)
|
||||||
ImVec2 ImGui::GetContentRegionMax()
|
ImVec2 ImGui::GetContentRegionMax()
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindowRead();
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
ImVec2 mx = window->ContentsRegionRect.Max - window->Pos;
|
ImVec2 mx = window->ContentsRegionRect.Max - window->Pos;
|
||||||
if (window->DC.CurrentColumns)
|
if (window->DC.CurrentColumns)
|
||||||
mx.x = GetColumnOffset(window->DC.CurrentColumns->Current + 1) - window->WindowPadding.x;
|
mx.x = GetColumnOffset(window->DC.CurrentColumns->Current + 1) - window->WindowPadding.x;
|
||||||
return mx;
|
return mx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// [Internal] Absolute coordinate. Saner. This is not exposed until we finishing refactoring work rect features.
|
||||||
|
ImVec2 ImGui::GetContentRegionMaxScreen()
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
|
ImVec2 mx = window->ContentsRegionRect.Max;
|
||||||
|
if (window->DC.CurrentColumns)
|
||||||
|
mx.x = window->Pos.x + GetColumnOffset(window->DC.CurrentColumns->Current + 1) - window->WindowPadding.x;
|
||||||
|
return mx;
|
||||||
|
}
|
||||||
|
|
||||||
ImVec2 ImGui::GetContentRegionAvail()
|
ImVec2 ImGui::GetContentRegionAvail()
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindowRead();
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
return GetContentRegionMax() - (window->DC.CursorPos - window->Pos);
|
return GetContentRegionMaxScreen() - window->DC.CursorPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ImGui::GetContentRegionAvailWidth()
|
float ImGui::GetContentRegionAvailWidth()
|
||||||
@ -7379,21 +7424,21 @@ void ImGui::EndGroup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Gets back to previous line and continue with horizontal layout
|
// Gets back to previous line and continue with horizontal layout
|
||||||
// pos_x == 0 : follow right after previous item
|
// offset_from_start_x == 0 : follow right after previous item
|
||||||
// pos_x != 0 : align to specified x position (relative to window/group left)
|
// offset_from_start_x != 0 : align to specified x position (relative to window/group left)
|
||||||
// spacing_w < 0 : use default spacing if pos_x == 0, no spacing if pos_x != 0
|
// spacing_w < 0 : use default spacing if pos_x == 0, no spacing if pos_x != 0
|
||||||
// spacing_w >= 0 : enforce spacing amount
|
// spacing_w >= 0 : enforce spacing amount
|
||||||
void ImGui::SameLine(float pos_x, float spacing_w)
|
void ImGui::SameLine(float offset_from_start_x, float spacing_w)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
if (window->SkipItems)
|
if (window->SkipItems)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (pos_x != 0.0f)
|
if (offset_from_start_x != 0.0f)
|
||||||
{
|
{
|
||||||
if (spacing_w < 0.0f) spacing_w = 0.0f;
|
if (spacing_w < 0.0f) spacing_w = 0.0f;
|
||||||
window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + pos_x + spacing_w + window->DC.GroupOffset.x + window->DC.ColumnsOffset.x;
|
window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + offset_from_start_x + spacing_w + window->DC.GroupOffset.x + window->DC.ColumnsOffset.x;
|
||||||
window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y;
|
window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -8992,13 +9037,13 @@ void ImGui::NextColumn()
|
|||||||
columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y);
|
columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y);
|
||||||
if (++columns->Current < columns->Count)
|
if (++columns->Current < columns->Count)
|
||||||
{
|
{
|
||||||
// Columns 1+ cancel out IndentX
|
// New column (columns 1+ cancels out IndentX)
|
||||||
window->DC.ColumnsOffset.x = GetColumnOffset(columns->Current) - window->DC.Indent.x + g.Style.ItemSpacing.x;
|
window->DC.ColumnsOffset.x = GetColumnOffset(columns->Current) - window->DC.Indent.x + g.Style.ItemSpacing.x;
|
||||||
window->DrawList->ChannelsSetCurrent(columns->Current);
|
window->DrawList->ChannelsSetCurrent(columns->Current);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// New line
|
// New row/line
|
||||||
window->DC.ColumnsOffset.x = 0.0f;
|
window->DC.ColumnsOffset.x = 0.0f;
|
||||||
window->DrawList->ChannelsSetCurrent(0);
|
window->DrawList->ChannelsSetCurrent(0);
|
||||||
columns->Current = 0;
|
columns->Current = 0;
|
||||||
@ -9010,7 +9055,7 @@ void ImGui::NextColumn()
|
|||||||
window->DC.CurrentLineTextBaseOffset = 0.0f;
|
window->DC.CurrentLineTextBaseOffset = 0.0f;
|
||||||
|
|
||||||
PushColumnClipRect();
|
PushColumnClipRect();
|
||||||
PushItemWidth(GetColumnWidth() * 0.65f); // FIXME: Move on columns setup
|
PushItemWidth(GetColumnWidth() * 0.65f); // FIXME-COLUMNS: Move on columns setup
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImGui::GetColumnIndex()
|
int ImGui::GetColumnIndex()
|
||||||
@ -9035,7 +9080,7 @@ static float PixelsToOffsetNorm(const ImGuiColumns* columns, float offset)
|
|||||||
return offset / (columns->MaxX - columns->MinX);
|
return offset / (columns->MaxX - columns->MinX);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline float GetColumnsRectHalfWidth() { return 4.0f; }
|
static const float COLUMNS_HIT_RECT_HALF_WIDTH = 4.0f;
|
||||||
|
|
||||||
static float GetDraggedColumnOffset(ImGuiColumns* columns, int column_index)
|
static float GetDraggedColumnOffset(ImGuiColumns* columns, int column_index)
|
||||||
{
|
{
|
||||||
@ -9046,7 +9091,7 @@ static float GetDraggedColumnOffset(ImGuiColumns* columns, int column_index)
|
|||||||
IM_ASSERT(column_index > 0); // We are not supposed to drag column 0.
|
IM_ASSERT(column_index > 0); // We are not supposed to drag column 0.
|
||||||
IM_ASSERT(g.ActiveId == columns->ID + ImGuiID(column_index));
|
IM_ASSERT(g.ActiveId == columns->ID + ImGuiID(column_index));
|
||||||
|
|
||||||
float x = g.IO.MousePos.x - g.ActiveIdClickOffset.x + GetColumnsRectHalfWidth() - window->Pos.x;
|
float x = g.IO.MousePos.x - g.ActiveIdClickOffset.x + COLUMNS_HIT_RECT_HALF_WIDTH - window->Pos.x;
|
||||||
x = ImMax(x, ImGui::GetColumnOffset(column_index - 1) + g.Style.ColumnsMinSpacing);
|
x = ImMax(x, ImGui::GetColumnOffset(column_index - 1) + g.Style.ColumnsMinSpacing);
|
||||||
if ((columns->Flags & ImGuiColumnsFlags_NoPreserveWidths))
|
if ((columns->Flags & ImGuiColumnsFlags_NoPreserveWidths))
|
||||||
x = ImMin(x, ImGui::GetColumnOffset(column_index + 1) - g.Style.ColumnsMinSpacing);
|
x = ImMin(x, ImGui::GetColumnOffset(column_index + 1) - g.Style.ColumnsMinSpacing);
|
||||||
@ -9185,8 +9230,8 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
|
|||||||
const float content_region_width = (window->SizeContentsExplicit.x != 0.0f) ? (window->SizeContentsExplicit.x) : (window->InnerClipRect.Max.x - window->Pos.x);
|
const float content_region_width = (window->SizeContentsExplicit.x != 0.0f) ? (window->SizeContentsExplicit.x) : (window->InnerClipRect.Max.x - window->Pos.x);
|
||||||
columns->MinX = window->DC.Indent.x - g.Style.ItemSpacing.x; // Lock our horizontal range
|
columns->MinX = window->DC.Indent.x - g.Style.ItemSpacing.x; // Lock our horizontal range
|
||||||
columns->MaxX = ImMax(content_region_width - window->Scroll.x, columns->MinX + 1.0f);
|
columns->MaxX = ImMax(content_region_width - window->Scroll.x, columns->MinX + 1.0f);
|
||||||
columns->StartPosY = window->DC.CursorPos.y;
|
columns->BackupCursorPosY = window->DC.CursorPos.y;
|
||||||
columns->StartMaxPosX = window->DC.CursorMaxPos.x;
|
columns->BackupCursorMaxPosX = window->DC.CursorMaxPos.x;
|
||||||
columns->LineMinY = columns->LineMaxY = window->DC.CursorPos.y;
|
columns->LineMinY = columns->LineMaxY = window->DC.CursorPos.y;
|
||||||
window->DC.ColumnsOffset.x = 0.0f;
|
window->DC.ColumnsOffset.x = 0.0f;
|
||||||
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
|
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
|
||||||
@ -9212,7 +9257,7 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
|
|||||||
{
|
{
|
||||||
// Compute clipping rectangle
|
// Compute clipping rectangle
|
||||||
ImGuiColumnData* column = &columns->Columns[n];
|
ImGuiColumnData* column = &columns->Columns[n];
|
||||||
float clip_x1 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(n) - 1.0f);
|
float clip_x1 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(n));
|
||||||
float clip_x2 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(n + 1) - 1.0f);
|
float clip_x2 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(n + 1) - 1.0f);
|
||||||
column->ClipRect = ImRect(clip_x1, -FLT_MAX, clip_x2, +FLT_MAX);
|
column->ClipRect = ImRect(clip_x1, -FLT_MAX, clip_x2, +FLT_MAX);
|
||||||
column->ClipRect.ClipWith(window->ClipRect);
|
column->ClipRect.ClipWith(window->ClipRect);
|
||||||
@ -9243,39 +9288,41 @@ 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 = columns->StartMaxPosX; // Restore cursor max pos, as columns don't grow parent
|
window->DC.CursorMaxPos.x = columns->BackupCursorMaxPosX; // 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;
|
||||||
if (!(columns->Flags & ImGuiColumnsFlags_NoBorder) && !window->SkipItems)
|
if (!(columns->Flags & ImGuiColumnsFlags_NoBorder) && !window->SkipItems)
|
||||||
{
|
{
|
||||||
const float y1 = columns->StartPosY;
|
// We clip Y boundaries CPU side because very long triangles are mishandled by some GPU drivers.
|
||||||
const float y2 = window->DC.CursorPos.y;
|
const float y1 = ImMax(columns->BackupCursorPosY, window->ClipRect.Min.y);
|
||||||
|
const float y2 = ImMin(window->DC.CursorPos.y, window->ClipRect.Max.y);
|
||||||
int dragging_column = -1;
|
int dragging_column = -1;
|
||||||
for (int n = 1; n < columns->Count; n++)
|
for (int n = 1; n < columns->Count; n++)
|
||||||
{
|
{
|
||||||
|
ImGuiColumnData* column = &columns->Columns[n];
|
||||||
float x = window->Pos.x + GetColumnOffset(n);
|
float x = window->Pos.x + GetColumnOffset(n);
|
||||||
const ImGuiID column_id = columns->ID + ImGuiID(n);
|
const ImGuiID column_id = columns->ID + ImGuiID(n);
|
||||||
const float column_hw = GetColumnsRectHalfWidth(); // Half-width for interaction
|
const float column_hit_hw = COLUMNS_HIT_RECT_HALF_WIDTH;
|
||||||
const ImRect column_rect(ImVec2(x - column_hw, y1), ImVec2(x + column_hw, y2));
|
const ImRect column_hit_rect(ImVec2(x - column_hit_hw, y1), ImVec2(x + column_hit_hw, y2));
|
||||||
KeepAliveID(column_id);
|
KeepAliveID(column_id);
|
||||||
if (IsClippedEx(column_rect, column_id, false))
|
if (IsClippedEx(column_hit_rect, column_id, false))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool hovered = false, held = false;
|
bool hovered = false, held = false;
|
||||||
if (!(columns->Flags & ImGuiColumnsFlags_NoResize))
|
if (!(columns->Flags & ImGuiColumnsFlags_NoResize))
|
||||||
{
|
{
|
||||||
ButtonBehavior(column_rect, column_id, &hovered, &held);
|
ButtonBehavior(column_hit_rect, column_id, &hovered, &held);
|
||||||
if (hovered || held)
|
if (hovered || held)
|
||||||
g.MouseCursor = ImGuiMouseCursor_ResizeEW;
|
g.MouseCursor = ImGuiMouseCursor_ResizeEW;
|
||||||
if (held && !(columns->Columns[n].Flags & ImGuiColumnsFlags_NoResize))
|
if (held && !(column->Flags & ImGuiColumnsFlags_NoResize))
|
||||||
dragging_column = n;
|
dragging_column = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw column (we clip the Y boundaries CPU side because very long triangles are mishandled by some GPU drivers.)
|
// Draw column
|
||||||
const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : hovered ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator);
|
const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : hovered ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator);
|
||||||
const float xi = (float)(int)x;
|
const float xi = (float)(int)x;
|
||||||
window->DrawList->AddLine(ImVec2(xi, ImMax(y1 + 1.0f, window->ClipRect.Min.y)), ImVec2(xi, ImMin(y2, window->ClipRect.Max.y)), col);
|
window->DrawList->AddLine(ImVec2(xi, y1 + 1.0f), ImVec2(xi, y2), col);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply dragging after drawing the column lines, so our rendered lines are in sync with how items were displayed during the frame.
|
// Apply dragging after drawing the column lines, so our rendered lines are in sync with how items were displayed during the frame.
|
||||||
@ -9304,10 +9351,11 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
|
|||||||
|
|
||||||
ImGuiColumnsFlags flags = (border ? 0 : ImGuiColumnsFlags_NoBorder);
|
ImGuiColumnsFlags flags = (border ? 0 : ImGuiColumnsFlags_NoBorder);
|
||||||
//flags |= ImGuiColumnsFlags_NoPreserveWidths; // NB: Legacy behavior
|
//flags |= ImGuiColumnsFlags_NoPreserveWidths; // NB: Legacy behavior
|
||||||
if (window->DC.CurrentColumns != NULL && window->DC.CurrentColumns->Count == columns_count && window->DC.CurrentColumns->Flags == flags)
|
ImGuiColumns* columns = window->DC.CurrentColumns;
|
||||||
|
if (columns != NULL && columns->Count == columns_count && columns->Flags == flags)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (window->DC.CurrentColumns != NULL)
|
if (columns != NULL)
|
||||||
EndColumns();
|
EndColumns();
|
||||||
|
|
||||||
if (columns_count != 1)
|
if (columns_count != 1)
|
||||||
@ -9391,7 +9439,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
window = NULL;
|
window = NULL;
|
||||||
source_id = ImHashStr("#SourceExtern", 0);
|
source_id = ImHashStr("#SourceExtern");
|
||||||
source_drag_active = true;
|
source_drag_active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9792,11 +9840,10 @@ void ImGui::LogButtons()
|
|||||||
const bool log_to_tty = Button("Log To TTY"); SameLine();
|
const bool log_to_tty = Button("Log To TTY"); SameLine();
|
||||||
const bool log_to_file = Button("Log To File"); SameLine();
|
const bool log_to_file = Button("Log To File"); SameLine();
|
||||||
const bool log_to_clipboard = Button("Log To Clipboard"); SameLine();
|
const bool log_to_clipboard = Button("Log To Clipboard"); SameLine();
|
||||||
PushItemWidth(80.0f);
|
|
||||||
PushAllowKeyboardFocus(false);
|
PushAllowKeyboardFocus(false);
|
||||||
|
SetNextItemWidth(80.0f);
|
||||||
SliderInt("Default Depth", &g.LogDepthToExpandDefault, 0, 9, NULL);
|
SliderInt("Default Depth", &g.LogDepthToExpandDefault, 0, 9, NULL);
|
||||||
PopAllowKeyboardFocus();
|
PopAllowKeyboardFocus();
|
||||||
PopItemWidth();
|
|
||||||
PopID();
|
PopID();
|
||||||
|
|
||||||
// Start logging at the end of the function so that the buttons don't appear in the log
|
// Start logging at the end of the function so that the buttons don't appear in the log
|
||||||
@ -9834,7 +9881,7 @@ ImGuiWindowSettings* ImGui::CreateNewWindowSettings(const char* name)
|
|||||||
g.SettingsWindows.push_back(ImGuiWindowSettings());
|
g.SettingsWindows.push_back(ImGuiWindowSettings());
|
||||||
ImGuiWindowSettings* settings = &g.SettingsWindows.back();
|
ImGuiWindowSettings* settings = &g.SettingsWindows.back();
|
||||||
settings->Name = ImStrdup(name);
|
settings->Name = ImStrdup(name);
|
||||||
settings->ID = ImHashStr(name, 0);
|
settings->ID = ImHashStr(name);
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9849,7 +9896,7 @@ ImGuiWindowSettings* ImGui::FindWindowSettings(ImGuiID id)
|
|||||||
|
|
||||||
ImGuiWindowSettings* ImGui::FindOrCreateWindowSettings(const char* name)
|
ImGuiWindowSettings* ImGui::FindOrCreateWindowSettings(const char* name)
|
||||||
{
|
{
|
||||||
if (ImGuiWindowSettings* settings = FindWindowSettings(ImHashStr(name, 0)))
|
if (ImGuiWindowSettings* settings = FindWindowSettings(ImHashStr(name)))
|
||||||
return settings;
|
return settings;
|
||||||
return CreateNewWindowSettings(name);
|
return CreateNewWindowSettings(name);
|
||||||
}
|
}
|
||||||
@ -9867,7 +9914,7 @@ void ImGui::LoadIniSettingsFromDisk(const char* ini_filename)
|
|||||||
ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name)
|
ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
const ImGuiID type_hash = ImHashStr(type_name, 0);
|
const ImGuiID type_hash = ImHashStr(type_name);
|
||||||
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
|
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
|
||||||
if (g.SettingsHandlers[handler_n].TypeHash == type_hash)
|
if (g.SettingsHandlers[handler_n].TypeHash == type_hash)
|
||||||
return &g.SettingsHandlers[handler_n];
|
return &g.SettingsHandlers[handler_n];
|
||||||
@ -9972,7 +10019,7 @@ const char* ImGui::SaveIniSettingsToMemory(size_t* out_size)
|
|||||||
|
|
||||||
static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
|
static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
|
||||||
{
|
{
|
||||||
ImGuiWindowSettings* settings = ImGui::FindWindowSettings(ImHashStr(name, 0));
|
ImGuiWindowSettings* settings = ImGui::FindWindowSettings(ImHashStr(name));
|
||||||
if (!settings)
|
if (!settings)
|
||||||
settings = ImGui::CreateNewWindowSettings(name);
|
settings = ImGui::CreateNewWindowSettings(name);
|
||||||
return (void*)settings;
|
return (void*)settings;
|
||||||
@ -10953,7 +11000,7 @@ void ImGui::DockContextInitialize(ImGuiContext* ctx)
|
|||||||
// Add .ini handle for persistent docking data
|
// Add .ini handle for persistent docking data
|
||||||
ImGuiSettingsHandler ini_handler;
|
ImGuiSettingsHandler ini_handler;
|
||||||
ini_handler.TypeName = "Docking";
|
ini_handler.TypeName = "Docking";
|
||||||
ini_handler.TypeHash = ImHashStr("Docking", 0, 0);
|
ini_handler.TypeHash = ImHashStr("Docking");
|
||||||
ini_handler.ReadOpenFn = DockSettingsHandler_ReadOpen;
|
ini_handler.ReadOpenFn = DockSettingsHandler_ReadOpen;
|
||||||
ini_handler.ReadLineFn = DockSettingsHandler_ReadLine;
|
ini_handler.ReadLineFn = DockSettingsHandler_ReadLine;
|
||||||
ini_handler.WriteAllFn = DockSettingsHandler_WriteAll;
|
ini_handler.WriteAllFn = DockSettingsHandler_WriteAll;
|
||||||
@ -13150,7 +13197,7 @@ ImGuiID ImGui::DockSpaceOverViewport(ImGuiViewport* viewport, ImGuiDockNodeFlags
|
|||||||
void ImGui::DockBuilderDockWindow(const char* window_name, ImGuiID node_id)
|
void ImGui::DockBuilderDockWindow(const char* window_name, ImGuiID node_id)
|
||||||
{
|
{
|
||||||
// We don't preserve relative order of multiple docked windows (by clearing DockOrder back to -1)
|
// We don't preserve relative order of multiple docked windows (by clearing DockOrder back to -1)
|
||||||
ImGuiID window_id = ImHashStr(window_name, 0);
|
ImGuiID window_id = ImHashStr(window_name);
|
||||||
if (ImGuiWindow* window = FindWindowByID(window_id))
|
if (ImGuiWindow* window = FindWindowByID(window_id))
|
||||||
{
|
{
|
||||||
// Apply to created window
|
// Apply to created window
|
||||||
@ -13457,7 +13504,7 @@ void ImGui::DockBuilderCopyDockSpace(ImGuiID src_dockspace_id, ImGuiID dst_docks
|
|||||||
{
|
{
|
||||||
const char* src_window_name = (*in_window_remap_pairs)[remap_window_n];
|
const char* src_window_name = (*in_window_remap_pairs)[remap_window_n];
|
||||||
const char* dst_window_name = (*in_window_remap_pairs)[remap_window_n + 1];
|
const char* dst_window_name = (*in_window_remap_pairs)[remap_window_n + 1];
|
||||||
ImGuiID src_window_id = ImHashStr(src_window_name, 0);
|
ImGuiID src_window_id = ImHashStr(src_window_name);
|
||||||
src_windows.push_back(src_window_id);
|
src_windows.push_back(src_window_id);
|
||||||
|
|
||||||
// Search in the remapping tables
|
// Search in the remapping tables
|
||||||
@ -14075,16 +14122,18 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool show_draw_cmd_clip_rects = true;
|
enum { RT_OuterRect, RT_OuterRectClipped, RT_InnerMainRect, RT_InnerClipRect, RT_ContentsRegionRect, RT_ContentsFullRect };
|
||||||
static bool show_window_begin_order = false;
|
static bool show_windows_begin_order = false;
|
||||||
|
static bool show_windows_rects = false;
|
||||||
|
static int show_windows_rect_type = RT_ContentsRegionRect;
|
||||||
|
static bool show_drawcmd_clip_rects = true;
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGui::Text("Dear ImGui %s", ImGui::GetVersion());
|
ImGui::Text("Dear ImGui %s", ImGui::GetVersion());
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
||||||
ImGui::Text("%d vertices, %d indices (%d triangles)", io.MetricsRenderVertices, io.MetricsRenderIndices, io.MetricsRenderIndices / 3);
|
ImGui::Text("%d vertices, %d indices (%d triangles)", io.MetricsRenderVertices, io.MetricsRenderIndices, io.MetricsRenderIndices / 3);
|
||||||
ImGui::Text("%d active windows (%d visible)", io.MetricsActiveWindows, io.MetricsRenderWindows);
|
ImGui::Text("%d active windows (%d visible)", io.MetricsActiveWindows, io.MetricsRenderWindows);
|
||||||
ImGui::Text("%d allocations", io.MetricsActiveAllocations);
|
ImGui::Text("%d active allocations", io.MetricsActiveAllocations);
|
||||||
ImGui::Checkbox("Show clipping rectangles when hovering draw commands", &show_draw_cmd_clip_rects);
|
|
||||||
ImGui::Checkbox("Ctrl shows window begin order", &show_window_begin_order);
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
struct Funcs
|
struct Funcs
|
||||||
@ -14118,7 +14167,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
}
|
}
|
||||||
ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL;
|
ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL;
|
||||||
bool pcmd_node_open = ImGui::TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "Draw %4d %s vtx, tex 0x%p, clip_rect (%4.0f,%4.0f)-(%4.0f,%4.0f)", pcmd->ElemCount, draw_list->IdxBuffer.Size > 0 ? "indexed" : "non-indexed", pcmd->TextureId, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
|
bool pcmd_node_open = ImGui::TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "Draw %4d %s vtx, tex 0x%p, clip_rect (%4.0f,%4.0f)-(%4.0f,%4.0f)", pcmd->ElemCount, draw_list->IdxBuffer.Size > 0 ? "indexed" : "non-indexed", pcmd->TextureId, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
|
||||||
if (show_draw_cmd_clip_rects && fg_draw_list && ImGui::IsItemHovered())
|
if (show_drawcmd_clip_rects && fg_draw_list && ImGui::IsItemHovered())
|
||||||
{
|
{
|
||||||
ImRect clip_rect = pcmd->ClipRect;
|
ImRect clip_rect = pcmd->ClipRect;
|
||||||
ImRect vtxs_rect;
|
ImRect vtxs_rect;
|
||||||
@ -14160,6 +14209,16 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void NodeColumns(const ImGuiColumns* columns)
|
||||||
|
{
|
||||||
|
if (!ImGui::TreeNode((void*)(uintptr_t)columns->ID, "Columns Id: 0x%08X, Count: %d, Flags: 0x%04X", columns->ID, columns->Count, columns->Flags))
|
||||||
|
return;
|
||||||
|
ImGui::BulletText("Width: %.1f (MinX: %.1f, MaxX: %.1f)", columns->MaxX - columns->MinX, columns->MinX, columns->MaxX);
|
||||||
|
for (int column_n = 0; column_n < columns->Columns.Size; column_n++)
|
||||||
|
ImGui::BulletText("Column %02d: OffsetNorm %.3f (= %.1f px)", column_n, columns->Columns[column_n].OffsetNorm, OffsetNormToPixels(columns, columns->Columns[column_n].OffsetNorm));
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
static void NodeWindows(ImVector<ImGuiWindow*>& windows, const char* label)
|
static void NodeWindows(ImVector<ImGuiWindow*>& windows, const char* label)
|
||||||
{
|
{
|
||||||
if (!ImGui::TreeNode(label, "%s (%d)", label, windows.Size))
|
if (!ImGui::TreeNode(label, "%s (%d)", label, windows.Size))
|
||||||
@ -14199,16 +14258,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
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))
|
||||||
{
|
{
|
||||||
for (int n = 0; n < window->ColumnsStorage.Size; n++)
|
for (int n = 0; n < window->ColumnsStorage.Size; n++)
|
||||||
{
|
NodeColumns(&window->ColumnsStorage[n]);
|
||||||
const ImGuiColumns* columns = &window->ColumnsStorage[n];
|
|
||||||
if (ImGui::TreeNode((void*)(uintptr_t)columns->ID, "Columns Id: 0x%08X, Count: %d, Flags: 0x%04X", columns->ID, columns->Count, columns->Flags))
|
|
||||||
{
|
|
||||||
ImGui::BulletText("Width: %.1f (MinX: %.1f, MaxX: %.1f)", columns->MaxX - columns->MinX, columns->MinX, columns->MaxX);
|
|
||||||
for (int column_n = 0; column_n < columns->Columns.Size; column_n++)
|
|
||||||
ImGui::BulletText("Column %02d: OffsetNorm %.3f (= %.1f px)", column_n, columns->Columns[column_n].OffsetNorm, OffsetNormToPixels(columns, columns->Columns[column_n].OffsetNorm));
|
|
||||||
ImGui::TreePop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
ImGui::BulletText("Storage: %d bytes", window->StateStorage.Data.Size * (int)sizeof(ImGuiStorage::Pair));
|
ImGui::BulletText("Storage: %d bytes", window->StateStorage.Data.Size * (int)sizeof(ImGuiStorage::Pair));
|
||||||
@ -14260,6 +14310,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
Funcs::NodeViewport(g.Viewports[i]);
|
Funcs::NodeViewport(g.Viewports[i]);
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::TreeNode("Popups", "Popups (%d)", g.OpenPopupStack.Size))
|
if (ImGui::TreeNode("Popups", "Popups (%d)", g.OpenPopupStack.Size))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < g.OpenPopupStack.Size; i++)
|
for (int i = 0; i < g.OpenPopupStack.Size; i++)
|
||||||
@ -14269,11 +14320,13 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
}
|
}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::TreeNode("Docking & Tab Bars"))
|
if (ImGui::TreeNode("Docking & Tab Bars"))
|
||||||
{
|
{
|
||||||
ShowDockingDebug();
|
ShowDockingDebug();
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::TreeNode("Internal state"))
|
if (ImGui::TreeNode("Internal state"))
|
||||||
{
|
{
|
||||||
const char* input_source_names[] = { "None", "Mouse", "Nav", "NavKeyboard", "NavGamepad" }; IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT);
|
const char* input_source_names[] = { "None", "Mouse", "Nav", "NavKeyboard", "NavGamepad" }; IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT);
|
||||||
@ -14296,19 +14349,43 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g.IO.KeyCtrl && show_window_begin_order)
|
if (ImGui::TreeNode("Tools"))
|
||||||
|
{
|
||||||
|
ImGui::Checkbox("Show windows begin order", &show_windows_begin_order);
|
||||||
|
ImGui::Checkbox("Show windows rectangles", &show_windows_rects);
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 12);
|
||||||
|
show_windows_rects |= ImGui::Combo("##rects_type", &show_windows_rect_type, "OuterRect\0" "OuterRectClipped\0" "InnerMainRect\0" "InnerClipRect\0" "ContentsRegionRect\0");
|
||||||
|
ImGui::Checkbox("Show clipping rectangle when hovering ImDrawCmd node", &show_drawcmd_clip_rects);
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (show_windows_rects || show_windows_begin_order)
|
||||||
{
|
{
|
||||||
for (int n = 0; n < g.Windows.Size; n++)
|
for (int n = 0; n < g.Windows.Size; n++)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = g.Windows[n];
|
ImGuiWindow* window = g.Windows[n];
|
||||||
if (!window->WasActive || ((window->Flags & ImGuiWindowFlags_ChildWindow) && window->DockNode == NULL))
|
if (!window->WasActive)
|
||||||
continue;
|
continue;
|
||||||
char buf[64] = "";
|
ImDrawList* draw_list = GetForegroundDrawList(window);
|
||||||
char* p = buf;
|
if (show_windows_rects)
|
||||||
p += ImFormatString(p, buf + IM_ARRAYSIZE(buf) - p, "Order: %d\n", window->BeginOrderWithinContext);
|
{
|
||||||
ImDrawList* fg_draw_list = GetForegroundDrawList(window->Viewport);
|
ImRect r;
|
||||||
fg_draw_list->AddRectFilled(window->Pos - ImVec2(1, 1), window->Pos + CalcTextSize(buf) + ImVec2(1, 1), IM_COL32(200, 100, 100, 255));
|
if (show_windows_rect_type == RT_OuterRect) { r = window->Rect(); }
|
||||||
fg_draw_list->AddText(NULL, 0.0f, window->Pos, IM_COL32(255, 255, 255, 255), buf);
|
else if (show_windows_rect_type == RT_OuterRectClipped) { r = window->OuterRectClipped; }
|
||||||
|
else if (show_windows_rect_type == RT_InnerMainRect) { r = window->InnerMainRect; }
|
||||||
|
else if (show_windows_rect_type == RT_InnerClipRect) { r = window->InnerClipRect; }
|
||||||
|
else if (show_windows_rect_type == RT_ContentsRegionRect) { r = window->ContentsRegionRect; }
|
||||||
|
draw_list->AddRect(r.Min, r.Max, IM_COL32(255, 0, 128, 255));
|
||||||
|
}
|
||||||
|
if (show_windows_begin_order && !(window->Flags & ImGuiWindowFlags_ChildWindow))
|
||||||
|
{
|
||||||
|
char buf[32];
|
||||||
|
ImFormatString(buf, IM_ARRAYSIZE(buf), "%d", window->BeginOrderWithinContext);
|
||||||
|
float font_size = ImGui::GetFontSize();
|
||||||
|
draw_list->AddRectFilled(window->Pos, window->Pos + ImVec2(font_size, font_size), IM_COL32(200, 100, 100, 255));
|
||||||
|
draw_list->AddText(window->Pos, IM_COL32(255, 255, 255, 255), buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
21
imgui.h
21
imgui.h
@ -276,13 +276,8 @@ namespace ImGui
|
|||||||
IMGUI_API ImVec2 GetWindowSize(); // get current window size
|
IMGUI_API ImVec2 GetWindowSize(); // get current window size
|
||||||
IMGUI_API float GetWindowWidth(); // get current window width (shortcut for GetWindowSize().x)
|
IMGUI_API float GetWindowWidth(); // get current window width (shortcut for GetWindowSize().x)
|
||||||
IMGUI_API float GetWindowHeight(); // get current window height (shortcut for GetWindowSize().y)
|
IMGUI_API float GetWindowHeight(); // get current window height (shortcut for GetWindowSize().y)
|
||||||
IMGUI_API ImVec2 GetContentRegionMax(); // current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates
|
|
||||||
IMGUI_API ImVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos()
|
|
||||||
IMGUI_API float GetContentRegionAvailWidth(); // == GetContentRegionAvail().x
|
|
||||||
IMGUI_API ImVec2 GetWindowContentRegionMin(); // content boundaries min (roughly (0,0)-Scroll), in window coordinates
|
|
||||||
IMGUI_API ImVec2 GetWindowContentRegionMax(); // content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates
|
|
||||||
IMGUI_API float GetWindowContentRegionWidth(); //
|
|
||||||
|
|
||||||
|
// Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after Begin).
|
||||||
IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0, const ImVec2& pivot = ImVec2(0,0)); // set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc.
|
IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0, const ImVec2& pivot = ImVec2(0,0)); // set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc.
|
||||||
IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin()
|
IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin()
|
||||||
IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Use callback to apply non-trivial programmatic constraints.
|
IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Use callback to apply non-trivial programmatic constraints.
|
||||||
@ -301,6 +296,15 @@ namespace ImGui
|
|||||||
IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond = 0); // set named window collapsed state
|
IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond = 0); // set named window collapsed state
|
||||||
IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / front-most. use NULL to remove focus.
|
IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / front-most. use NULL to remove focus.
|
||||||
|
|
||||||
|
// Content region
|
||||||
|
// - Those functions are bound to be redesigned soon (they are confusing, incomplete and return values in local window coordinates which increases confusion)
|
||||||
|
IMGUI_API ImVec2 GetContentRegionMax(); // current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates
|
||||||
|
IMGUI_API ImVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos()
|
||||||
|
IMGUI_API float GetContentRegionAvailWidth(); // == GetContentRegionAvail().x
|
||||||
|
IMGUI_API ImVec2 GetWindowContentRegionMin(); // content boundaries min (roughly (0,0)-Scroll), in window coordinates
|
||||||
|
IMGUI_API ImVec2 GetWindowContentRegionMax(); // content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates
|
||||||
|
IMGUI_API float GetWindowContentRegionWidth(); //
|
||||||
|
|
||||||
// Windows Scrolling
|
// Windows Scrolling
|
||||||
IMGUI_API float GetScrollX(); // get scrolling amount [0..GetScrollMaxX()]
|
IMGUI_API float GetScrollX(); // get scrolling amount [0..GetScrollMaxX()]
|
||||||
IMGUI_API float GetScrollY(); // get scrolling amount [0..GetScrollMaxY()]
|
IMGUI_API float GetScrollY(); // get scrolling amount [0..GetScrollMaxY()]
|
||||||
@ -329,8 +333,9 @@ namespace ImGui
|
|||||||
IMGUI_API ImU32 GetColorU32(ImU32 col); // retrieve given color with style alpha applied
|
IMGUI_API ImU32 GetColorU32(ImU32 col); // retrieve given color with style alpha applied
|
||||||
|
|
||||||
// Parameters stacks (current window)
|
// Parameters stacks (current window)
|
||||||
IMGUI_API void PushItemWidth(float item_width); // width of items for the common item+label case, pixels. 0.0f = default to ~2/3 of windows width, >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -1.0f always align width to the right side)
|
IMGUI_API void PushItemWidth(float item_width); // set width of items for common large "item+label" widgets. >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -1.0f always align width to the right side). 0.0f = default to ~2/3 of windows width,
|
||||||
IMGUI_API void PopItemWidth();
|
IMGUI_API void PopItemWidth();
|
||||||
|
IMGUI_API void SetNextItemWidth(float item_width); // set width of the _next_ common large "item+label" widget. >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -1.0f always align width to the right side)
|
||||||
IMGUI_API float CalcItemWidth(); // width of item given pushed settings and current cursor position
|
IMGUI_API float CalcItemWidth(); // width of item given pushed settings and current cursor position
|
||||||
IMGUI_API void PushTextWrapPos(float wrap_local_pos_x = 0.0f); // word-wrapping for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space
|
IMGUI_API void PushTextWrapPos(float wrap_local_pos_x = 0.0f); // word-wrapping for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space
|
||||||
IMGUI_API void PopTextWrapPos();
|
IMGUI_API void PopTextWrapPos();
|
||||||
@ -343,7 +348,7 @@ namespace ImGui
|
|||||||
// - By "cursor" we mean the current output position.
|
// - By "cursor" we mean the current output position.
|
||||||
// - The typical widget behavior is to output themselves at the current cursor position, then move the cursor one line down.
|
// - The typical widget behavior is to output themselves at the current cursor position, then move the cursor one line down.
|
||||||
IMGUI_API void Separator(); // separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator.
|
IMGUI_API void Separator(); // separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator.
|
||||||
IMGUI_API void SameLine(float local_pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally. X position given in window coordinates.
|
IMGUI_API void SameLine(float offset_from_start_x=0.0f, float spacing=-1.0f); // call between widgets or groups to layout them horizontally. X position given in window coordinates.
|
||||||
IMGUI_API void NewLine(); // undo a SameLine() or force a new line when in an horizontal-layout context.
|
IMGUI_API void NewLine(); // undo a SameLine() or force a new line when in an horizontal-layout context.
|
||||||
IMGUI_API void Spacing(); // add vertical spacing.
|
IMGUI_API void Spacing(); // add vertical spacing.
|
||||||
IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size. unlike InvisibleButton(), Dummy() won't take the mouse click or be navigable into.
|
IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size. unlike InvisibleButton(), Dummy() won't take the mouse click or be navigable into.
|
||||||
|
@ -269,7 +269,6 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
ImGui::End();
|
ImGui::End();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ImGui::Text("dear imgui says hello. (%s)", IMGUI_VERSION);
|
|
||||||
|
|
||||||
// Most "big" widgets share a common width settings by default.
|
// Most "big" widgets share a common width settings by default.
|
||||||
//ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.65f); // Use 2/3 of the space for widgets and 1/3 for labels (default)
|
//ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.65f); // Use 2/3 of the space for widgets and 1/3 for labels (default)
|
||||||
@ -310,7 +309,9 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::Text("dear imgui says hello. (%s)", IMGUI_VERSION);
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
if (ImGui::CollapsingHeader("Help"))
|
if (ImGui::CollapsingHeader("Help"))
|
||||||
{
|
{
|
||||||
ImGui::Text("PROGRAMMER GUIDE:");
|
ImGui::Text("PROGRAMMER GUIDE:");
|
||||||
@ -604,9 +605,8 @@ static void ShowDemoWindowWidgets()
|
|||||||
ImGui::ListBox("listbox\n(single select)", &listbox_item_current, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
|
ImGui::ListBox("listbox\n(single select)", &listbox_item_current, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
|
||||||
|
|
||||||
//static int listbox_item_current2 = 2;
|
//static int listbox_item_current2 = 2;
|
||||||
//ImGui::PushItemWidth(-1);
|
//ImGui::SetNextItemWidth(-1);
|
||||||
//ImGui::ListBox("##listbox2", &listbox_item_current2, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
|
//ImGui::ListBox("##listbox2", &listbox_item_current2, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
|
||||||
//ImGui::PopItemWidth();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
@ -1106,7 +1106,8 @@ static void ShowDemoWindowWidgets()
|
|||||||
};
|
};
|
||||||
static int func_type = 0, display_count = 70;
|
static int func_type = 0, display_count = 70;
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::PushItemWidth(100); ImGui::Combo("func", &func_type, "Sin\0Saw\0"); ImGui::PopItemWidth();
|
ImGui::SetNextItemWidth(100);
|
||||||
|
ImGui::Combo("func", &func_type, "Sin\0Saw\0");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SliderInt("Sample count", &display_count, 1, 400);
|
ImGui::SliderInt("Sample count", &display_count, 1, 400);
|
||||||
float (*func)(void*, int) = (func_type == 0) ? Funcs::Sin : Funcs::Saw;
|
float (*func)(void*, int) = (func_type == 0) ? Funcs::Sin : Funcs::Saw;
|
||||||
@ -1724,9 +1725,8 @@ static void ShowDemoWindowLayout()
|
|||||||
static int line = 50;
|
static int line = 50;
|
||||||
bool goto_line = ImGui::Button("Goto");
|
bool goto_line = ImGui::Button("Goto");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::PushItemWidth(100);
|
ImGui::SetNextItemWidth(100);
|
||||||
goto_line |= ImGui::InputInt("##Line", &line, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue);
|
goto_line |= ImGui::InputInt("##Line", &line, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue);
|
||||||
ImGui::PopItemWidth();
|
|
||||||
|
|
||||||
// Child 1: no border, enable horizontal scrollbar
|
// Child 1: no border, enable horizontal scrollbar
|
||||||
{
|
{
|
||||||
@ -1797,35 +1797,36 @@ static void ShowDemoWindowLayout()
|
|||||||
|
|
||||||
if (ImGui::TreeNode("Widgets Width"))
|
if (ImGui::TreeNode("Widgets Width"))
|
||||||
{
|
{
|
||||||
|
// Use SetNextItemWidth() to set the width of a single upcoming item.
|
||||||
|
// Use PushItemWidth()/PopItemWidth() to set the width of a group of items.
|
||||||
static float f = 0.0f;
|
static float f = 0.0f;
|
||||||
ImGui::Text("PushItemWidth(100)");
|
ImGui::Text("SetNextItemWidth/PushItemWidth(100)");
|
||||||
ImGui::SameLine(); HelpMarker("Fixed width.");
|
ImGui::SameLine(); HelpMarker("Fixed width.");
|
||||||
ImGui::PushItemWidth(100);
|
ImGui::SetNextItemWidth(100);
|
||||||
ImGui::DragFloat("float##1", &f);
|
ImGui::DragFloat("float##1", &f);
|
||||||
ImGui::PopItemWidth();
|
|
||||||
|
|
||||||
ImGui::Text("PushItemWidth(GetWindowWidth() * 0.5f)");
|
ImGui::Text("SetNextItemWidth/PushItemWidth(GetWindowWidth() * 0.5f)");
|
||||||
ImGui::SameLine(); HelpMarker("Half of window width.");
|
ImGui::SameLine(); HelpMarker("Half of window width.");
|
||||||
ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.5f);
|
ImGui::SetNextItemWidth(ImGui::GetWindowWidth() * 0.5f);
|
||||||
ImGui::DragFloat("float##2", &f);
|
ImGui::DragFloat("float##2", &f);
|
||||||
ImGui::PopItemWidth();
|
|
||||||
|
|
||||||
ImGui::Text("PushItemWidth(GetContentRegionAvailWidth() * 0.5f)");
|
ImGui::Text("SetNextItemWidth/PushItemWidth(GetContentRegionAvailWidth() * 0.5f)");
|
||||||
ImGui::SameLine(); HelpMarker("Half of available width.\n(~ right-cursor_pos)\n(works within a column set)");
|
ImGui::SameLine(); HelpMarker("Half of available width.\n(~ right-cursor_pos)\n(works within a column set)");
|
||||||
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() * 0.5f);
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth() * 0.5f);
|
||||||
ImGui::DragFloat("float##3", &f);
|
ImGui::DragFloat("float##3", &f);
|
||||||
ImGui::PopItemWidth();
|
|
||||||
|
|
||||||
ImGui::Text("PushItemWidth(-100)");
|
ImGui::Text("SetNextItemWidth/PushItemWidth(-100)");
|
||||||
ImGui::SameLine(); HelpMarker("Align to right edge minus 100");
|
ImGui::SameLine(); HelpMarker("Align to right edge minus 100");
|
||||||
ImGui::PushItemWidth(-100);
|
ImGui::SetNextItemWidth(-100);
|
||||||
ImGui::DragFloat("float##4", &f);
|
ImGui::DragFloat("float##4", &f);
|
||||||
ImGui::PopItemWidth();
|
|
||||||
|
|
||||||
ImGui::Text("PushItemWidth(-1)");
|
// Demonstrate using PushItemWidth to surround three items. Calling SetNextItemWidth() before each of them would have the same effect.
|
||||||
|
ImGui::Text("SetNextItemWidth/PushItemWidth(-1)");
|
||||||
ImGui::SameLine(); HelpMarker("Align to right edge");
|
ImGui::SameLine(); HelpMarker("Align to right edge");
|
||||||
ImGui::PushItemWidth(-1);
|
ImGui::PushItemWidth(-1);
|
||||||
ImGui::DragFloat("float##5", &f);
|
ImGui::DragFloat("float##5a", &f);
|
||||||
|
ImGui::DragFloat("float##5b", &f);
|
||||||
|
ImGui::DragFloat("float##5c", &f);
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
@ -2298,9 +2299,8 @@ static void ShowDemoWindowPopups()
|
|||||||
{
|
{
|
||||||
if (ImGui::Selectable("Set to zero")) value = 0.0f;
|
if (ImGui::Selectable("Set to zero")) value = 0.0f;
|
||||||
if (ImGui::Selectable("Set to PI")) value = 3.1415f;
|
if (ImGui::Selectable("Set to PI")) value = 3.1415f;
|
||||||
ImGui::PushItemWidth(-1);
|
ImGui::SetNextItemWidth(-1);
|
||||||
ImGui::DragFloat("##Value", &value, 0.1f, 0.0f, 0.0f);
|
ImGui::DragFloat("##Value", &value, 0.1f, 0.0f, 0.0f);
|
||||||
ImGui::PopItemWidth();
|
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3046,7 +3046,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
}
|
}
|
||||||
ImGui::LogFinish();
|
ImGui::LogFinish();
|
||||||
}
|
}
|
||||||
ImGui::SameLine(); ImGui::PushItemWidth(120); ImGui::Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0"); ImGui::PopItemWidth();
|
ImGui::SameLine(); ImGui::SetNextItemWidth(120); ImGui::Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0");
|
||||||
ImGui::SameLine(); ImGui::Checkbox("Only Modified Colors", &output_only_modified);
|
ImGui::SameLine(); ImGui::Checkbox("Only Modified Colors", &output_only_modified);
|
||||||
|
|
||||||
static ImGuiTextFilter filter;
|
static ImGuiTextFilter filter;
|
||||||
@ -3885,12 +3885,11 @@ static void ShowExampleAppPropertyEditor(bool* p_open)
|
|||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
ImGui::TreeNodeEx("Field", ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_Bullet, "Field_%d", i);
|
ImGui::TreeNodeEx("Field", ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_Bullet, "Field_%d", i);
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
ImGui::PushItemWidth(-1);
|
ImGui::SetNextItemWidth(-1);
|
||||||
if (i >= 5)
|
if (i >= 5)
|
||||||
ImGui::InputFloat("##value", &dummy_members[i], 1.0f);
|
ImGui::InputFloat("##value", &dummy_members[i], 1.0f);
|
||||||
else
|
else
|
||||||
ImGui::DragFloat("##value", &dummy_members[i], 0.01f);
|
ImGui::DragFloat("##value", &dummy_members[i], 0.01f);
|
||||||
ImGui::PopItemWidth();
|
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
}
|
}
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
@ -4032,10 +4031,10 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
|
|||||||
if (ImGui::Button("200x200")) { ImGui::SetWindowSize(ImVec2(200, 200)); } ImGui::SameLine();
|
if (ImGui::Button("200x200")) { ImGui::SetWindowSize(ImVec2(200, 200)); } ImGui::SameLine();
|
||||||
if (ImGui::Button("500x500")) { ImGui::SetWindowSize(ImVec2(500, 500)); } ImGui::SameLine();
|
if (ImGui::Button("500x500")) { ImGui::SetWindowSize(ImVec2(500, 500)); } ImGui::SameLine();
|
||||||
if (ImGui::Button("800x200")) { ImGui::SetWindowSize(ImVec2(800, 200)); }
|
if (ImGui::Button("800x200")) { ImGui::SetWindowSize(ImVec2(800, 200)); }
|
||||||
ImGui::PushItemWidth(200);
|
ImGui::SetNextItemWidth(200);
|
||||||
ImGui::Combo("Constraint", &type, desc, IM_ARRAYSIZE(desc));
|
ImGui::Combo("Constraint", &type, desc, IM_ARRAYSIZE(desc));
|
||||||
|
ImGui::SetNextItemWidth(200);
|
||||||
ImGui::DragInt("Lines", &display_lines, 0.2f, 1, 100);
|
ImGui::DragInt("Lines", &display_lines, 0.2f, 1, 100);
|
||||||
ImGui::PopItemWidth();
|
|
||||||
ImGui::Checkbox("Auto-resize", &auto_resize);
|
ImGui::Checkbox("Auto-resize", &auto_resize);
|
||||||
for (int i = 0; i < display_lines; i++)
|
for (int i = 0; i < display_lines; i++)
|
||||||
ImGui::Text("%*sHello, sailor! Making this line long enough for the example.", i * 4, "");
|
ImGui::Text("%*sHello, sailor! Making this line long enough for the example.", i * 4, "");
|
||||||
@ -4640,12 +4639,14 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||||||
if (ImGui::BeginPopupModal("Save?"))
|
if (ImGui::BeginPopupModal("Save?"))
|
||||||
{
|
{
|
||||||
ImGui::Text("Save change to the following items?");
|
ImGui::Text("Save change to the following items?");
|
||||||
ImGui::PushItemWidth(-1.0f);
|
ImGui::SetNextItemWidth(-1.0f);
|
||||||
ImGui::ListBoxHeader("##", close_queue_unsaved_documents, 6);
|
if (ImGui::ListBoxHeader("##", close_queue_unsaved_documents, 6))
|
||||||
|
{
|
||||||
for (int n = 0; n < close_queue.Size; n++)
|
for (int n = 0; n < close_queue.Size; n++)
|
||||||
if (close_queue[n]->Dirty)
|
if (close_queue[n]->Dirty)
|
||||||
ImGui::Text("%s", close_queue[n]->Name);
|
ImGui::Text("%s", close_queue[n]->Name);
|
||||||
ImGui::ListBoxFooter();
|
ImGui::ListBoxFooter();
|
||||||
|
}
|
||||||
|
|
||||||
if (ImGui::Button("Yes", ImVec2(80, 0)))
|
if (ImGui::Button("Yes", ImVec2(80, 0)))
|
||||||
{
|
{
|
||||||
|
@ -160,7 +160,7 @@ IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, cons
|
|||||||
|
|
||||||
// Helpers: Misc
|
// Helpers: Misc
|
||||||
IMGUI_API ImU32 ImHashData(const void* data, size_t data_size, ImU32 seed = 0);
|
IMGUI_API ImU32 ImHashData(const void* data, size_t data_size, ImU32 seed = 0);
|
||||||
IMGUI_API ImU32 ImHashStr(const char* data, size_t data_size, ImU32 seed = 0);
|
IMGUI_API ImU32 ImHashStr(const char* data, size_t data_size = 0, ImU32 seed = 0);
|
||||||
IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_t* out_file_size = NULL, int padding_bytes = 0);
|
IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_t* out_file_size = NULL, int padding_bytes = 0);
|
||||||
IMGUI_API FILE* ImFileOpen(const char* filename, const char* file_open_mode);
|
IMGUI_API FILE* ImFileOpen(const char* filename, const char* file_open_mode);
|
||||||
static inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; }
|
static inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; }
|
||||||
@ -650,7 +650,7 @@ struct ImGuiWindowSettings
|
|||||||
struct ImGuiSettingsHandler
|
struct ImGuiSettingsHandler
|
||||||
{
|
{
|
||||||
const char* TypeName; // Short description stored in .ini file. Disallowed characters: '[' ']'
|
const char* TypeName; // Short description stored in .ini file. Disallowed characters: '[' ']'
|
||||||
ImGuiID TypeHash; // == ImHashStr(TypeName, 0, 0)
|
ImGuiID TypeHash; // == ImHashStr(TypeName)
|
||||||
void* (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name); // Read: Called when entering into a new ini entry e.g. "[Window][Name]"
|
void* (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name); // Read: Called when entering into a new ini entry e.g. "[Window][Name]"
|
||||||
void (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line); // Read: Called for every line of text within an ini entry
|
void (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line); // Read: Called for every line of text within an ini entry
|
||||||
void (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf); // Write: Output every entries into 'out_buf'
|
void (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf); // Write: Output every entries into 'out_buf'
|
||||||
@ -678,7 +678,7 @@ struct ImGuiColumnData
|
|||||||
ImGuiColumnsFlags Flags; // Not exposed
|
ImGuiColumnsFlags Flags; // Not exposed
|
||||||
ImRect ClipRect;
|
ImRect ClipRect;
|
||||||
|
|
||||||
ImGuiColumnData() { OffsetNorm = OffsetNormBeforeResize = 0.0f; Flags = 0; }
|
ImGuiColumnData() { OffsetNorm = OffsetNormBeforeResize = 0.0f; Flags = ImGuiColumnsFlags_None; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ImGuiColumns
|
struct ImGuiColumns
|
||||||
@ -691,23 +691,23 @@ struct ImGuiColumns
|
|||||||
int Count;
|
int Count;
|
||||||
float MinX, MaxX;
|
float MinX, MaxX;
|
||||||
float LineMinY, LineMaxY;
|
float LineMinY, LineMaxY;
|
||||||
float StartPosY; // Copy of CursorPos
|
float BackupCursorPosY; // Backup of CursorPos at the time of BeginColumns()
|
||||||
float StartMaxPosX; // Copy of CursorMaxPos
|
float BackupCursorMaxPosX; // Backup of CursorMaxPos at the time of BeginColumns()
|
||||||
ImVector<ImGuiColumnData> Columns;
|
ImVector<ImGuiColumnData> Columns;
|
||||||
|
|
||||||
ImGuiColumns() { Clear(); }
|
ImGuiColumns() { Clear(); }
|
||||||
void Clear()
|
void Clear()
|
||||||
{
|
{
|
||||||
ID = 0;
|
ID = 0;
|
||||||
Flags = 0;
|
Flags = ImGuiColumnsFlags_None;
|
||||||
IsFirstFrame = false;
|
IsFirstFrame = false;
|
||||||
IsBeingResized = false;
|
IsBeingResized = false;
|
||||||
Current = 0;
|
Current = 0;
|
||||||
Count = 1;
|
Count = 1;
|
||||||
MinX = MaxX = 0.0f;
|
MinX = MaxX = 0.0f;
|
||||||
LineMinY = LineMaxY = 0.0f;
|
LineMinY = LineMaxY = 0.0f;
|
||||||
StartPosY = 0.0f;
|
BackupCursorPosY = 0.0f;
|
||||||
StartMaxPosX = 0.0f;
|
BackupCursorMaxPosX = 0.0f;
|
||||||
Columns.clear();
|
Columns.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1301,6 +1301,7 @@ struct IMGUI_API ImGuiWindowTempData
|
|||||||
// We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.
|
// We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.
|
||||||
ImGuiItemFlags ItemFlags; // == ItemFlagsStack.back() [empty == ImGuiItemFlags_Default]
|
ImGuiItemFlags ItemFlags; // == ItemFlagsStack.back() [empty == ImGuiItemFlags_Default]
|
||||||
float ItemWidth; // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
|
float ItemWidth; // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
|
||||||
|
float NextItemWidth;
|
||||||
float TextWrapPos; // == TextWrapPosStack.back() [empty == -1.0f]
|
float TextWrapPos; // == TextWrapPosStack.back() [empty == -1.0f]
|
||||||
ImVector<ImGuiItemFlags>ItemFlagsStack;
|
ImVector<ImGuiItemFlags>ItemFlagsStack;
|
||||||
ImVector<float> ItemWidthStack;
|
ImVector<float> ItemWidthStack;
|
||||||
@ -1336,6 +1337,7 @@ struct IMGUI_API ImGuiWindowTempData
|
|||||||
|
|
||||||
ItemFlags = ImGuiItemFlags_Default_;
|
ItemFlags = ImGuiItemFlags_Default_;
|
||||||
ItemWidth = 0.0f;
|
ItemWidth = 0.0f;
|
||||||
|
NextItemWidth = +FLT_MAX;
|
||||||
TextWrapPos = -1.0f;
|
TextWrapPos = -1.0f;
|
||||||
memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
|
memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
|
||||||
|
|
||||||
@ -1626,12 +1628,14 @@ namespace ImGui
|
|||||||
IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
|
IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
|
||||||
IMGUI_API bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id); // Return true if focus is requested
|
IMGUI_API bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id); // Return true if focus is requested
|
||||||
IMGUI_API void FocusableItemUnregister(ImGuiWindow* window);
|
IMGUI_API void FocusableItemUnregister(ImGuiWindow* window);
|
||||||
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_x, float default_y);
|
IMGUI_API float GetNextItemWidth();
|
||||||
|
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_w, float default_h);
|
||||||
IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
|
IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
|
||||||
IMGUI_API void PushMultiItemsWidths(int components, float width_full = 0.0f);
|
IMGUI_API void PushMultiItemsWidths(int components, float width_full);
|
||||||
IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled);
|
IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled);
|
||||||
IMGUI_API void PopItemFlag();
|
IMGUI_API void PopItemFlag();
|
||||||
IMGUI_API bool IsItemToggledSelection(); // was the last item selection toggled? (after Selectable(), TreeNode() etc. We only returns toggle _event_ in order to handle clipping correctly)
|
IMGUI_API bool IsItemToggledSelection(); // was the last item selection toggled? (after Selectable(), TreeNode() etc. We only returns toggle _event_ in order to handle clipping correctly)
|
||||||
|
IMGUI_API ImVec2 GetContentRegionMaxScreen();
|
||||||
|
|
||||||
// Logging/Capture
|
// Logging/Capture
|
||||||
IMGUI_API void LogBegin(ImGuiLogType type, int auto_open_depth); // -> BeginCapture() when we design v2 api, for now stay under the radar by using the old name.
|
IMGUI_API void LogBegin(ImGuiLogType type, int auto_open_depth); // -> BeginCapture() when we design v2 api, for now stay under the radar by using the old name.
|
||||||
|
@ -299,7 +299,8 @@ void ImGui::TextWrapped(const char* fmt, ...)
|
|||||||
|
|
||||||
void ImGui::TextWrappedV(const char* fmt, va_list args)
|
void ImGui::TextWrappedV(const char* fmt, va_list args)
|
||||||
{
|
{
|
||||||
bool need_backup = (GImGui->CurrentWindow->DC.TextWrapPos < 0.0f); // Keep existing wrap position if one is already set
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
|
bool need_backup = (window->DC.TextWrapPos < 0.0f); // Keep existing wrap position if one is already set
|
||||||
if (need_backup)
|
if (need_backup)
|
||||||
PushTextWrapPos(0.0f);
|
PushTextWrapPos(0.0f);
|
||||||
TextV(fmt, args);
|
TextV(fmt, args);
|
||||||
@ -324,7 +325,7 @@ void ImGui::LabelTextV(const char* label, const char* fmt, va_list args)
|
|||||||
|
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
const ImGuiStyle& style = g.Style;
|
const ImGuiStyle& style = g.Style;
|
||||||
const float w = CalcItemWidth();
|
const float w = GetNextItemWidth();
|
||||||
|
|
||||||
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||||
const ImRect value_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2));
|
const ImRect value_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2));
|
||||||
@ -818,16 +819,19 @@ void ImGui::Scrollbar(ImGuiAxis axis)
|
|||||||
// Render background
|
// Render background
|
||||||
bool other_scrollbar = (horizontal ? window->ScrollbarY : window->ScrollbarX);
|
bool other_scrollbar = (horizontal ? window->ScrollbarY : window->ScrollbarX);
|
||||||
float other_scrollbar_size_w = other_scrollbar ? style.ScrollbarSize : 0.0f;
|
float other_scrollbar_size_w = other_scrollbar ? style.ScrollbarSize : 0.0f;
|
||||||
const ImRect window_rect = window->Rect();
|
const ImRect host_rect = window->Rect();
|
||||||
const float border_size = window->WindowBorderSize;
|
const float border_size = window->WindowBorderSize;
|
||||||
ImRect bb = horizontal
|
ImRect bb = horizontal
|
||||||
? ImRect(window->Pos.x + border_size, window_rect.Max.y - style.ScrollbarSize, window_rect.Max.x - other_scrollbar_size_w - border_size, window_rect.Max.y - border_size)
|
? ImRect(host_rect.Min.x + border_size, host_rect.Max.y - style.ScrollbarSize, host_rect.Max.x - other_scrollbar_size_w - border_size, host_rect.Max.y - border_size)
|
||||||
: ImRect(window_rect.Max.x - style.ScrollbarSize, window->Pos.y + border_size, window_rect.Max.x - border_size, window_rect.Max.y - other_scrollbar_size_w - border_size);
|
: ImRect(host_rect.Max.x - style.ScrollbarSize, host_rect.Min.y + border_size, host_rect.Max.x - border_size, host_rect.Max.y - other_scrollbar_size_w - border_size);
|
||||||
|
bb.Min.x = ImMax(host_rect.Min.x, bb.Min.x); // Handle case where the host rectangle is smaller than the scrollbar
|
||||||
|
bb.Min.y = ImMax(host_rect.Min.y, bb.Min.y);
|
||||||
if (!horizontal)
|
if (!horizontal)
|
||||||
bb.Min.y += window->TitleBarHeight() + ((window->Flags & ImGuiWindowFlags_MenuBar) ? window->MenuBarHeight() : 0.0f);
|
bb.Min.y += window->TitleBarHeight() + ((window->Flags & ImGuiWindowFlags_MenuBar) ? window->MenuBarHeight() : 0.0f); // FIXME: InnerRect?
|
||||||
|
|
||||||
|
const float bb_width = bb.GetWidth();
|
||||||
const float bb_height = bb.GetHeight();
|
const float bb_height = bb.GetHeight();
|
||||||
if (bb.GetWidth() <= 0.0f || bb_height <= 0.0f)
|
if (bb_width <= 0.0f || bb_height <= 0.0f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// When we are too small, start hiding and disabling the grab (this reduce visual noise on very small window and facilitate using the resize grab)
|
// When we are too small, start hiding and disabling the grab (this reduce visual noise on very small window and facilitate using the resize grab)
|
||||||
@ -846,7 +850,7 @@ void ImGui::Scrollbar(ImGuiAxis axis)
|
|||||||
else
|
else
|
||||||
window_rounding_corners = (((window->Flags & ImGuiWindowFlags_NoTitleBar) && !(window->Flags & ImGuiWindowFlags_MenuBar)) ? ImDrawCornerFlags_TopRight : 0) | (other_scrollbar ? 0 : ImDrawCornerFlags_BotRight);
|
window_rounding_corners = (((window->Flags & ImGuiWindowFlags_NoTitleBar) && !(window->Flags & ImGuiWindowFlags_MenuBar)) ? ImDrawCornerFlags_TopRight : 0) | (other_scrollbar ? 0 : ImDrawCornerFlags_BotRight);
|
||||||
window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_ScrollbarBg), window->WindowRounding, window_rounding_corners);
|
window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_ScrollbarBg), window->WindowRounding, window_rounding_corners);
|
||||||
bb.Expand(ImVec2(-ImClamp((float)(int)((bb.Max.x - bb.Min.x - 2.0f) * 0.5f), 0.0f, 3.0f), -ImClamp((float)(int)((bb.Max.y - bb.Min.y - 2.0f) * 0.5f), 0.0f, 3.0f)));
|
bb.Expand(ImVec2(-ImClamp((float)(int)((bb_width - 2.0f) * 0.5f), 0.0f, 3.0f), -ImClamp((float)(int)((bb_height - 2.0f) * 0.5f), 0.0f, 3.0f)));
|
||||||
|
|
||||||
// V denote the main, longer axis of the scrollbar (= height for a vertical scrollbar)
|
// V denote the main, longer axis of the scrollbar (= height for a vertical scrollbar)
|
||||||
float scrollbar_size_v = horizontal ? bb.GetWidth() : bb.GetHeight();
|
float scrollbar_size_v = horizontal ? bb.GetWidth() : bb.GetHeight();
|
||||||
@ -917,9 +921,9 @@ void ImGui::Scrollbar(ImGuiAxis axis)
|
|||||||
const ImU32 grab_col = GetColorU32(held ? ImGuiCol_ScrollbarGrabActive : hovered ? ImGuiCol_ScrollbarGrabHovered : ImGuiCol_ScrollbarGrab, alpha);
|
const ImU32 grab_col = GetColorU32(held ? ImGuiCol_ScrollbarGrabActive : hovered ? ImGuiCol_ScrollbarGrabHovered : ImGuiCol_ScrollbarGrab, alpha);
|
||||||
ImRect grab_rect;
|
ImRect grab_rect;
|
||||||
if (horizontal)
|
if (horizontal)
|
||||||
grab_rect = ImRect(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm), bb.Min.y, ImMin(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm) + grab_h_pixels, window_rect.Max.x), bb.Max.y);
|
grab_rect = ImRect(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm), bb.Min.y, ImMin(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm) + grab_h_pixels, host_rect.Max.x), bb.Max.y);
|
||||||
else
|
else
|
||||||
grab_rect = ImRect(bb.Min.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm), bb.Max.x, ImMin(ImLerp(bb.Min.y, bb.Max.y, grab_v_norm) + grab_h_pixels, window_rect.Max.y));
|
grab_rect = ImRect(bb.Min.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm), bb.Max.x, ImMin(ImLerp(bb.Min.y, bb.Max.y, grab_v_norm) + grab_h_pixels, host_rect.Max.y));
|
||||||
window->DrawList->AddRectFilled(grab_rect.Min, grab_rect.Max, grab_col, style.ScrollbarRounding);
|
window->DrawList->AddRectFilled(grab_rect.Min, grab_rect.Max, grab_col, style.ScrollbarRounding);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1116,7 +1120,7 @@ void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* over
|
|||||||
const ImGuiStyle& style = g.Style;
|
const ImGuiStyle& style = g.Style;
|
||||||
|
|
||||||
ImVec2 pos = window->DC.CursorPos;
|
ImVec2 pos = window->DC.CursorPos;
|
||||||
ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), g.FontSize + style.FramePadding.y*2.0f);
|
ImVec2 size = CalcItemSize(size_arg, GetNextItemWidth(), g.FontSize + style.FramePadding.y*2.0f);
|
||||||
ImRect bb(pos, pos + size);
|
ImRect bb(pos, pos + size);
|
||||||
ItemSize(size, style.FramePadding.y);
|
ItemSize(size, style.FramePadding.y);
|
||||||
if (!ItemAdd(bb, 0))
|
if (!ItemAdd(bb, 0))
|
||||||
@ -1380,7 +1384,8 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboF
|
|||||||
|
|
||||||
const float arrow_size = (flags & ImGuiComboFlags_NoArrowButton) ? 0.0f : GetFrameHeight();
|
const float arrow_size = (flags & ImGuiComboFlags_NoArrowButton) ? 0.0f : GetFrameHeight();
|
||||||
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||||
const float w = (flags & ImGuiComboFlags_NoPreview) ? arrow_size : CalcItemWidth();
|
const float expected_w = GetNextItemWidth();
|
||||||
|
const float w = (flags & ImGuiComboFlags_NoPreview) ? arrow_size : expected_w;
|
||||||
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f));
|
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f));
|
||||||
const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
|
const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
|
||||||
ItemSize(total_bb, style.FramePadding.y);
|
ItemSize(total_bb, style.FramePadding.y);
|
||||||
@ -1391,19 +1396,19 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboF
|
|||||||
bool pressed = ButtonBehavior(frame_bb, id, &hovered, &held);
|
bool pressed = ButtonBehavior(frame_bb, id, &hovered, &held);
|
||||||
bool popup_open = IsPopupOpen(id);
|
bool popup_open = IsPopupOpen(id);
|
||||||
|
|
||||||
const ImRect value_bb(frame_bb.Min, frame_bb.Max - ImVec2(arrow_size, 0.0f));
|
|
||||||
const ImU32 frame_col = GetColorU32(hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
const ImU32 frame_col = GetColorU32(hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
||||||
|
const float value_x2 = ImMax(frame_bb.Min.x, frame_bb.Max.x - arrow_size);
|
||||||
RenderNavHighlight(frame_bb, id);
|
RenderNavHighlight(frame_bb, id);
|
||||||
if (!(flags & ImGuiComboFlags_NoPreview))
|
if (!(flags & ImGuiComboFlags_NoPreview))
|
||||||
window->DrawList->AddRectFilled(frame_bb.Min, ImVec2(frame_bb.Max.x - arrow_size, frame_bb.Max.y), frame_col, style.FrameRounding, ImDrawCornerFlags_Left);
|
window->DrawList->AddRectFilled(frame_bb.Min, ImVec2(value_x2, frame_bb.Max.y), frame_col, style.FrameRounding, ImDrawCornerFlags_Left);
|
||||||
if (!(flags & ImGuiComboFlags_NoArrowButton))
|
if (!(flags & ImGuiComboFlags_NoArrowButton))
|
||||||
{
|
{
|
||||||
window->DrawList->AddRectFilled(ImVec2(frame_bb.Max.x - arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32((popup_open || hovered) ? ImGuiCol_ButtonHovered : ImGuiCol_Button), style.FrameRounding, (w <= arrow_size) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Right);
|
window->DrawList->AddRectFilled(ImVec2(value_x2, frame_bb.Min.y), frame_bb.Max, GetColorU32((popup_open || hovered) ? ImGuiCol_ButtonHovered : ImGuiCol_Button), style.FrameRounding, (w <= arrow_size) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Right);
|
||||||
RenderArrow(ImVec2(frame_bb.Max.x - arrow_size + style.FramePadding.y, frame_bb.Min.y + style.FramePadding.y), ImGuiDir_Down);
|
RenderArrow(ImVec2(value_x2 + style.FramePadding.y, frame_bb.Min.y + style.FramePadding.y), ImGuiDir_Down);
|
||||||
}
|
}
|
||||||
RenderFrameBorder(frame_bb.Min, frame_bb.Max, style.FrameRounding);
|
RenderFrameBorder(frame_bb.Min, frame_bb.Max, style.FrameRounding);
|
||||||
if (preview_value != NULL && !(flags & ImGuiComboFlags_NoPreview))
|
if (preview_value != NULL && !(flags & ImGuiComboFlags_NoPreview))
|
||||||
RenderTextClipped(frame_bb.Min + style.FramePadding, value_bb.Max, preview_value, NULL, NULL, ImVec2(0.0f,0.0f));
|
RenderTextClipped(frame_bb.Min + style.FramePadding, ImVec2(value_x2, frame_bb.Max.y), preview_value, NULL, NULL, ImVec2(0.0f,0.0f));
|
||||||
if (label_size.x > 0)
|
if (label_size.x > 0)
|
||||||
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
||||||
|
|
||||||
@ -2005,7 +2010,7 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* v, floa
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
const ImGuiStyle& style = g.Style;
|
const ImGuiStyle& style = g.Style;
|
||||||
const ImGuiID id = window->GetID(label);
|
const ImGuiID id = window->GetID(label);
|
||||||
const float w = CalcItemWidth();
|
const float w = GetNextItemWidth();
|
||||||
|
|
||||||
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||||
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f));
|
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f));
|
||||||
@ -2079,7 +2084,7 @@ bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* v, int
|
|||||||
bool value_changed = false;
|
bool value_changed = false;
|
||||||
BeginGroup();
|
BeginGroup();
|
||||||
PushID(label);
|
PushID(label);
|
||||||
PushMultiItemsWidths(components);
|
PushMultiItemsWidths(components, GetNextItemWidth());
|
||||||
size_t type_size = GDataTypeInfo[data_type].Size;
|
size_t type_size = GDataTypeInfo[data_type].Size;
|
||||||
for (int i = 0; i < components; i++)
|
for (int i = 0; i < components; i++)
|
||||||
{
|
{
|
||||||
@ -2126,7 +2131,7 @@ bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_cu
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
PushID(label);
|
PushID(label);
|
||||||
BeginGroup();
|
BeginGroup();
|
||||||
PushMultiItemsWidths(2);
|
PushMultiItemsWidths(2, GetNextItemWidth());
|
||||||
|
|
||||||
bool value_changed = DragFloat("##min", v_current_min, v_speed, (v_min >= v_max) ? -FLT_MAX : v_min, (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max), format, power);
|
bool value_changed = DragFloat("##min", v_current_min, v_speed, (v_min >= v_max) ? -FLT_MAX : v_min, (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max), format, power);
|
||||||
PopItemWidth();
|
PopItemWidth();
|
||||||
@ -2171,7 +2176,7 @@ bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
PushID(label);
|
PushID(label);
|
||||||
BeginGroup();
|
BeginGroup();
|
||||||
PushMultiItemsWidths(2);
|
PushMultiItemsWidths(2, GetNextItemWidth());
|
||||||
|
|
||||||
bool value_changed = DragInt("##min", v_current_min, v_speed, (v_min >= v_max) ? INT_MIN : v_min, (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max), format);
|
bool value_changed = DragInt("##min", v_current_min, v_speed, (v_min >= v_max) ? INT_MIN : v_min, (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max), format);
|
||||||
PopItemWidth();
|
PopItemWidth();
|
||||||
@ -2253,16 +2258,16 @@ bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_typ
|
|||||||
grab_sz = ImMax((float)(slider_sz / (v_range + 1)), style.GrabMinSize); // For integer sliders: if possible have the grab size represent 1 unit
|
grab_sz = ImMax((float)(slider_sz / (v_range + 1)), style.GrabMinSize); // For integer sliders: if possible have the grab size represent 1 unit
|
||||||
grab_sz = ImMin(grab_sz, slider_sz);
|
grab_sz = ImMin(grab_sz, slider_sz);
|
||||||
const float slider_usable_sz = slider_sz - grab_sz;
|
const float slider_usable_sz = slider_sz - grab_sz;
|
||||||
const float slider_usable_pos_min = bb.Min[axis] + grab_padding + grab_sz*0.5f;
|
const float slider_usable_pos_min = bb.Min[axis] + grab_padding + grab_sz * 0.5f;
|
||||||
const float slider_usable_pos_max = bb.Max[axis] - grab_padding - grab_sz*0.5f;
|
const float slider_usable_pos_max = bb.Max[axis] - grab_padding - grab_sz * 0.5f;
|
||||||
|
|
||||||
// For power curve sliders that cross over sign boundary we want the curve to be symmetric around 0.0f
|
// For power curve sliders that cross over sign boundary we want the curve to be symmetric around 0.0f
|
||||||
float linear_zero_pos; // 0.0->1.0f
|
float linear_zero_pos; // 0.0->1.0f
|
||||||
if (is_power && v_min * v_max < 0.0f)
|
if (is_power && v_min * v_max < 0.0f)
|
||||||
{
|
{
|
||||||
// Different sign
|
// Different sign
|
||||||
const FLOATTYPE linear_dist_min_to_0 = ImPow(v_min >= 0 ? (FLOATTYPE)v_min : -(FLOATTYPE)v_min, (FLOATTYPE)1.0f/power);
|
const FLOATTYPE linear_dist_min_to_0 = ImPow(v_min >= 0 ? (FLOATTYPE)v_min : -(FLOATTYPE)v_min, (FLOATTYPE)1.0f / power);
|
||||||
const FLOATTYPE linear_dist_max_to_0 = ImPow(v_max >= 0 ? (FLOATTYPE)v_max : -(FLOATTYPE)v_max, (FLOATTYPE)1.0f/power);
|
const FLOATTYPE linear_dist_max_to_0 = ImPow(v_max >= 0 ? (FLOATTYPE)v_max : -(FLOATTYPE)v_max, (FLOATTYPE)1.0f / power);
|
||||||
linear_zero_pos = (float)(linear_dist_min_to_0 / (linear_dist_min_to_0 + linear_dist_max_to_0));
|
linear_zero_pos = (float)(linear_dist_min_to_0 / (linear_dist_min_to_0 + linear_dist_max_to_0));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2385,15 +2390,22 @@ bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_typ
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (slider_sz < 1.0f)
|
||||||
|
{
|
||||||
|
*out_grab_bb = ImRect(bb.Min, bb.Min);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Output grab position so it can be displayed by the caller
|
// Output grab position so it can be displayed by the caller
|
||||||
float grab_t = SliderCalcRatioFromValueT<TYPE,FLOATTYPE>(data_type, *v, v_min, v_max, power, linear_zero_pos);
|
float grab_t = SliderCalcRatioFromValueT<TYPE, FLOATTYPE>(data_type, *v, v_min, v_max, power, linear_zero_pos);
|
||||||
if (axis == ImGuiAxis_Y)
|
if (axis == ImGuiAxis_Y)
|
||||||
grab_t = 1.0f - grab_t;
|
grab_t = 1.0f - grab_t;
|
||||||
const float grab_pos = ImLerp(slider_usable_pos_min, slider_usable_pos_max, grab_t);
|
const float grab_pos = ImLerp(slider_usable_pos_min, slider_usable_pos_max, grab_t);
|
||||||
if (axis == ImGuiAxis_X)
|
if (axis == ImGuiAxis_X)
|
||||||
*out_grab_bb = ImRect(grab_pos - grab_sz*0.5f, bb.Min.y + grab_padding, grab_pos + grab_sz*0.5f, bb.Max.y - grab_padding);
|
*out_grab_bb = ImRect(grab_pos - grab_sz * 0.5f, bb.Min.y + grab_padding, grab_pos + grab_sz * 0.5f, bb.Max.y - grab_padding);
|
||||||
else
|
else
|
||||||
*out_grab_bb = ImRect(bb.Min.x + grab_padding, grab_pos - grab_sz*0.5f, bb.Max.x - grab_padding, grab_pos + grab_sz*0.5f);
|
*out_grab_bb = ImRect(bb.Min.x + grab_padding, grab_pos - grab_sz * 0.5f, bb.Max.x - grab_padding, grab_pos + grab_sz * 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
return value_changed;
|
return value_changed;
|
||||||
}
|
}
|
||||||
@ -2442,7 +2454,7 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* v, co
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
const ImGuiStyle& style = g.Style;
|
const ImGuiStyle& style = g.Style;
|
||||||
const ImGuiID id = window->GetID(label);
|
const ImGuiID id = window->GetID(label);
|
||||||
const float w = CalcItemWidth();
|
const float w = GetNextItemWidth();
|
||||||
|
|
||||||
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||||
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f));
|
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f));
|
||||||
@ -2495,6 +2507,7 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* v, co
|
|||||||
MarkItemEdited(id);
|
MarkItemEdited(id);
|
||||||
|
|
||||||
// Render grab
|
// Render grab
|
||||||
|
if (grab_bb.Max.x > grab_bb.Min.x)
|
||||||
window->DrawList->AddRectFilled(grab_bb.Min, grab_bb.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding);
|
window->DrawList->AddRectFilled(grab_bb.Min, grab_bb.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding);
|
||||||
|
|
||||||
// Display value using user-provided display format so user can add prefix/suffix/decorations to the value.
|
// Display value using user-provided display format so user can add prefix/suffix/decorations to the value.
|
||||||
@ -2520,7 +2533,7 @@ bool ImGui::SliderScalarN(const char* label, ImGuiDataType data_type, void* v, i
|
|||||||
bool value_changed = false;
|
bool value_changed = false;
|
||||||
BeginGroup();
|
BeginGroup();
|
||||||
PushID(label);
|
PushID(label);
|
||||||
PushMultiItemsWidths(components);
|
PushMultiItemsWidths(components, GetNextItemWidth());
|
||||||
size_t type_size = GDataTypeInfo[data_type].Size;
|
size_t type_size = GDataTypeInfo[data_type].Size;
|
||||||
for (int i = 0; i < components; i++)
|
for (int i = 0; i < components; i++)
|
||||||
{
|
{
|
||||||
@ -2635,6 +2648,7 @@ bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType d
|
|||||||
MarkItemEdited(id);
|
MarkItemEdited(id);
|
||||||
|
|
||||||
// Render grab
|
// Render grab
|
||||||
|
if (grab_bb.Max.y > grab_bb.Min.y)
|
||||||
window->DrawList->AddRectFilled(grab_bb.Min, grab_bb.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding);
|
window->DrawList->AddRectFilled(grab_bb.Min, grab_bb.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding);
|
||||||
|
|
||||||
// Display value using user-provided display format so user can add prefix/suffix/decorations to the value.
|
// Display value using user-provided display format so user can add prefix/suffix/decorations to the value.
|
||||||
@ -2808,10 +2822,9 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* data_p
|
|||||||
|
|
||||||
BeginGroup(); // The only purpose of the group here is to allow the caller to query item data e.g. IsItemActive()
|
BeginGroup(); // The only purpose of the group here is to allow the caller to query item data e.g. IsItemActive()
|
||||||
PushID(label);
|
PushID(label);
|
||||||
PushItemWidth(ImMax(1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2));
|
SetNextItemWidth(ImMax(1.0f, GetNextItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2));
|
||||||
if (InputText("", buf, IM_ARRAYSIZE(buf), flags)) // PushId(label) + "" gives us the expected ID from outside point of view
|
if (InputText("", buf, IM_ARRAYSIZE(buf), flags)) // PushId(label) + "" gives us the expected ID from outside point of view
|
||||||
value_changed = DataTypeApplyOpFromText(buf, g.InputTextState.InitialTextA.Data, data_type, data_ptr, format);
|
value_changed = DataTypeApplyOpFromText(buf, g.InputTextState.InitialTextA.Data, data_type, data_ptr, format);
|
||||||
PopItemWidth();
|
|
||||||
|
|
||||||
// Step buttons
|
// Step buttons
|
||||||
const ImVec2 backup_frame_padding = style.FramePadding;
|
const ImVec2 backup_frame_padding = style.FramePadding;
|
||||||
@ -2857,7 +2870,7 @@ bool ImGui::InputScalarN(const char* label, ImGuiDataType data_type, void* v, in
|
|||||||
bool value_changed = false;
|
bool value_changed = false;
|
||||||
BeginGroup();
|
BeginGroup();
|
||||||
PushID(label);
|
PushID(label);
|
||||||
PushMultiItemsWidths(components);
|
PushMultiItemsWidths(components, GetNextItemWidth());
|
||||||
size_t type_size = GDataTypeInfo[data_type].Size;
|
size_t type_size = GDataTypeInfo[data_type].Size;
|
||||||
for (int i = 0; i < components; i++)
|
for (int i = 0; i < components; i++)
|
||||||
{
|
{
|
||||||
@ -3307,7 +3320,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
BeginGroup();
|
BeginGroup();
|
||||||
const ImGuiID id = window->GetID(label);
|
const ImGuiID id = window->GetID(label);
|
||||||
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||||
ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), (is_multiline ? GetTextLineHeight() * 8.0f : label_size.y) + style.FramePadding.y*2.0f); // Arbitrary default of 8 lines high for multi-line
|
ImVec2 size = CalcItemSize(size_arg, GetNextItemWidth(), (is_multiline ? GetTextLineHeight() * 8.0f : label_size.y) + style.FramePadding.y*2.0f); // Arbitrary default of 8 lines high for multi-line
|
||||||
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + size);
|
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + size);
|
||||||
const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? (style.ItemInnerSpacing.x + label_size.x) : 0.0f, 0.0f));
|
const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? (style.ItemInnerSpacing.x + label_size.x) : 0.0f, 0.0f));
|
||||||
|
|
||||||
@ -4068,7 +4081,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
const ImGuiStyle& style = g.Style;
|
const ImGuiStyle& style = g.Style;
|
||||||
const float square_sz = GetFrameHeight();
|
const float square_sz = GetFrameHeight();
|
||||||
const float w_extra = (flags & ImGuiColorEditFlags_NoSmallPreview) ? 0.0f : (square_sz + style.ItemInnerSpacing.x);
|
const float w_extra = (flags & ImGuiColorEditFlags_NoSmallPreview) ? 0.0f : (square_sz + style.ItemInnerSpacing.x);
|
||||||
const float w_items_all = CalcItemWidth() - w_extra;
|
const float w_items_all = GetNextItemWidth() - w_extra;
|
||||||
const char* label_display_end = FindRenderedTextEnd(label);
|
const char* label_display_end = FindRenderedTextEnd(label);
|
||||||
|
|
||||||
BeginGroup();
|
BeginGroup();
|
||||||
@ -4133,13 +4146,11 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
};
|
};
|
||||||
const int fmt_idx = hide_prefix ? 0 : (flags & ImGuiColorEditFlags_DisplayHSV) ? 2 : 1;
|
const int fmt_idx = hide_prefix ? 0 : (flags & ImGuiColorEditFlags_DisplayHSV) ? 2 : 1;
|
||||||
|
|
||||||
PushItemWidth(w_item_one);
|
|
||||||
for (int n = 0; n < components; n++)
|
for (int n = 0; n < components; n++)
|
||||||
{
|
{
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
SameLine(0, style.ItemInnerSpacing.x);
|
SameLine(0, style.ItemInnerSpacing.x);
|
||||||
if (n + 1 == components)
|
SetNextItemWidth((n + 1 < components) ? w_item_one : w_item_last);
|
||||||
PushItemWidth(w_item_last);
|
|
||||||
if (flags & ImGuiColorEditFlags_Float)
|
if (flags & ImGuiColorEditFlags_Float)
|
||||||
{
|
{
|
||||||
value_changed |= DragFloat(ids[n], &f[n], 1.0f/255.0f, 0.0f, hdr ? 0.0f : 1.0f, fmt_table_float[fmt_idx][n]);
|
value_changed |= DragFloat(ids[n], &f[n], 1.0f/255.0f, 0.0f, hdr ? 0.0f : 1.0f, fmt_table_float[fmt_idx][n]);
|
||||||
@ -4152,8 +4163,6 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
||||||
OpenPopupOnItemClick("context");
|
OpenPopupOnItemClick("context");
|
||||||
}
|
}
|
||||||
PopItemWidth();
|
|
||||||
PopItemWidth();
|
|
||||||
}
|
}
|
||||||
else if ((flags & ImGuiColorEditFlags_DisplayHex) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
|
else if ((flags & ImGuiColorEditFlags_DisplayHex) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
|
||||||
{
|
{
|
||||||
@ -4163,7 +4172,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X%02X", ImClamp(i[0],0,255), ImClamp(i[1],0,255), ImClamp(i[2],0,255), ImClamp(i[3],0,255));
|
ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X%02X", ImClamp(i[0],0,255), ImClamp(i[1],0,255), ImClamp(i[2],0,255), ImClamp(i[3],0,255));
|
||||||
else
|
else
|
||||||
ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", ImClamp(i[0],0,255), ImClamp(i[1],0,255), ImClamp(i[2],0,255));
|
ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", ImClamp(i[0],0,255), ImClamp(i[1],0,255), ImClamp(i[2],0,255));
|
||||||
PushItemWidth(w_items_all);
|
SetNextItemWidth(w_items_all);
|
||||||
if (InputText("##Text", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase))
|
if (InputText("##Text", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase))
|
||||||
{
|
{
|
||||||
value_changed = true;
|
value_changed = true;
|
||||||
@ -4178,7 +4187,6 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
}
|
}
|
||||||
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
||||||
OpenPopupOnItemClick("context");
|
OpenPopupOnItemClick("context");
|
||||||
PopItemWidth();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiWindow* picker_active_window = NULL;
|
ImGuiWindow* picker_active_window = NULL;
|
||||||
@ -4211,9 +4219,8 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
}
|
}
|
||||||
ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags__InputMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar;
|
ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags__InputMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar;
|
||||||
ImGuiColorEditFlags picker_flags = (flags_untouched & picker_flags_to_forward) | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf;
|
ImGuiColorEditFlags picker_flags = (flags_untouched & picker_flags_to_forward) | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf;
|
||||||
PushItemWidth(square_sz * 12.0f); // Use 256 + bar sizes?
|
SetNextItemWidth(square_sz * 12.0f); // Use 256 + bar sizes?
|
||||||
value_changed |= ColorPicker4("##picker", col, picker_flags, &g.ColorPickerRef.x);
|
value_changed |= ColorPicker4("##picker", col, picker_flags, &g.ColorPickerRef.x);
|
||||||
PopItemWidth();
|
|
||||||
EndPopup();
|
EndPopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4381,7 +4388,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
ImVec2 picker_pos = window->DC.CursorPos;
|
ImVec2 picker_pos = window->DC.CursorPos;
|
||||||
float square_sz = GetFrameHeight();
|
float square_sz = GetFrameHeight();
|
||||||
float bars_width = square_sz; // Arbitrary smallish width of Hue/Alpha picking bars
|
float bars_width = square_sz; // Arbitrary smallish width of Hue/Alpha picking bars
|
||||||
float sv_picker_size = ImMax(bars_width * 1, CalcItemWidth() - (alpha_bar ? 2 : 1) * (bars_width + style.ItemInnerSpacing.x)); // Saturation/Value picking box
|
float sv_picker_size = ImMax(bars_width * 1, GetNextItemWidth() - (alpha_bar ? 2 : 1) * (bars_width + style.ItemInnerSpacing.x)); // Saturation/Value picking box
|
||||||
float bar0_pos_x = picker_pos.x + sv_picker_size + style.ItemInnerSpacing.x;
|
float bar0_pos_x = picker_pos.x + sv_picker_size + style.ItemInnerSpacing.x;
|
||||||
float bar1_pos_x = bar0_pos_x + bars_width + style.ItemInnerSpacing.x;
|
float bar1_pos_x = bar0_pos_x + bars_width + style.ItemInnerSpacing.x;
|
||||||
float bars_triangles_half_sz = (float)(int)(bars_width * 0.20f);
|
float bars_triangles_half_sz = (float)(int)(bars_width * 0.20f);
|
||||||
@ -5078,7 +5085,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|||||||
// We vertically grow up to current line height up the typical widget height.
|
// We vertically grow up to current line height up the typical widget height.
|
||||||
const float text_base_offset_y = ImMax(padding.y, window->DC.CurrentLineTextBaseOffset); // Latch before ItemSize changes it
|
const float text_base_offset_y = ImMax(padding.y, window->DC.CurrentLineTextBaseOffset); // Latch before ItemSize changes it
|
||||||
const float frame_height = ImMax(ImMin(window->DC.CurrentLineSize.y, g.FontSize + style.FramePadding.y*2), label_size.y + padding.y*2);
|
const float frame_height = ImMax(ImMin(window->DC.CurrentLineSize.y, g.FontSize + style.FramePadding.y*2), label_size.y + padding.y*2);
|
||||||
ImRect frame_bb = ImRect(window->DC.CursorPos, ImVec2(window->Pos.x + GetContentRegionMax().x, window->DC.CursorPos.y + frame_height));
|
ImRect frame_bb = ImRect(window->DC.CursorPos, ImVec2(GetContentRegionMaxScreen().x, window->DC.CursorPos.y + frame_height));
|
||||||
if (display_frame)
|
if (display_frame)
|
||||||
{
|
{
|
||||||
// Framed header expand a little outside the default padding
|
// Framed header expand a little outside the default padding
|
||||||
@ -5461,6 +5468,9 @@ bool ImGui::Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags
|
|||||||
// - ListBoxHeader()
|
// - ListBoxHeader()
|
||||||
// - ListBoxFooter()
|
// - ListBoxFooter()
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
// FIXME: This is an old API. We should redesign some of it, rename ListBoxHeader->BeginListBox, ListBoxFooter->EndListBox
|
||||||
|
// and promote using them over existing ListBox() functions, similarly to change with combo boxes.
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
// FIXME: In principle this function should be called BeginListBox(). We should rename it after re-evaluating if we want to keep the same signature.
|
// FIXME: In principle this function should be called BeginListBox(). We should rename it after re-evaluating if we want to keep the same signature.
|
||||||
// Helper to calculate the size of a listbox and display a label on the right.
|
// Helper to calculate the size of a listbox and display a label on the right.
|
||||||
@ -5476,7 +5486,7 @@ bool ImGui::ListBoxHeader(const char* label, const ImVec2& size_arg)
|
|||||||
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||||
|
|
||||||
// Size default to hold ~7 items. Fractional number of items helps seeing that we can scroll down/up without looking at scrollbar.
|
// Size default to hold ~7 items. Fractional number of items helps seeing that we can scroll down/up without looking at scrollbar.
|
||||||
ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), GetTextLineHeightWithSpacing() * 7.4f + style.ItemSpacing.y);
|
ImVec2 size = CalcItemSize(size_arg, GetNextItemWidth(), GetTextLineHeightWithSpacing() * 7.4f + style.ItemSpacing.y);
|
||||||
ImVec2 frame_size = ImVec2(size.x, ImMax(size.y, label_size.y));
|
ImVec2 frame_size = ImVec2(size.x, ImMax(size.y, label_size.y));
|
||||||
ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size);
|
ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size);
|
||||||
ImRect bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
|
ImRect bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
|
||||||
@ -5593,7 +5603,7 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
|
|||||||
|
|
||||||
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||||
if (frame_size.x == 0.0f)
|
if (frame_size.x == 0.0f)
|
||||||
frame_size.x = CalcItemWidth();
|
frame_size.x = GetNextItemWidth();
|
||||||
if (frame_size.y == 0.0f)
|
if (frame_size.y == 0.0f)
|
||||||
frame_size.y = label_size.y + (style.FramePadding.y * 2);
|
frame_size.y = label_size.y + (style.FramePadding.y * 2);
|
||||||
|
|
||||||
@ -6506,7 +6516,7 @@ static ImU32 ImGui::TabBarCalcTabID(ImGuiTabBar* tab_bar, const char* label)
|
|||||||
{
|
{
|
||||||
if (tab_bar->Flags & ImGuiTabBarFlags_DockNode)
|
if (tab_bar->Flags & ImGuiTabBarFlags_DockNode)
|
||||||
{
|
{
|
||||||
ImGuiID id = ImHashStr(label, 0);
|
ImGuiID id = ImHashStr(label);
|
||||||
KeepAliveID(id);
|
KeepAliveID(id);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user