diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8f3eae1..47d6e87 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,4 @@
-image: swift:5.0
+image: swift:5.1.3
#variables:
# GIT_SUBMODULE_STRATEGY: recursive
diff --git a/3rdparty/cimgui b/3rdparty/cimgui
index 548716f..6114267 160000
--- a/3rdparty/cimgui
+++ b/3rdparty/cimgui
@@ -1 +1 @@
-Subproject commit 548716fab7abdf6732a69afa578b38f7158db858
+Subproject commit 6114267384b9af64ee250bf4ccfcaf9729316877
diff --git a/LICENSE b/LICENSE
index 363645e..60ff405 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2019 Christian Treffs
+Copyright (c) 2019-2020 Christian Treffs
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/Makefile b/Makefile
index a040940..5a788f9 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@ copyLibImGui:
cp $(imgui_src)/generator/output/cimgui.cpp $(c_imgui_src)
generateCInterface:
- cd $(imgui_src)/generator && luajit ./generator.lua clang sdl glfw glut metal
+ cd $(imgui_src)/generator && luajit ./generator.lua gcc true sdl glfw glut metal
buildCImGui: updateCLibImGui generateCInterface copyLibImGui
diff --git a/Package.swift b/Package.swift
index ab5f585..27c1d33 100644
--- a/Package.swift
+++ b/Package.swift
@@ -4,14 +4,9 @@ import PackageDescription
var package = Package(
name: "ImGui",
products: [
- // Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(name: "ImGui", targets: ["ImGui"]),
.library(name: "CImGui", targets: ["CImGui"])
],
- dependencies: [
- // Dependencies declare other packages that this package depends on.
- // .package(url: /* package url */, from: "1.0.0"),
- ],
targets: [
.target(name: "ImGui", dependencies: ["CImGui"]),
.target(name: "CImGui", path: "Sources/CImGui", cxxSettings: [.define("CIMGUI_DEFINE_ENUMS_AND_STRUCTS")]),
@@ -21,16 +16,10 @@ var package = Package(
cxxLanguageStandard: .cxx11
)
+package.products.append(.executable(name: "DemoMinimal", targets: ["DemoMinimal"]))
+package.targets.append(.target(name: "DemoMinimal", dependencies: ["ImGui"], path: "Sources/Demos/Minimal"))
+
#if canImport(Metal) && os(macOS)
-let metalDemo: (Product, Target) =
- (.executable(name: "DemoMetal-macOS", targets: ["DemoMetal"]),
- .target(name: "DemoMetal", dependencies: ["ImGui"], path: "Sources/Demos/Metal"))
-package.products.append(metalDemo.0)
-package.targets.append(metalDemo.1)
+package.products.append(.executable(name: "DemoMetal-macOS", targets: ["DemoMetal"]))
+package.targets.append(.target(name: "DemoMetal", dependencies: ["ImGui"], path: "Sources/Demos/Metal"))
#endif
-
-let minimumDemo: (Product, Target) =
-(.executable(name: "DemoMinimal", targets: ["DemoMinimal"]),
- .target(name: "DemoMinimal", dependencies: ["ImGui"], path: "Sources/Demos/Minimal"))
-package.products.append(minimumDemo.0)
-package.targets.append(minimumDemo.1)
diff --git a/README.md b/README.md
index 4b45b17..7a8fd62 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,12 @@
# Swift ImGui
[![Build Status](https://travis-ci.com/ctreffs/SwiftImGui.svg?branch=master)](https://travis-ci.com/ctreffs/SwiftImGui)
[![license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
-[![swift version](https://img.shields.io/badge/swift-5.0+-brightgreen.svg)](https://swift.org/download)
+[![swift version](https://img.shields.io/badge/swift-5.1+-brightgreen.svg)](https://swift.org/download)
[![platforms](https://img.shields.io/badge/platforms-%20macOS%20|%20iOS%20|%20tvOS-brightgreen.svg)](#)
[![platforms](https://img.shields.io/badge/platforms-linux-brightgreen.svg)](#)
-
+
This is a **lightweight**, **auto-generated** and **thin** Swift wrapper around the popular and excellent [**dear imgui**](https://github.com/ocornut/imgui) library.
@@ -26,19 +26,19 @@ These instructions will get your copy of the project up and running on your loca
### 💻 Installing
-Swift ImGui is available for all platforms that support [Swift 5.0](https://swift.org/) and higher and the [Swift Package Manager (SPM)](https://github.com/apple/swift-package-manager).
+Swift ImGui is available for all platforms that support [Swift 5.1](https://swift.org/) and higher and the [Swift Package Manager (SPM)](https://github.com/apple/swift-package-manager).
Extend the following lines in your `Package.swift` file or use it to create a new project.
```swift
-// swift-tools-version:5.0
+// swift-tools-version:5.1
import PackageDescription
let package = Package(
name: "YourPackageName",
dependencies: [
- .package(url: "https://github.com/ctreffs/SwiftImGui.git", from: "1.1.1")
+ .package(url: "https://github.com/ctreffs/SwiftImGui.git", from: "1.2.0")
],
targets: [
.target(
@@ -73,8 +73,10 @@ for n in 0..<20 {
io.pointee.DisplaySize = ImVec2(x: 1920, y: 1080)
io.pointee.DeltaTime = 1.0 / 60.0
ImGuiNewFrame()
+ var f: Float = 0.0
ImGuiTextV("Hello, world!")
- ImGuiSliderFloat("float", &f, 0.0, 1.0, nil, 1)
+ ImGuiSliderFloat("float", &f, 0.0, 1.0, "", 1)
+ ImGuiTextV("Application average %.3f ms/frame (%.1f FPS)", 1000.0 / io.pointee.Framerate, io.pointee.Framerate)
ImGuiShowDemoWindow(nil)
ImGuiRender()
}
@@ -84,37 +86,29 @@ ImGuiDestroyContext(ctx)
## 🆕 Update SwiftImGui
-SwiftImGui uses a multi-stage process to update to the latest imgui version.
-All necessary steps are provided in an automated fashion via a [`Makefile`](Makefile).
-Run the following commands in the repository's root directory:
-
-1. `make buildCImGui` - Update cimgui submodule && generate C interface
-2. `make wrapLibImGui` - Update SwiftImGui && auto-wrap C interface
-
+SwiftImGui uses a mutli-stage process to update to the latest imgui version. See [HOWTO.md](docs/HOWTO.md) for details.
## 💁 Help needed
-This project is in an early stage and needs a lot of love.
-If you are interested in contributing, please feel free to do so!
+This project needs a lot of love.
+If you are interested in contributing please feel free to do so!
-Things that need to be done are, among others:
+Things that need to be done among others are:
-- [ ] Extend the AutoWrapper to wrap more cimgui functions (currently there are 55 'invalid' functions that will not be wrapped; 543 will be wrapped properly)
+- [ ] Extend the AutoWrapper to wrap more cimgui functions (currently there are 81 'invalid' functions that will not be wrapped. 799 will be wrapped properly.)
- [ ] Some vector functions are not available via the c interface - see `Sources/AutoWrapper/Exceptions.swift`
-- [ ] Find a way to automate the remaining necessary manual adjustments in the cimgui generator template
-- [ ] Support for [Cocoapods](https://cocoapods.org) packaging
-- [ ] Support for [Carthage](https://github.com/Carthage/Carthage) packaging
-- [ ] Write some additional tests to improve coverage
+- [ ] Find a solution for manual adjustments in cimgui generator template
+- [ ] Write some more tests
## 🏷️ Versioning
-We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](/releases).
+We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [releases on this repository](https://github.com/ctreffs/SwiftImGui/releases).
## ✍️ Authors
* [Christian Treffs](https://github.com/ctreffs)
-See also the list of [contributors](https://github.com/ctreffs/SwiftImGui/contributors) who participated in this project.
+See also the list of [contributors](https://github.com/ctreffs/SwiftImGui/graphs/contributors) who participated in this project.
## 🔏 Licenses
diff --git a/Sources/AutoWrapper/DataType.swift b/Sources/AutoWrapper/DataType.swift
index b3bc550..0331759 100644
--- a/Sources/AutoWrapper/DataType.swift
+++ b/Sources/AutoWrapper/DataType.swift
@@ -157,9 +157,12 @@ public struct DataType: Decodable {
// const char* -> String
return toWrap
- case .pointer where isConst == false && type == .char:
- // char* -> String
+ case .pointer where isConst == false && type == .char && context != .ret:
+ // char* -> inout String
return "inout \(toWrap)"
+ case .pointer where isConst == false && type == .char && context == .ret:
+ // char* -> String
+ return "\(toWrap)"
case .pointer where isConst == true && type == .void:
return "UnsafeRawPointer!"
case .pointer where isConst == false && type == .void:
diff --git a/Sources/AutoWrapper/Definitions.swift b/Sources/AutoWrapper/Definitions.swift
index 340d426..2b7bc8b 100644
--- a/Sources/AutoWrapper/Definitions.swift
+++ b/Sources/AutoWrapper/Definitions.swift
@@ -47,28 +47,26 @@ public struct FunctionDef: Decodable {
}
public var encodedFuncname: String {
- guard let range = ov_cimguiname.range(of: funcname) else {
+ guard let range = ov_cimguiname.range(of: funcname), !range.isEmpty else {
assertionFailure("Original name should contain funcname")
return funcname
}
- let name: String = funcname.components(separatedBy: "_")
- .map {
- // uppercase first character
- $0.replacingCharacters(in: $0.startIndex..<$0.index(after: $0.startIndex), with: $0.prefix(1).uppercased())
- }
- .joined()
-
- let prefix: String
- let suffix = String(ov_cimguiname[range.upperBound.. = [
+ "ImChunkStream_clear",
+ "ImChunkStream_empty",
+ "ImChunkStream_size",
+ "ImPool_Clear",
+ "ImPool_GetSize",
+ "ImPool_RemovePoolIdx",
+ "ImPool_Reserve",
+ "ImVector__grow_capacity",
"ImVector_capacity",
"ImVector_clear",
"ImVector_empty",
- "ImVector__grow_capacity",
"ImVector_pop_back",
"ImVector_reserve",
- "ImVector_resize",
+ "ImVector_resizeNil",
+ "ImVector_shrink",
"ImVector_size",
"ImVector_size_in_bytes",
- "ImVector_swap"
+ "ImVector_swap",
+ "igImFontAtlasBuildMultiplyRectAlpha8",
+ "igImFontAtlasBuildMultiplyCalcLookupTable",
+ "igImTriangleBarycentricCoords"
]
/// causes "Use of undeclared type '...'" compiler error.
public static let undeclardTypes: [String: Declaration] = [
- "ImGuiContext": Declaration(name: "ImGuiContext", typealiasType: "OpaquePointer"),
- "ImDrawListSharedData": Declaration(name: "ImDrawListSharedData", typealiasType: "OpaquePointer")
+ "ImChunkStream": Declaration(name: "ImChunkStream", typealiasType: "OpaquePointer"),
+ "ImPool": Declaration(name: "ImPool", typealiasType: "OpaquePointer")
+ ]
+
+ public static let stripPrefix: Set = [
+ "ig"
]
}
diff --git a/Sources/AutoWrapper/FunctionBodyRenderer.swift b/Sources/AutoWrapper/FunctionBodyRenderer.swift
index da3e032..22fabf8 100644
--- a/Sources/AutoWrapper/FunctionBodyRenderer.swift
+++ b/Sources/AutoWrapper/FunctionBodyRenderer.swift
@@ -101,7 +101,7 @@ struct FunctionBodyRenderer {
return [.line("&\(arg.escapedName)")]
case let .arrayFixedSize(count) where arg.type.isConst == false:
- if arg.type.type.isNumber && count < 5 {
+ if arg.type.type.isNumber && count < 5 || arg.type.type == .custom("ImVec2") {
// SIMD vector
return [
.preLine("withUnsafeMutablePointer(to: &\(arg.escapedName)) { \(arg.name)MutPtr in"),
diff --git a/Sources/CImGui/cimgui.cpp b/Sources/CImGui/cimgui.cpp
index 600fa92..abaca4c 100644
--- a/Sources/CImGui/cimgui.cpp
+++ b/Sources/CImGui/cimgui.cpp
@@ -1,5 +1,6 @@
//This file is automatically generated by generator.lua from https://github.com/cimgui/cimgui
-//based on imgui.h file version "1.74 WIP" from Dear ImGui https://github.com/ocornut/imgui
+//based on imgui.h file version "1.76" from Dear ImGui https://github.com/ocornut/imgui
+//with imgui_internal.h api
#include "./imgui/imgui.h"
#include "./imgui/imgui_internal.h"
@@ -7,7 +8,7 @@
-CIMGUI_API ImVec2* ImVec2_ImVec2(void)
+CIMGUI_API ImVec2* ImVec2_ImVec2Nil(void)
{
return IM_NEW(ImVec2)();
}
@@ -19,7 +20,7 @@ CIMGUI_API ImVec2* ImVec2_ImVec2Float(float _x,float _y)
{
return IM_NEW(ImVec2)(_x,_y);
}
-CIMGUI_API ImVec4* ImVec4_ImVec4(void)
+CIMGUI_API ImVec4* ImVec4_ImVec4Nil(void)
{
return IM_NEW(ImVec4)();
}
@@ -47,10 +48,6 @@ CIMGUI_API void igSetCurrentContext(ImGuiContext* ctx)
{
return ImGui::SetCurrentContext(ctx);
}
-CIMGUI_API bool igDebugCheckVersionAndDataLayout(const char* version_str,size_t sz_io,size_t sz_style,size_t sz_vec2,size_t sz_vec4,size_t sz_drawvert,size_t sz_drawidx)
-{
- return ImGui::DebugCheckVersionAndDataLayout(version_str,sz_io,sz_style,sz_vec2,sz_vec4,sz_drawvert,sz_drawidx);
-}
CIMGUI_API ImGuiIO* igGetIO()
{
return &ImGui::GetIO();
@@ -127,7 +124,7 @@ CIMGUI_API void igEnd()
{
return ImGui::End();
}
-CIMGUI_API bool igBeginChild(const char* str_id,const ImVec2 size,bool border,ImGuiWindowFlags flags)
+CIMGUI_API bool igBeginChildStr(const char* str_id,const ImVec2 size,bool border,ImGuiWindowFlags flags)
{
return ImGui::BeginChild(str_id,size,border,flags);
}
@@ -159,21 +156,13 @@ CIMGUI_API ImDrawList* igGetWindowDrawList()
{
return ImGui::GetWindowDrawList();
}
-CIMGUI_API float igGetWindowDpiScale()
-{
- return ImGui::GetWindowDpiScale();
-}
-CIMGUI_API ImGuiViewport* igGetWindowViewport()
-{
- return ImGui::GetWindowViewport();
-}
-CIMGUI_API ImVec2 igGetWindowPos()
+CIMGUI_API void igGetWindowPos(ImVec2 *pOut)
{
- return ImGui::GetWindowPos();
+ *pOut = ImGui::GetWindowPos();
}
-CIMGUI_API ImVec2 igGetWindowSize()
+CIMGUI_API void igGetWindowSize(ImVec2 *pOut)
{
- return ImGui::GetWindowSize();
+ *pOut = ImGui::GetWindowSize();
}
CIMGUI_API float igGetWindowWidth()
{
@@ -211,10 +200,6 @@ CIMGUI_API void igSetNextWindowBgAlpha(float alpha)
{
return ImGui::SetNextWindowBgAlpha(alpha);
}
-CIMGUI_API void igSetNextWindowViewport(ImGuiID viewport_id)
-{
- return ImGui::SetNextWindowViewport(viewport_id);
-}
CIMGUI_API void igSetWindowPosVec2(const ImVec2 pos,ImGuiCond cond)
{
return ImGui::SetWindowPos(pos,cond);
@@ -227,7 +212,7 @@ CIMGUI_API void igSetWindowCollapsedBool(bool collapsed,ImGuiCond cond)
{
return ImGui::SetWindowCollapsed(collapsed,cond);
}
-CIMGUI_API void igSetWindowFocus()
+CIMGUI_API void igSetWindowFocusNil()
{
return ImGui::SetWindowFocus();
}
@@ -251,21 +236,21 @@ CIMGUI_API void igSetWindowFocusStr(const char* name)
{
return ImGui::SetWindowFocus(name);
}
-CIMGUI_API ImVec2 igGetContentRegionMax()
+CIMGUI_API void igGetContentRegionMax(ImVec2 *pOut)
{
- return ImGui::GetContentRegionMax();
+ *pOut = ImGui::GetContentRegionMax();
}
-CIMGUI_API ImVec2 igGetContentRegionAvail()
+CIMGUI_API void igGetContentRegionAvail(ImVec2 *pOut)
{
- return ImGui::GetContentRegionAvail();
+ *pOut = ImGui::GetContentRegionAvail();
}
-CIMGUI_API ImVec2 igGetWindowContentRegionMin()
+CIMGUI_API void igGetWindowContentRegionMin(ImVec2 *pOut)
{
- return ImGui::GetWindowContentRegionMin();
+ *pOut = ImGui::GetWindowContentRegionMin();
}
-CIMGUI_API ImVec2 igGetWindowContentRegionMax()
+CIMGUI_API void igGetWindowContentRegionMax(ImVec2 *pOut)
{
- return ImGui::GetWindowContentRegionMax();
+ *pOut = ImGui::GetWindowContentRegionMax();
}
CIMGUI_API float igGetWindowContentRegionWidth()
{
@@ -287,11 +272,11 @@ CIMGUI_API float igGetScrollMaxY()
{
return ImGui::GetScrollMaxY();
}
-CIMGUI_API void igSetScrollX(float scroll_x)
+CIMGUI_API void igSetScrollXFloat(float scroll_x)
{
return ImGui::SetScrollX(scroll_x);
}
-CIMGUI_API void igSetScrollY(float scroll_y)
+CIMGUI_API void igSetScrollYFloat(float scroll_y)
{
return ImGui::SetScrollY(scroll_y);
}
@@ -303,11 +288,11 @@ CIMGUI_API void igSetScrollHereY(float center_y_ratio)
{
return ImGui::SetScrollHereY(center_y_ratio);
}
-CIMGUI_API void igSetScrollFromPosX(float local_x,float center_x_ratio)
+CIMGUI_API void igSetScrollFromPosXFloat(float local_x,float center_x_ratio)
{
return ImGui::SetScrollFromPosX(local_x,center_x_ratio);
}
-CIMGUI_API void igSetScrollFromPosY(float local_y,float center_y_ratio)
+CIMGUI_API void igSetScrollFromPosYFloat(float local_y,float center_y_ratio)
{
return ImGui::SetScrollFromPosY(local_y,center_y_ratio);
}
@@ -323,7 +308,7 @@ CIMGUI_API void igPushStyleColorU32(ImGuiCol idx,ImU32 col)
{
return ImGui::PushStyleColor(idx,col);
}
-CIMGUI_API void igPushStyleColor(ImGuiCol idx,const ImVec4 col)
+CIMGUI_API void igPushStyleColorVec4(ImGuiCol idx,const ImVec4 col)
{
return ImGui::PushStyleColor(idx,col);
}
@@ -355,11 +340,11 @@ CIMGUI_API float igGetFontSize()
{
return ImGui::GetFontSize();
}
-CIMGUI_API ImVec2 igGetFontTexUvWhitePixel()
+CIMGUI_API void igGetFontTexUvWhitePixel(ImVec2 *pOut)
{
- return ImGui::GetFontTexUvWhitePixel();
+ *pOut = ImGui::GetFontTexUvWhitePixel();
}
-CIMGUI_API ImU32 igGetColorU32(ImGuiCol idx,float alpha_mul)
+CIMGUI_API ImU32 igGetColorU32Col(ImGuiCol idx,float alpha_mul)
{
return ImGui::GetColorU32(idx,alpha_mul);
}
@@ -447,9 +432,9 @@ CIMGUI_API void igEndGroup()
{
return ImGui::EndGroup();
}
-CIMGUI_API ImVec2 igGetCursorPos()
+CIMGUI_API void igGetCursorPos(ImVec2 *pOut)
{
- return ImGui::GetCursorPos();
+ *pOut = ImGui::GetCursorPos();
}
CIMGUI_API float igGetCursorPosX()
{
@@ -471,13 +456,13 @@ CIMGUI_API void igSetCursorPosY(float local_y)
{
return ImGui::SetCursorPosY(local_y);
}
-CIMGUI_API ImVec2 igGetCursorStartPos()
+CIMGUI_API void igGetCursorStartPos(ImVec2 *pOut)
{
- return ImGui::GetCursorStartPos();
+ *pOut = ImGui::GetCursorStartPos();
}
-CIMGUI_API ImVec2 igGetCursorScreenPos()
+CIMGUI_API void igGetCursorScreenPos(ImVec2 *pOut)
{
- return ImGui::GetCursorScreenPos();
+ *pOut = ImGui::GetCursorScreenPos();
}
CIMGUI_API void igSetCursorScreenPos(const ImVec2 pos)
{
@@ -507,7 +492,7 @@ CIMGUI_API void igPushIDStr(const char* str_id)
{
return ImGui::PushID(str_id);
}
-CIMGUI_API void igPushIDRange(const char* str_id_begin,const char* str_id_end)
+CIMGUI_API void igPushIDStrStr(const char* str_id_begin,const char* str_id_end)
{
return ImGui::PushID(str_id_begin,str_id_end);
}
@@ -527,7 +512,7 @@ CIMGUI_API ImGuiID igGetIDStr(const char* str_id)
{
return ImGui::GetID(str_id);
}
-CIMGUI_API ImGuiID igGetIDRange(const char* str_id_begin,const char* str_id_end)
+CIMGUI_API ImGuiID igGetIDStrStr(const char* str_id_begin,const char* str_id_end)
{
return ImGui::GetID(str_id_begin,str_id_end);
}
@@ -661,7 +646,7 @@ CIMGUI_API void igEndCombo()
{
return ImGui::EndCombo();
}
-CIMGUI_API bool igCombo(const char* label,int* current_item,const char* const items[],int items_count,int popup_max_height_in_items)
+CIMGUI_API bool igComboStr_arr(const char* label,int* current_item,const char* const items[],int items_count,int popup_max_height_in_items)
{
return ImGui::Combo(label,current_item,items,items_count,popup_max_height_in_items);
}
@@ -929,7 +914,7 @@ CIMGUI_API float igGetTreeNodeToLabelSpacing()
{
return ImGui::GetTreeNodeToLabelSpacing();
}
-CIMGUI_API bool igCollapsingHeader(const char* label,ImGuiTreeNodeFlags flags)
+CIMGUI_API bool igCollapsingHeaderTreeNodeFlags(const char* label,ImGuiTreeNodeFlags flags)
{
return ImGui::CollapsingHeader(label,flags);
}
@@ -941,7 +926,7 @@ CIMGUI_API void igSetNextItemOpen(bool is_open,ImGuiCond cond)
{
return ImGui::SetNextItemOpen(is_open,cond);
}
-CIMGUI_API bool igSelectable(const char* label,bool selected,ImGuiSelectableFlags flags,const ImVec2 size)
+CIMGUI_API bool igSelectableBool(const char* label,bool selected,ImGuiSelectableFlags flags,const ImVec2 size)
{
return ImGui::Selectable(label,selected,flags,size);
}
@@ -969,7 +954,7 @@ CIMGUI_API void igListBoxFooter()
{
return ImGui::ListBoxFooter();
}
-CIMGUI_API void igPlotLines(const char* label,const float* values,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size,int stride)
+CIMGUI_API void igPlotLinesFloatPtr(const char* label,const float* values,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size,int stride)
{
return ImGui::PlotLines(label,values,values_count,values_offset,overlay_text,scale_min,scale_max,graph_size,stride);
}
@@ -1001,14 +986,6 @@ CIMGUI_API void igValueFloat(const char* prefix,float v,const char* float_format
{
return ImGui::Value(prefix,v,float_format);
}
-CIMGUI_API bool igBeginMainMenuBar()
-{
- return ImGui::BeginMainMenuBar();
-}
-CIMGUI_API void igEndMainMenuBar()
-{
- return ImGui::EndMainMenuBar();
-}
CIMGUI_API bool igBeginMenuBar()
{
return ImGui::BeginMenuBar();
@@ -1017,6 +994,14 @@ CIMGUI_API void igEndMenuBar()
{
return ImGui::EndMenuBar();
}
+CIMGUI_API bool igBeginMainMenuBar()
+{
+ return ImGui::BeginMainMenuBar();
+}
+CIMGUI_API void igEndMainMenuBar()
+{
+ return ImGui::EndMainMenuBar();
+}
CIMGUI_API bool igBeginMenu(const char* label,bool enabled)
{
return ImGui::BeginMenu(label,enabled);
@@ -1060,15 +1045,15 @@ CIMGUI_API bool igBeginPopup(const char* str_id,ImGuiWindowFlags flags)
{
return ImGui::BeginPopup(str_id,flags);
}
-CIMGUI_API bool igBeginPopupContextItem(const char* str_id,int mouse_button)
+CIMGUI_API bool igBeginPopupContextItem(const char* str_id,ImGuiMouseButton mouse_button)
{
return ImGui::BeginPopupContextItem(str_id,mouse_button);
}
-CIMGUI_API bool igBeginPopupContextWindow(const char* str_id,int mouse_button,bool also_over_items)
+CIMGUI_API bool igBeginPopupContextWindow(const char* str_id,ImGuiMouseButton mouse_button,bool also_over_items)
{
return ImGui::BeginPopupContextWindow(str_id,mouse_button,also_over_items);
}
-CIMGUI_API bool igBeginPopupContextVoid(const char* str_id,int mouse_button)
+CIMGUI_API bool igBeginPopupContextVoid(const char* str_id,ImGuiMouseButton mouse_button)
{
return ImGui::BeginPopupContextVoid(str_id,mouse_button);
}
@@ -1080,11 +1065,11 @@ CIMGUI_API void igEndPopup()
{
return ImGui::EndPopup();
}
-CIMGUI_API bool igOpenPopupOnItemClick(const char* str_id,int mouse_button)
+CIMGUI_API bool igOpenPopupOnItemClick(const char* str_id,ImGuiMouseButton mouse_button)
{
return ImGui::OpenPopupOnItemClick(str_id,mouse_button);
}
-CIMGUI_API bool igIsPopupOpen(const char* str_id)
+CIMGUI_API bool igIsPopupOpenStr(const char* str_id)
{
return ImGui::IsPopupOpen(str_id);
}
@@ -1144,30 +1129,6 @@ CIMGUI_API void igSetTabItemClosed(const char* tab_or_docked_window_label)
{
return ImGui::SetTabItemClosed(tab_or_docked_window_label);
}
-CIMGUI_API void igDockSpace(ImGuiID id,const ImVec2 size,ImGuiDockNodeFlags flags,const ImGuiWindowClass* window_class)
-{
- return ImGui::DockSpace(id,size,flags,window_class);
-}
-CIMGUI_API ImGuiID igDockSpaceOverViewport(ImGuiViewport* viewport,ImGuiDockNodeFlags flags,const ImGuiWindowClass* window_class)
-{
- return ImGui::DockSpaceOverViewport(viewport,flags,window_class);
-}
-CIMGUI_API void igSetNextWindowDockID(ImGuiID dock_id,ImGuiCond cond)
-{
- return ImGui::SetNextWindowDockID(dock_id,cond);
-}
-CIMGUI_API void igSetNextWindowClass(const ImGuiWindowClass* window_class)
-{
- return ImGui::SetNextWindowClass(window_class);
-}
-CIMGUI_API ImGuiID igGetWindowDockID()
-{
- return ImGui::GetWindowDockID();
-}
-CIMGUI_API bool igIsWindowDocked()
-{
- return ImGui::IsWindowDocked();
-}
CIMGUI_API void igLogToTTY(int auto_open_depth)
{
return ImGui::LogToTTY(auto_open_depth);
@@ -1244,7 +1205,7 @@ CIMGUI_API bool igIsItemFocused()
{
return ImGui::IsItemFocused();
}
-CIMGUI_API bool igIsItemClicked(int mouse_button)
+CIMGUI_API bool igIsItemClicked(ImGuiMouseButton mouse_button)
{
return ImGui::IsItemClicked(mouse_button);
}
@@ -1268,6 +1229,10 @@ CIMGUI_API bool igIsItemDeactivatedAfterEdit()
{
return ImGui::IsItemDeactivatedAfterEdit();
}
+CIMGUI_API bool igIsItemToggledOpen()
+{
+ return ImGui::IsItemToggledOpen();
+}
CIMGUI_API bool igIsAnyItemHovered()
{
return ImGui::IsAnyItemHovered();
@@ -1280,23 +1245,23 @@ CIMGUI_API bool igIsAnyItemFocused()
{
return ImGui::IsAnyItemFocused();
}
-CIMGUI_API ImVec2 igGetItemRectMin()
+CIMGUI_API void igGetItemRectMin(ImVec2 *pOut)
{
- return ImGui::GetItemRectMin();
+ *pOut = ImGui::GetItemRectMin();
}
-CIMGUI_API ImVec2 igGetItemRectMax()
+CIMGUI_API void igGetItemRectMax(ImVec2 *pOut)
{
- return ImGui::GetItemRectMax();
+ *pOut = ImGui::GetItemRectMax();
}
-CIMGUI_API ImVec2 igGetItemRectSize()
+CIMGUI_API void igGetItemRectSize(ImVec2 *pOut)
{
- return ImGui::GetItemRectSize();
+ *pOut = ImGui::GetItemRectSize();
}
CIMGUI_API void igSetItemAllowOverlap()
{
return ImGui::SetItemAllowOverlap();
}
-CIMGUI_API bool igIsRectVisible(const ImVec2 size)
+CIMGUI_API bool igIsRectVisibleNil(const ImVec2 size)
{
return ImGui::IsRectVisible(size);
}
@@ -1316,18 +1281,10 @@ CIMGUI_API ImDrawList* igGetBackgroundDrawList()
{
return ImGui::GetBackgroundDrawList();
}
-CIMGUI_API ImDrawList* igGetForegroundDrawList()
+CIMGUI_API ImDrawList* igGetForegroundDrawListNil()
{
return ImGui::GetForegroundDrawList();
}
-CIMGUI_API ImDrawList* igGetBackgroundDrawListViewportPtr(ImGuiViewport* viewport)
-{
- return ImGui::GetBackgroundDrawList(viewport);
-}
-CIMGUI_API ImDrawList* igGetForegroundDrawListViewportPtr(ImGuiViewport* viewport)
-{
- return ImGui::GetForegroundDrawList(viewport);
-}
CIMGUI_API ImDrawListSharedData* igGetDrawListSharedData()
{
return ImGui::GetDrawListSharedData();
@@ -1344,10 +1301,6 @@ CIMGUI_API ImGuiStorage* igGetStateStorage()
{
return ImGui::GetStateStorage();
}
-CIMGUI_API ImVec2 igCalcTextSize(const char* text,const char* text_end,bool hide_text_after_double_hash,float wrap_width)
-{
- return ImGui::CalcTextSize(text,text_end,hide_text_after_double_hash,wrap_width);
-}
CIMGUI_API void igCalcListClipping(int items_count,float items_height,int* out_items_display_start,int* out_items_display_end)
{
return ImGui::CalcListClipping(items_count,items_height,out_items_display_start,out_items_display_end);
@@ -1360,9 +1313,13 @@ CIMGUI_API void igEndChildFrame()
{
return ImGui::EndChildFrame();
}
-CIMGUI_API ImVec4 igColorConvertU32ToFloat4(ImU32 in)
+CIMGUI_API void igCalcTextSize(ImVec2 *pOut,const char* text,const char* text_end,bool hide_text_after_double_hash,float wrap_width)
+{
+ *pOut = ImGui::CalcTextSize(text,text_end,hide_text_after_double_hash,wrap_width);
+}
+CIMGUI_API void igColorConvertU32ToFloat4(ImVec4 *pOut,ImU32 in)
{
- return ImGui::ColorConvertU32ToFloat4(in);
+ *pOut = ImGui::ColorConvertU32ToFloat4(in);
}
CIMGUI_API ImU32 igColorConvertFloat4ToU32(const ImVec4 in)
{
@@ -1388,29 +1345,25 @@ CIMGUI_API int igGetKeyPressedAmount(int key_index,float repeat_delay,float rate
{
return ImGui::GetKeyPressedAmount(key_index,repeat_delay,rate);
}
-CIMGUI_API bool igIsMouseDown(int button)
+CIMGUI_API void igCaptureKeyboardFromApp(bool want_capture_keyboard_value)
{
- return ImGui::IsMouseDown(button);
+ return ImGui::CaptureKeyboardFromApp(want_capture_keyboard_value);
}
-CIMGUI_API bool igIsAnyMouseDown()
+CIMGUI_API bool igIsMouseDown(ImGuiMouseButton button)
{
- return ImGui::IsAnyMouseDown();
+ return ImGui::IsMouseDown(button);
}
-CIMGUI_API bool igIsMouseClicked(int button,bool repeat)
+CIMGUI_API bool igIsMouseClicked(ImGuiMouseButton button,bool repeat)
{
return ImGui::IsMouseClicked(button,repeat);
}
-CIMGUI_API bool igIsMouseDoubleClicked(int button)
-{
- return ImGui::IsMouseDoubleClicked(button);
-}
-CIMGUI_API bool igIsMouseReleased(int button)
+CIMGUI_API bool igIsMouseReleased(ImGuiMouseButton button)
{
return ImGui::IsMouseReleased(button);
}
-CIMGUI_API bool igIsMouseDragging(int button,float lock_threshold)
+CIMGUI_API bool igIsMouseDoubleClicked(ImGuiMouseButton button)
{
- return ImGui::IsMouseDragging(button,lock_threshold);
+ return ImGui::IsMouseDoubleClicked(button);
}
CIMGUI_API bool igIsMouseHoveringRect(const ImVec2 r_min,const ImVec2 r_max,bool clip)
{
@@ -1420,19 +1373,27 @@ CIMGUI_API bool igIsMousePosValid(const ImVec2* mouse_pos)
{
return ImGui::IsMousePosValid(mouse_pos);
}
-CIMGUI_API ImVec2 igGetMousePos()
+CIMGUI_API bool igIsAnyMouseDown()
+{
+ return ImGui::IsAnyMouseDown();
+}
+CIMGUI_API void igGetMousePos(ImVec2 *pOut)
+{
+ *pOut = ImGui::GetMousePos();
+}
+CIMGUI_API void igGetMousePosOnOpeningCurrentPopup(ImVec2 *pOut)
{
- return ImGui::GetMousePos();
+ *pOut = ImGui::GetMousePosOnOpeningCurrentPopup();
}
-CIMGUI_API ImVec2 igGetMousePosOnOpeningCurrentPopup()
+CIMGUI_API bool igIsMouseDragging(ImGuiMouseButton button,float lock_threshold)
{
- return ImGui::GetMousePosOnOpeningCurrentPopup();
+ return ImGui::IsMouseDragging(button,lock_threshold);
}
-CIMGUI_API ImVec2 igGetMouseDragDelta(int button,float lock_threshold)
+CIMGUI_API void igGetMouseDragDelta(ImVec2 *pOut,ImGuiMouseButton button,float lock_threshold)
{
- return ImGui::GetMouseDragDelta(button,lock_threshold);
+ *pOut = ImGui::GetMouseDragDelta(button,lock_threshold);
}
-CIMGUI_API void igResetMouseDragDelta(int button)
+CIMGUI_API void igResetMouseDragDelta(ImGuiMouseButton button)
{
return ImGui::ResetMouseDragDelta(button);
}
@@ -1440,13 +1401,9 @@ CIMGUI_API ImGuiMouseCursor igGetMouseCursor()
{
return ImGui::GetMouseCursor();
}
-CIMGUI_API void igSetMouseCursor(ImGuiMouseCursor type)
+CIMGUI_API void igSetMouseCursor(ImGuiMouseCursor cursor_type)
{
- return ImGui::SetMouseCursor(type);
-}
-CIMGUI_API void igCaptureKeyboardFromApp(bool want_capture_keyboard_value)
-{
- return ImGui::CaptureKeyboardFromApp(want_capture_keyboard_value);
+ return ImGui::SetMouseCursor(cursor_type);
}
CIMGUI_API void igCaptureMouseFromApp(bool want_capture_mouse_value)
{
@@ -1476,6 +1433,10 @@ CIMGUI_API const char* igSaveIniSettingsToMemory(size_t* out_ini_size)
{
return ImGui::SaveIniSettingsToMemory(out_ini_size);
}
+CIMGUI_API bool igDebugCheckVersionAndDataLayout(const char* version_str,size_t sz_io,size_t sz_style,size_t sz_vec2,size_t sz_vec4,size_t sz_drawvert,size_t sz_drawidx)
+{
+ return ImGui::DebugCheckVersionAndDataLayout(version_str,sz_io,sz_style,sz_vec2,sz_vec4,sz_drawvert,sz_drawidx);
+}
CIMGUI_API void igSetAllocatorFunctions(void*(*alloc_func)(size_t sz,void* user_data),void(*free_func)(void* ptr,void* user_data),void* user_data)
{
return ImGui::SetAllocatorFunctions(alloc_func,free_func,user_data);
@@ -1488,34 +1449,6 @@ CIMGUI_API void igMemFree(void* ptr)
{
return ImGui::MemFree(ptr);
}
-CIMGUI_API ImGuiPlatformIO* igGetPlatformIO()
-{
- return &ImGui::GetPlatformIO();
-}
-CIMGUI_API ImGuiViewport* igGetMainViewport()
-{
- return ImGui::GetMainViewport();
-}
-CIMGUI_API void igUpdatePlatformWindows()
-{
- return ImGui::UpdatePlatformWindows();
-}
-CIMGUI_API void igRenderPlatformWindowsDefault(void* platform_arg,void* renderer_arg)
-{
- return ImGui::RenderPlatformWindowsDefault(platform_arg,renderer_arg);
-}
-CIMGUI_API void igDestroyPlatformWindows()
-{
- return ImGui::DestroyPlatformWindows();
-}
-CIMGUI_API ImGuiViewport* igFindViewportByID(ImGuiID id)
-{
- return ImGui::FindViewportByID(id);
-}
-CIMGUI_API ImGuiViewport* igFindViewportByPlatformHandle(void* platform_handle)
-{
- return ImGui::FindViewportByPlatformHandle(platform_handle);
-}
CIMGUI_API ImGuiStyle* ImGuiStyle_ImGuiStyle(void)
{
return IM_NEW(ImGuiStyle)();
@@ -1532,6 +1465,10 @@ CIMGUI_API void ImGuiIO_AddInputCharacter(ImGuiIO* self,unsigned int c)
{
return self->AddInputCharacter(c);
}
+CIMGUI_API void ImGuiIO_AddInputCharacterUTF16(ImGuiIO* self,ImWchar16 c)
+{
+ return self->AddInputCharacterUTF16(c);
+}
CIMGUI_API void ImGuiIO_AddInputCharactersUTF8(ImGuiIO* self,const char* str)
{
return self->AddInputCharactersUTF8(str);
@@ -1568,14 +1505,6 @@ CIMGUI_API bool ImGuiInputTextCallbackData_HasSelection(ImGuiInputTextCallbackDa
{
return self->HasSelection();
}
-CIMGUI_API ImGuiWindowClass* ImGuiWindowClass_ImGuiWindowClass(void)
-{
- return IM_NEW(ImGuiWindowClass)();
-}
-CIMGUI_API void ImGuiWindowClass_destroy(ImGuiWindowClass* self)
-{
- IM_DELETE(self);
-}
CIMGUI_API ImGuiPayload* ImGuiPayload_ImGuiPayload(void)
{
return IM_NEW(ImGuiPayload)();
@@ -1636,7 +1565,7 @@ CIMGUI_API bool ImGuiTextFilter_IsActive(ImGuiTextFilter* self)
{
return self->IsActive();
}
-CIMGUI_API ImGuiTextRange* ImGuiTextRange_ImGuiTextRange(void)
+CIMGUI_API ImGuiTextRange* ImGuiTextRange_ImGuiTextRangeNil(void)
{
return IM_NEW(ImGuiTextRange)();
}
@@ -1796,7 +1725,7 @@ CIMGUI_API void ImGuiListClipper_End(ImGuiListClipper* self)
{
return self->End();
}
-CIMGUI_API ImColor* ImColor_ImColor(void)
+CIMGUI_API ImColor* ImColor_ImColorNil(void)
{
return IM_NEW(ImColor)();
}
@@ -1824,9 +1753,9 @@ CIMGUI_API void ImColor_SetHSV(ImColor* self,float h,float s,float v,float a)
{
return self->SetHSV(h,s,v,a);
}
-CIMGUI_API ImColor ImColor_HSV(ImColor* self,float h,float s,float v,float a)
+CIMGUI_API void ImColor_HSV(ImColor *pOut,ImColor* self,float h,float s,float v,float a)
{
- return self->HSV(h,s,v,a);
+ *pOut = self->HSV(h,s,v,a);
}
CIMGUI_API ImDrawCmd* ImDrawCmd_ImDrawCmd(void)
{
@@ -1892,13 +1821,13 @@ CIMGUI_API void ImDrawList_PopTextureID(ImDrawList* self)
{
return self->PopTextureID();
}
-CIMGUI_API ImVec2 ImDrawList_GetClipRectMin(ImDrawList* self)
+CIMGUI_API void ImDrawList_GetClipRectMin(ImVec2 *pOut,ImDrawList* self)
{
- return self->GetClipRectMin();
+ *pOut = self->GetClipRectMin();
}
-CIMGUI_API ImVec2 ImDrawList_GetClipRectMax(ImDrawList* self)
+CIMGUI_API void ImDrawList_GetClipRectMax(ImVec2 *pOut,ImDrawList* self)
{
- return self->GetClipRectMax();
+ *pOut = self->GetClipRectMax();
}
CIMGUI_API void ImDrawList_AddLine(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,ImU32 col,float thickness)
{
@@ -1940,7 +1869,15 @@ CIMGUI_API void ImDrawList_AddCircleFilled(ImDrawList* self,const ImVec2 center,
{
return self->AddCircleFilled(center,radius,col,num_segments);
}
-CIMGUI_API void ImDrawList_AddText(ImDrawList* self,const ImVec2 pos,ImU32 col,const char* text_begin,const char* text_end)
+CIMGUI_API void ImDrawList_AddNgon(ImDrawList* self,const ImVec2 center,float radius,ImU32 col,int num_segments,float thickness)
+{
+ return self->AddNgon(center,radius,col,num_segments,thickness);
+}
+CIMGUI_API void ImDrawList_AddNgonFilled(ImDrawList* self,const ImVec2 center,float radius,ImU32 col,int num_segments)
+{
+ return self->AddNgonFilled(center,radius,col,num_segments);
+}
+CIMGUI_API void ImDrawList_AddTextVec2(ImDrawList* self,const ImVec2 pos,ImU32 col,const char* text_begin,const char* text_end)
{
return self->AddText(pos,col,text_begin,text_end);
}
@@ -1956,9 +1893,9 @@ CIMGUI_API void ImDrawList_AddConvexPolyFilled(ImDrawList* self,const ImVec2* po
{
return self->AddConvexPolyFilled(points,num_points,col);
}
-CIMGUI_API void ImDrawList_AddBezierCurve(ImDrawList* self,const ImVec2 pos0,const ImVec2 cp0,const ImVec2 cp1,const ImVec2 pos1,ImU32 col,float thickness,int num_segments)
+CIMGUI_API void ImDrawList_AddBezierCurve(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,ImU32 col,float thickness,int num_segments)
{
- return self->AddBezierCurve(pos0,cp0,cp1,pos1,col,thickness,num_segments);
+ return self->AddBezierCurve(p1,p2,p3,p4,col,thickness,num_segments);
}
CIMGUI_API void ImDrawList_AddImage(ImDrawList* self,ImTextureID user_texture_id,const ImVec2 p_min,const ImVec2 p_max,const ImVec2 uv_min,const ImVec2 uv_max,ImU32 col)
{
@@ -2000,9 +1937,9 @@ CIMGUI_API void ImDrawList_PathArcToFast(ImDrawList* self,const ImVec2 center,fl
{
return self->PathArcToFast(center,radius,a_min_of_12,a_max_of_12);
}
-CIMGUI_API void ImDrawList_PathBezierCurveTo(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,int num_segments)
+CIMGUI_API void ImDrawList_PathBezierCurveTo(ImDrawList* self,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,int num_segments)
{
- return self->PathBezierCurveTo(p1,p2,p3,num_segments);
+ return self->PathBezierCurveTo(p2,p3,p4,num_segments);
}
CIMGUI_API void ImDrawList_PathRect(ImDrawList* self,const ImVec2 rect_min,const ImVec2 rect_max,float rounding,ImDrawCornerFlags rounding_corners)
{
@@ -2044,6 +1981,10 @@ CIMGUI_API void ImDrawList_PrimReserve(ImDrawList* self,int idx_count,int vtx_co
{
return self->PrimReserve(idx_count,vtx_count);
}
+CIMGUI_API void ImDrawList_PrimUnreserve(ImDrawList* self,int idx_count,int vtx_count)
+{
+ return self->PrimUnreserve(idx_count,vtx_count);
+}
CIMGUI_API void ImDrawList_PrimRect(ImDrawList* self,const ImVec2 a,const ImVec2 b,ImU32 col)
{
return self->PrimRect(a,b,col);
@@ -2116,11 +2057,11 @@ CIMGUI_API void ImFontGlyphRangesBuilder_Clear(ImFontGlyphRangesBuilder* self)
{
return self->Clear();
}
-CIMGUI_API bool ImFontGlyphRangesBuilder_GetBit(ImFontGlyphRangesBuilder* self,int n)
+CIMGUI_API bool ImFontGlyphRangesBuilder_GetBit(ImFontGlyphRangesBuilder* self,size_t n)
{
return self->GetBit(n);
}
-CIMGUI_API void ImFontGlyphRangesBuilder_SetBit(ImFontGlyphRangesBuilder* self,int n)
+CIMGUI_API void ImFontGlyphRangesBuilder_SetBit(ImFontGlyphRangesBuilder* self,size_t n)
{
return self->SetBit(n);
}
@@ -2300,9 +2241,9 @@ CIMGUI_API const char* ImFont_GetDebugName(ImFont* self)
{
return self->GetDebugName();
}
-CIMGUI_API ImVec2 ImFont_CalcTextSizeA(ImFont* self,float size,float max_width,float wrap_width,const char* text_begin,const char* text_end,const char** remaining)
+CIMGUI_API void ImFont_CalcTextSizeA(ImVec2 *pOut,ImFont* self,float size,float max_width,float wrap_width,const char* text_begin,const char* text_end,const char** remaining)
{
- return self->CalcTextSizeA(size,max_width,wrap_width,text_begin,text_end,remaining);
+ *pOut = self->CalcTextSizeA(size,max_width,wrap_width,text_begin,text_end,remaining);
}
CIMGUI_API const char* ImFont_CalcWordWrapPositionA(ImFont* self,float scale,const char* text,const char* text_end,float wrap_width)
{
@@ -2336,305 +2277,1605 @@ CIMGUI_API void ImFont_AddRemapChar(ImFont* self,ImWchar dst,ImWchar src,bool ov
{
return self->AddRemapChar(dst,src,overwrite_dst);
}
+CIMGUI_API void ImFont_SetGlyphVisible(ImFont* self,ImWchar c,bool visible)
+{
+ return self->SetGlyphVisible(c,visible);
+}
CIMGUI_API void ImFont_SetFallbackChar(ImFont* self,ImWchar c)
{
return self->SetFallbackChar(c);
}
-CIMGUI_API ImGuiPlatformMonitor* ImGuiPlatformMonitor_ImGuiPlatformMonitor(void)
+CIMGUI_API bool ImFont_IsGlyphRangeUnused(ImFont* self,unsigned int c_begin,unsigned int c_last)
{
- return IM_NEW(ImGuiPlatformMonitor)();
+ return self->IsGlyphRangeUnused(c_begin,c_last);
}
-CIMGUI_API void ImGuiPlatformMonitor_destroy(ImGuiPlatformMonitor* self)
+CIMGUI_API ImU32 igImHashData(const void* data,size_t data_size,ImU32 seed)
{
- IM_DELETE(self);
+ return ImHashData(data,data_size,seed);
}
-CIMGUI_API ImGuiPlatformIO* ImGuiPlatformIO_ImGuiPlatformIO(void)
+CIMGUI_API ImU32 igImHashStr(const char* data,size_t data_size,ImU32 seed)
{
- return IM_NEW(ImGuiPlatformIO)();
+ return ImHashStr(data,data_size,seed);
}
-CIMGUI_API void ImGuiPlatformIO_destroy(ImGuiPlatformIO* self)
+CIMGUI_API ImU32 igImAlphaBlendColors(ImU32 col_a,ImU32 col_b)
{
- IM_DELETE(self);
+ return ImAlphaBlendColors(col_a,col_b);
}
-CIMGUI_API ImGuiViewport* ImGuiViewport_ImGuiViewport(void)
+CIMGUI_API bool igImIsPowerOfTwo(int v)
{
- return IM_NEW(ImGuiViewport)();
+ return ImIsPowerOfTwo(v);
}
-CIMGUI_API void ImGuiViewport_destroy(ImGuiViewport* self)
+CIMGUI_API int igImUpperPowerOfTwo(int v)
{
- IM_DELETE(self);
+ return ImUpperPowerOfTwo(v);
}
-CIMGUI_API void igGetWindowPos_nonUDT(ImVec2 *pOut)
+CIMGUI_API int igImStricmp(const char* str1,const char* str2)
{
- *pOut = ImGui::GetWindowPos();
+ return ImStricmp(str1,str2);
}
-CIMGUI_API ImVec2_Simple igGetWindowPos_nonUDT2()
+CIMGUI_API int igImStrnicmp(const char* str1,const char* str2,size_t count)
{
- ImVec2 ret = ImGui::GetWindowPos();
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImStrnicmp(str1,str2,count);
}
-CIMGUI_API void igGetWindowSize_nonUDT(ImVec2 *pOut)
+CIMGUI_API void igImStrncpy(char* dst,const char* src,size_t count)
{
- *pOut = ImGui::GetWindowSize();
+ return ImStrncpy(dst,src,count);
}
-CIMGUI_API ImVec2_Simple igGetWindowSize_nonUDT2()
+CIMGUI_API char* igImStrdup(const char* str)
{
- ImVec2 ret = ImGui::GetWindowSize();
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImStrdup(str);
}
-CIMGUI_API void igGetContentRegionMax_nonUDT(ImVec2 *pOut)
+CIMGUI_API char* igImStrdupcpy(char* dst,size_t* p_dst_size,const char* str)
{
- *pOut = ImGui::GetContentRegionMax();
+ return ImStrdupcpy(dst,p_dst_size,str);
}
-CIMGUI_API ImVec2_Simple igGetContentRegionMax_nonUDT2()
+CIMGUI_API const char* igImStrchrRange(const char* str_begin,const char* str_end,char c)
{
- ImVec2 ret = ImGui::GetContentRegionMax();
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImStrchrRange(str_begin,str_end,c);
}
-CIMGUI_API void igGetContentRegionAvail_nonUDT(ImVec2 *pOut)
+CIMGUI_API int igImStrlenW(const ImWchar* str)
{
- *pOut = ImGui::GetContentRegionAvail();
+ return ImStrlenW(str);
}
-CIMGUI_API ImVec2_Simple igGetContentRegionAvail_nonUDT2()
+CIMGUI_API const char* igImStreolRange(const char* str,const char* str_end)
{
- ImVec2 ret = ImGui::GetContentRegionAvail();
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImStreolRange(str,str_end);
}
-CIMGUI_API void igGetWindowContentRegionMin_nonUDT(ImVec2 *pOut)
+CIMGUI_API const ImWchar* igImStrbolW(const ImWchar* buf_mid_line,const ImWchar* buf_begin)
{
- *pOut = ImGui::GetWindowContentRegionMin();
+ return ImStrbolW(buf_mid_line,buf_begin);
}
-CIMGUI_API ImVec2_Simple igGetWindowContentRegionMin_nonUDT2()
+CIMGUI_API const char* igImStristr(const char* haystack,const char* haystack_end,const char* needle,const char* needle_end)
{
- ImVec2 ret = ImGui::GetWindowContentRegionMin();
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImStristr(haystack,haystack_end,needle,needle_end);
}
-CIMGUI_API void igGetWindowContentRegionMax_nonUDT(ImVec2 *pOut)
+CIMGUI_API void igImStrTrimBlanks(char* str)
{
- *pOut = ImGui::GetWindowContentRegionMax();
+ return ImStrTrimBlanks(str);
}
-CIMGUI_API ImVec2_Simple igGetWindowContentRegionMax_nonUDT2()
+CIMGUI_API const char* igImStrSkipBlank(const char* str)
{
- ImVec2 ret = ImGui::GetWindowContentRegionMax();
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImStrSkipBlank(str);
}
-CIMGUI_API void igGetFontTexUvWhitePixel_nonUDT(ImVec2 *pOut)
+CIMGUI_API int igImFormatString(char* buf,size_t buf_size,const char* fmt,...)
{
- *pOut = ImGui::GetFontTexUvWhitePixel();
+ va_list args;
+ va_start(args, fmt);
+ int ret = ImFormatStringV(buf,buf_size,fmt,args);
+ va_end(args);
+ return ret;
}
-CIMGUI_API ImVec2_Simple igGetFontTexUvWhitePixel_nonUDT2()
+CIMGUI_API int igImFormatStringV(char* buf,size_t buf_size,const char* fmt,va_list args)
{
- ImVec2 ret = ImGui::GetFontTexUvWhitePixel();
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImFormatStringV(buf,buf_size,fmt,args);
}
-CIMGUI_API void igGetCursorPos_nonUDT(ImVec2 *pOut)
+CIMGUI_API const char* igImParseFormatFindStart(const char* format)
{
- *pOut = ImGui::GetCursorPos();
+ return ImParseFormatFindStart(format);
}
-CIMGUI_API ImVec2_Simple igGetCursorPos_nonUDT2()
+CIMGUI_API const char* igImParseFormatFindEnd(const char* format)
{
- ImVec2 ret = ImGui::GetCursorPos();
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImParseFormatFindEnd(format);
}
-CIMGUI_API void igGetCursorStartPos_nonUDT(ImVec2 *pOut)
+CIMGUI_API const char* igImParseFormatTrimDecorations(const char* format,char* buf,size_t buf_size)
{
- *pOut = ImGui::GetCursorStartPos();
+ return ImParseFormatTrimDecorations(format,buf,buf_size);
}
-CIMGUI_API ImVec2_Simple igGetCursorStartPos_nonUDT2()
+CIMGUI_API int igImParseFormatPrecision(const char* format,int default_value)
{
- ImVec2 ret = ImGui::GetCursorStartPos();
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImParseFormatPrecision(format,default_value);
}
-CIMGUI_API void igGetCursorScreenPos_nonUDT(ImVec2 *pOut)
+CIMGUI_API bool igImCharIsBlankA(char c)
{
- *pOut = ImGui::GetCursorScreenPos();
+ return ImCharIsBlankA(c);
}
-CIMGUI_API ImVec2_Simple igGetCursorScreenPos_nonUDT2()
+CIMGUI_API bool igImCharIsBlankW(unsigned int c)
{
- ImVec2 ret = ImGui::GetCursorScreenPos();
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImCharIsBlankW(c);
}
-CIMGUI_API void igGetItemRectMin_nonUDT(ImVec2 *pOut)
+CIMGUI_API int igImTextStrToUtf8(char* buf,int buf_size,const ImWchar* in_text,const ImWchar* in_text_end)
{
- *pOut = ImGui::GetItemRectMin();
+ return ImTextStrToUtf8(buf,buf_size,in_text,in_text_end);
}
-CIMGUI_API ImVec2_Simple igGetItemRectMin_nonUDT2()
+CIMGUI_API int igImTextCharFromUtf8(unsigned int* out_char,const char* in_text,const char* in_text_end)
{
- ImVec2 ret = ImGui::GetItemRectMin();
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImTextCharFromUtf8(out_char,in_text,in_text_end);
}
-CIMGUI_API void igGetItemRectMax_nonUDT(ImVec2 *pOut)
+CIMGUI_API int igImTextStrFromUtf8(ImWchar* buf,int buf_size,const char* in_text,const char* in_text_end,const char** in_remaining)
{
- *pOut = ImGui::GetItemRectMax();
+ return ImTextStrFromUtf8(buf,buf_size,in_text,in_text_end,in_remaining);
}
-CIMGUI_API ImVec2_Simple igGetItemRectMax_nonUDT2()
+CIMGUI_API int igImTextCountCharsFromUtf8(const char* in_text,const char* in_text_end)
{
- ImVec2 ret = ImGui::GetItemRectMax();
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImTextCountCharsFromUtf8(in_text,in_text_end);
}
-CIMGUI_API void igGetItemRectSize_nonUDT(ImVec2 *pOut)
+CIMGUI_API int igImTextCountUtf8BytesFromChar(const char* in_text,const char* in_text_end)
{
- *pOut = ImGui::GetItemRectSize();
+ return ImTextCountUtf8BytesFromChar(in_text,in_text_end);
}
-CIMGUI_API ImVec2_Simple igGetItemRectSize_nonUDT2()
+CIMGUI_API int igImTextCountUtf8BytesFromStr(const ImWchar* in_text,const ImWchar* in_text_end)
{
- ImVec2 ret = ImGui::GetItemRectSize();
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImTextCountUtf8BytesFromStr(in_text,in_text_end);
}
-CIMGUI_API void igCalcTextSize_nonUDT(ImVec2 *pOut,const char* text,const char* text_end,bool hide_text_after_double_hash,float wrap_width)
+CIMGUI_API ImFileHandle igImFileOpen(const char* filename,const char* mode)
{
- *pOut = ImGui::CalcTextSize(text,text_end,hide_text_after_double_hash,wrap_width);
+ return ImFileOpen(filename,mode);
}
-CIMGUI_API ImVec2_Simple igCalcTextSize_nonUDT2(const char* text,const char* text_end,bool hide_text_after_double_hash,float wrap_width)
+CIMGUI_API bool igImFileClose(ImFileHandle file)
{
- ImVec2 ret = ImGui::CalcTextSize(text,text_end,hide_text_after_double_hash,wrap_width);
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImFileClose(file);
}
-CIMGUI_API void igColorConvertU32ToFloat4_nonUDT(ImVec4 *pOut,ImU32 in)
+CIMGUI_API ImU64 igImFileGetSize(ImFileHandle file)
{
- *pOut = ImGui::ColorConvertU32ToFloat4(in);
+ return ImFileGetSize(file);
}
-CIMGUI_API ImVec4_Simple igColorConvertU32ToFloat4_nonUDT2(ImU32 in)
+CIMGUI_API ImU64 igImFileRead(void* data,ImU64 size,ImU64 count,ImFileHandle file)
{
- ImVec4 ret = ImGui::ColorConvertU32ToFloat4(in);
- ImVec4_Simple ret2 = ImVec4ToSimple(ret);
- return ret2;
+ return ImFileRead(data,size,count,file);
}
-CIMGUI_API void igGetMousePos_nonUDT(ImVec2 *pOut)
+CIMGUI_API ImU64 igImFileWrite(const void* data,ImU64 size,ImU64 count,ImFileHandle file)
{
- *pOut = ImGui::GetMousePos();
+ return ImFileWrite(data,size,count,file);
}
-CIMGUI_API ImVec2_Simple igGetMousePos_nonUDT2()
+CIMGUI_API void* igImFileLoadToMemory(const char* filename,const char* mode,size_t* out_file_size,int padding_bytes)
{
- ImVec2 ret = ImGui::GetMousePos();
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImFileLoadToMemory(filename,mode,out_file_size,padding_bytes);
}
-CIMGUI_API void igGetMousePosOnOpeningCurrentPopup_nonUDT(ImVec2 *pOut)
+CIMGUI_API float igImPowFloat(float x,float y)
{
- *pOut = ImGui::GetMousePosOnOpeningCurrentPopup();
+ return ImPow(x,y);
}
-CIMGUI_API ImVec2_Simple igGetMousePosOnOpeningCurrentPopup_nonUDT2()
+CIMGUI_API double igImPowdouble(double x,double y)
{
- ImVec2 ret = ImGui::GetMousePosOnOpeningCurrentPopup();
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImPow(x,y);
}
-CIMGUI_API void igGetMouseDragDelta_nonUDT(ImVec2 *pOut,int button,float lock_threshold)
+CIMGUI_API void igImMin(ImVec2 *pOut,const ImVec2 lhs,const ImVec2 rhs)
{
- *pOut = ImGui::GetMouseDragDelta(button,lock_threshold);
+ *pOut = ImMin(lhs,rhs);
}
-CIMGUI_API ImVec2_Simple igGetMouseDragDelta_nonUDT2(int button,float lock_threshold)
+CIMGUI_API void igImMax(ImVec2 *pOut,const ImVec2 lhs,const ImVec2 rhs)
{
- ImVec2 ret = ImGui::GetMouseDragDelta(button,lock_threshold);
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ *pOut = ImMax(lhs,rhs);
}
-CIMGUI_API void ImColor_HSV_nonUDT(ImColor *pOut,ImColor* self,float h,float s,float v,float a)
+CIMGUI_API void igImClamp(ImVec2 *pOut,const ImVec2 v,const ImVec2 mn,ImVec2 mx)
{
- *pOut = self->HSV(h,s,v,a);
+ *pOut = ImClamp(v,mn,mx);
}
-CIMGUI_API ImColor_Simple ImColor_HSV_nonUDT2(ImColor* self,float h,float s,float v,float a)
+CIMGUI_API void igImLerpVec2Float(ImVec2 *pOut,const ImVec2 a,const ImVec2 b,float t)
{
- ImColor ret = self->HSV(h,s,v,a);
- ImColor_Simple ret2 = ImColorToSimple(ret);
- return ret2;
+ *pOut = ImLerp(a,b,t);
}
-CIMGUI_API void ImDrawList_GetClipRectMin_nonUDT(ImVec2 *pOut,ImDrawList* self)
+CIMGUI_API void igImLerpVec2Vec2(ImVec2 *pOut,const ImVec2 a,const ImVec2 b,const ImVec2 t)
{
- *pOut = self->GetClipRectMin();
+ *pOut = ImLerp(a,b,t);
}
-CIMGUI_API ImVec2_Simple ImDrawList_GetClipRectMin_nonUDT2(ImDrawList* self)
+CIMGUI_API void igImLerpVec4(ImVec4 *pOut,const ImVec4 a,const ImVec4 b,float t)
{
- ImVec2 ret = self->GetClipRectMin();
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ *pOut = ImLerp(a,b,t);
}
-CIMGUI_API void ImDrawList_GetClipRectMax_nonUDT(ImVec2 *pOut,ImDrawList* self)
+CIMGUI_API float igImSaturate(float f)
{
- *pOut = self->GetClipRectMax();
+ return ImSaturate(f);
}
-CIMGUI_API ImVec2_Simple ImDrawList_GetClipRectMax_nonUDT2(ImDrawList* self)
+CIMGUI_API float igImLengthSqrVec2(const ImVec2 lhs)
{
- ImVec2 ret = self->GetClipRectMax();
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImLengthSqr(lhs);
}
-CIMGUI_API void ImFont_CalcTextSizeA_nonUDT(ImVec2 *pOut,ImFont* self,float size,float max_width,float wrap_width,const char* text_begin,const char* text_end,const char** remaining)
+CIMGUI_API float igImLengthSqrVec4(const ImVec4 lhs)
{
- *pOut = self->CalcTextSizeA(size,max_width,wrap_width,text_begin,text_end,remaining);
+ return ImLengthSqr(lhs);
}
-CIMGUI_API ImVec2_Simple ImFont_CalcTextSizeA_nonUDT2(ImFont* self,float size,float max_width,float wrap_width,const char* text_begin,const char* text_end,const char** remaining)
+CIMGUI_API float igImInvLength(const ImVec2 lhs,float fail_value)
{
- ImVec2 ret = self->CalcTextSizeA(size,max_width,wrap_width,text_begin,text_end,remaining);
- ImVec2_Simple ret2 = ImVec2ToSimple(ret);
- return ret2;
+ return ImInvLength(lhs,fail_value);
}
-
-
-
-/////////////////////////////manual written functions
-CIMGUI_API void igLogText(CONST char *fmt, ...)
+CIMGUI_API float igImFloorFloat(float f)
{
- char buffer[256];
- va_list args;
- va_start(args, fmt);
- vsnprintf(buffer, 256, fmt, args);
- va_end(args);
-
- ImGui::LogText("%s", buffer);
+ return ImFloor(f);
}
-CIMGUI_API void ImGuiTextBuffer_appendf(struct ImGuiTextBuffer *buffer, const char *fmt, ...)
+CIMGUI_API void igImFloorVec2(ImVec2 *pOut,const ImVec2 v)
{
- va_list args;
- va_start(args, fmt);
- buffer->appendfv(fmt, args);
- va_end(args);
+ *pOut = ImFloor(v);
}
-
-CIMGUI_API float igGET_FLT_MAX()
+CIMGUI_API int igImModPositive(int a,int b)
{
- return FLT_MAX;
+ return ImModPositive(a,b);
}
-CIMGUI_API void igColorConvertRGBtoHSV(float r,float g,float b,float *out_h,float *out_s,float *out_v)
+CIMGUI_API float igImDot(const ImVec2 a,const ImVec2 b)
{
- ImGui::ColorConvertRGBtoHSV(r,g,b,*out_h,*out_s,*out_v);
+ return ImDot(a,b);
}
-CIMGUI_API void igColorConvertHSVtoRGB(float h,float s,float v,float *out_r,float *out_g,float *out_b)
+CIMGUI_API void igImRotate(ImVec2 *pOut,const ImVec2 v,float cos_a,float sin_a)
{
- ImGui::ColorConvertHSVtoRGB(h,s,v,*out_r,*out_g,*out_b);
+ *pOut = ImRotate(v,cos_a,sin_a);
}
-
-CIMGUI_API ImVector_ImWchar* ImVector_ImWchar_create()
+CIMGUI_API float igImLinearSweep(float current,float target,float speed)
{
- return IM_NEW(ImVector) ();
+ return ImLinearSweep(current,target,speed);
}
-
-CIMGUI_API void ImVector_ImWchar_destroy(ImVector_ImWchar* self)
+CIMGUI_API void igImMul(ImVec2 *pOut,const ImVec2 lhs,const ImVec2 rhs)
+{
+ *pOut = ImMul(lhs,rhs);
+}
+CIMGUI_API void igImBezierCalc(ImVec2 *pOut,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,float t)
+{
+ *pOut = ImBezierCalc(p1,p2,p3,p4,t);
+}
+CIMGUI_API void igImBezierClosestPoint(ImVec2 *pOut,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,const ImVec2 p,int num_segments)
+{
+ *pOut = ImBezierClosestPoint(p1,p2,p3,p4,p,num_segments);
+}
+CIMGUI_API void igImBezierClosestPointCasteljau(ImVec2 *pOut,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,const ImVec2 p,float tess_tol)
+{
+ *pOut = ImBezierClosestPointCasteljau(p1,p2,p3,p4,p,tess_tol);
+}
+CIMGUI_API void igImLineClosestPoint(ImVec2 *pOut,const ImVec2 a,const ImVec2 b,const ImVec2 p)
+{
+ *pOut = ImLineClosestPoint(a,b,p);
+}
+CIMGUI_API bool igImTriangleContainsPoint(const ImVec2 a,const ImVec2 b,const ImVec2 c,const ImVec2 p)
+{
+ return ImTriangleContainsPoint(a,b,c,p);
+}
+CIMGUI_API void igImTriangleClosestPoint(ImVec2 *pOut,const ImVec2 a,const ImVec2 b,const ImVec2 c,const ImVec2 p)
+{
+ *pOut = ImTriangleClosestPoint(a,b,c,p);
+}
+CIMGUI_API void igImTriangleBarycentricCoords(const ImVec2 a,const ImVec2 b,const ImVec2 c,const ImVec2 p,float out_u,float out_v,float out_w)
+{
+ return ImTriangleBarycentricCoords(a,b,c,p,out_u,out_v,out_w);
+}
+CIMGUI_API float igImTriangleArea(const ImVec2 a,const ImVec2 b,const ImVec2 c)
+{
+ return ImTriangleArea(a,b,c);
+}
+CIMGUI_API ImGuiDir igImGetDirQuadrantFromDelta(float dx,float dy)
+{
+ return ImGetDirQuadrantFromDelta(dx,dy);
+}
+CIMGUI_API bool igImBitArrayTestBit(const ImU32* arr,int n)
+{
+ return ImBitArrayTestBit(arr,n);
+}
+CIMGUI_API void igImBitArrayClearBit(ImU32* arr,int n)
+{
+ return ImBitArrayClearBit(arr,n);
+}
+CIMGUI_API void igImBitArraySetBit(ImU32* arr,int n)
+{
+ return ImBitArraySetBit(arr,n);
+}
+CIMGUI_API void igImBitArraySetBitRange(ImU32* arr,int n,int n2)
+{
+ return ImBitArraySetBitRange(arr,n,n2);
+}
+CIMGUI_API void ImBitVector_Create(ImBitVector* self,int sz)
+{
+ return self->Create(sz);
+}
+CIMGUI_API void ImBitVector_Clear(ImBitVector* self)
+{
+ return self->Clear();
+}
+CIMGUI_API bool ImBitVector_TestBit(ImBitVector* self,int n)
+{
+ return self->TestBit(n);
+}
+CIMGUI_API void ImBitVector_SetBit(ImBitVector* self,int n)
+{
+ return self->SetBit(n);
+}
+CIMGUI_API void ImBitVector_ClearBit(ImBitVector* self,int n)
+{
+ return self->ClearBit(n);
+}
+CIMGUI_API ImVec1* ImVec1_ImVec1Nil(void)
+{
+ return IM_NEW(ImVec1)();
+}
+CIMGUI_API void ImVec1_destroy(ImVec1* self)
{
IM_DELETE(self);
}
-
-CIMGUI_API void ImVector_ImWchar_Init(ImVector_ImWchar* p)
+CIMGUI_API ImVec1* ImVec1_ImVec1Float(float _x)
{
- IM_PLACEMENT_NEW(p) ImVector();
+ return IM_NEW(ImVec1)(_x);
}
-CIMGUI_API void ImVector_ImWchar_UnInit(ImVector_ImWchar* p)
+CIMGUI_API ImVec2ih* ImVec2ih_ImVec2ihNil(void)
{
- p->~ImVector();
+ return IM_NEW(ImVec2ih)();
+}
+CIMGUI_API void ImVec2ih_destroy(ImVec2ih* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API ImVec2ih* ImVec2ih_ImVec2ihshort(short _x,short _y)
+{
+ return IM_NEW(ImVec2ih)(_x,_y);
+}
+CIMGUI_API ImVec2ih* ImVec2ih_ImVec2ihVec2(const ImVec2 rhs)
+{
+ return IM_NEW(ImVec2ih)(rhs);
+}
+CIMGUI_API ImRect* ImRect_ImRectNil(void)
+{
+ return IM_NEW(ImRect)();
+}
+CIMGUI_API void ImRect_destroy(ImRect* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API ImRect* ImRect_ImRectVec2(const ImVec2 min,const ImVec2 max)
+{
+ return IM_NEW(ImRect)(min,max);
+}
+CIMGUI_API ImRect* ImRect_ImRectVec4(const ImVec4 v)
+{
+ return IM_NEW(ImRect)(v);
+}
+CIMGUI_API ImRect* ImRect_ImRectFloat(float x1,float y1,float x2,float y2)
+{
+ return IM_NEW(ImRect)(x1,y1,x2,y2);
+}
+CIMGUI_API void ImRect_GetCenter(ImVec2 *pOut,ImRect* self)
+{
+ *pOut = self->GetCenter();
+}
+CIMGUI_API void ImRect_GetSize(ImVec2 *pOut,ImRect* self)
+{
+ *pOut = self->GetSize();
+}
+CIMGUI_API float ImRect_GetWidth(ImRect* self)
+{
+ return self->GetWidth();
+}
+CIMGUI_API float ImRect_GetHeight(ImRect* self)
+{
+ return self->GetHeight();
+}
+CIMGUI_API void ImRect_GetTL(ImVec2 *pOut,ImRect* self)
+{
+ *pOut = self->GetTL();
+}
+CIMGUI_API void ImRect_GetTR(ImVec2 *pOut,ImRect* self)
+{
+ *pOut = self->GetTR();
+}
+CIMGUI_API void ImRect_GetBL(ImVec2 *pOut,ImRect* self)
+{
+ *pOut = self->GetBL();
+}
+CIMGUI_API void ImRect_GetBR(ImVec2 *pOut,ImRect* self)
+{
+ *pOut = self->GetBR();
+}
+CIMGUI_API bool ImRect_ContainsVec2(ImRect* self,const ImVec2 p)
+{
+ return self->Contains(p);
+}
+CIMGUI_API bool ImRect_ContainsRect(ImRect* self,const ImRect r)
+{
+ return self->Contains(r);
+}
+CIMGUI_API bool ImRect_Overlaps(ImRect* self,const ImRect r)
+{
+ return self->Overlaps(r);
+}
+CIMGUI_API void ImRect_AddVec2(ImRect* self,const ImVec2 p)
+{
+ return self->Add(p);
+}
+CIMGUI_API void ImRect_AddRect(ImRect* self,const ImRect r)
+{
+ return self->Add(r);
+}
+CIMGUI_API void ImRect_ExpandFloat(ImRect* self,const float amount)
+{
+ return self->Expand(amount);
+}
+CIMGUI_API void ImRect_ExpandVec2(ImRect* self,const ImVec2 amount)
+{
+ return self->Expand(amount);
+}
+CIMGUI_API void ImRect_Translate(ImRect* self,const ImVec2 d)
+{
+ return self->Translate(d);
+}
+CIMGUI_API void ImRect_TranslateX(ImRect* self,float dx)
+{
+ return self->TranslateX(dx);
+}
+CIMGUI_API void ImRect_TranslateY(ImRect* self,float dy)
+{
+ return self->TranslateY(dy);
+}
+CIMGUI_API void ImRect_ClipWith(ImRect* self,const ImRect r)
+{
+ return self->ClipWith(r);
+}
+CIMGUI_API void ImRect_ClipWithFull(ImRect* self,const ImRect r)
+{
+ return self->ClipWithFull(r);
+}
+CIMGUI_API void ImRect_Floor(ImRect* self)
+{
+ return self->Floor();
+}
+CIMGUI_API bool ImRect_IsInverted(ImRect* self)
+{
+ return self->IsInverted();
+}
+CIMGUI_API ImGuiStyleMod* ImGuiStyleMod_ImGuiStyleModInt(ImGuiStyleVar idx,int v)
+{
+ return IM_NEW(ImGuiStyleMod)(idx,v);
+}
+CIMGUI_API void ImGuiStyleMod_destroy(ImGuiStyleMod* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API ImGuiStyleMod* ImGuiStyleMod_ImGuiStyleModFloat(ImGuiStyleVar idx,float v)
+{
+ return IM_NEW(ImGuiStyleMod)(idx,v);
+}
+CIMGUI_API ImGuiStyleMod* ImGuiStyleMod_ImGuiStyleModVec2(ImGuiStyleVar idx,ImVec2 v)
+{
+ return IM_NEW(ImGuiStyleMod)(idx,v);
+}
+CIMGUI_API ImGuiMenuColumns* ImGuiMenuColumns_ImGuiMenuColumns(void)
+{
+ return IM_NEW(ImGuiMenuColumns)();
+}
+CIMGUI_API void ImGuiMenuColumns_destroy(ImGuiMenuColumns* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API void ImGuiMenuColumns_Update(ImGuiMenuColumns* self,int count,float spacing,bool clear)
+{
+ return self->Update(count,spacing,clear);
+}
+CIMGUI_API float ImGuiMenuColumns_DeclColumns(ImGuiMenuColumns* self,float w0,float w1,float w2)
+{
+ return self->DeclColumns(w0,w1,w2);
+}
+CIMGUI_API float ImGuiMenuColumns_CalcExtraSpace(ImGuiMenuColumns* self,float avail_w)
+{
+ return self->CalcExtraSpace(avail_w);
+}
+CIMGUI_API ImGuiInputTextState* ImGuiInputTextState_ImGuiInputTextState(void)
+{
+ return IM_NEW(ImGuiInputTextState)();
+}
+CIMGUI_API void ImGuiInputTextState_destroy(ImGuiInputTextState* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API void ImGuiInputTextState_ClearText(ImGuiInputTextState* self)
+{
+ return self->ClearText();
+}
+CIMGUI_API void ImGuiInputTextState_ClearFreeMemory(ImGuiInputTextState* self)
+{
+ return self->ClearFreeMemory();
+}
+CIMGUI_API int ImGuiInputTextState_GetUndoAvailCount(ImGuiInputTextState* self)
+{
+ return self->GetUndoAvailCount();
+}
+CIMGUI_API int ImGuiInputTextState_GetRedoAvailCount(ImGuiInputTextState* self)
+{
+ return self->GetRedoAvailCount();
+}
+CIMGUI_API void ImGuiInputTextState_OnKeyPressed(ImGuiInputTextState* self,int key)
+{
+ return self->OnKeyPressed(key);
+}
+CIMGUI_API void ImGuiInputTextState_CursorAnimReset(ImGuiInputTextState* self)
+{
+ return self->CursorAnimReset();
+}
+CIMGUI_API void ImGuiInputTextState_CursorClamp(ImGuiInputTextState* self)
+{
+ return self->CursorClamp();
+}
+CIMGUI_API bool ImGuiInputTextState_HasSelection(ImGuiInputTextState* self)
+{
+ return self->HasSelection();
+}
+CIMGUI_API void ImGuiInputTextState_ClearSelection(ImGuiInputTextState* self)
+{
+ return self->ClearSelection();
+}
+CIMGUI_API void ImGuiInputTextState_SelectAll(ImGuiInputTextState* self)
+{
+ return self->SelectAll();
+}
+CIMGUI_API ImGuiWindowSettings* ImGuiWindowSettings_ImGuiWindowSettings(void)
+{
+ return IM_NEW(ImGuiWindowSettings)();
+}
+CIMGUI_API void ImGuiWindowSettings_destroy(ImGuiWindowSettings* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API char* ImGuiWindowSettings_GetName(ImGuiWindowSettings* self)
+{
+ return self->GetName();
+}
+CIMGUI_API ImGuiSettingsHandler* ImGuiSettingsHandler_ImGuiSettingsHandler(void)
+{
+ return IM_NEW(ImGuiSettingsHandler)();
+}
+CIMGUI_API void ImGuiSettingsHandler_destroy(ImGuiSettingsHandler* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API ImGuiPopupData* ImGuiPopupData_ImGuiPopupData(void)
+{
+ return IM_NEW(ImGuiPopupData)();
+}
+CIMGUI_API void ImGuiPopupData_destroy(ImGuiPopupData* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API ImGuiColumnData* ImGuiColumnData_ImGuiColumnData(void)
+{
+ return IM_NEW(ImGuiColumnData)();
+}
+CIMGUI_API void ImGuiColumnData_destroy(ImGuiColumnData* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API ImGuiColumns* ImGuiColumns_ImGuiColumns(void)
+{
+ return IM_NEW(ImGuiColumns)();
+}
+CIMGUI_API void ImGuiColumns_destroy(ImGuiColumns* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API void ImGuiColumns_Clear(ImGuiColumns* self)
+{
+ return self->Clear();
+}
+CIMGUI_API ImDrawListSharedData* ImDrawListSharedData_ImDrawListSharedData(void)
+{
+ return IM_NEW(ImDrawListSharedData)();
+}
+CIMGUI_API void ImDrawListSharedData_destroy(ImDrawListSharedData* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API void ImDrawListSharedData_SetCircleSegmentMaxError(ImDrawListSharedData* self,float max_error)
+{
+ return self->SetCircleSegmentMaxError(max_error);
+}
+CIMGUI_API void ImDrawDataBuilder_Clear(ImDrawDataBuilder* self)
+{
+ return self->Clear();
+}
+CIMGUI_API void ImDrawDataBuilder_ClearFreeMemory(ImDrawDataBuilder* self)
+{
+ return self->ClearFreeMemory();
+}
+CIMGUI_API void ImDrawDataBuilder_FlattenIntoSingleLayer(ImDrawDataBuilder* self)
+{
+ return self->FlattenIntoSingleLayer();
+}
+CIMGUI_API ImGuiNavMoveResult* ImGuiNavMoveResult_ImGuiNavMoveResult(void)
+{
+ return IM_NEW(ImGuiNavMoveResult)();
+}
+CIMGUI_API void ImGuiNavMoveResult_destroy(ImGuiNavMoveResult* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API void ImGuiNavMoveResult_Clear(ImGuiNavMoveResult* self)
+{
+ return self->Clear();
+}
+CIMGUI_API ImGuiNextWindowData* ImGuiNextWindowData_ImGuiNextWindowData(void)
+{
+ return IM_NEW(ImGuiNextWindowData)();
+}
+CIMGUI_API void ImGuiNextWindowData_destroy(ImGuiNextWindowData* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API void ImGuiNextWindowData_ClearFlags(ImGuiNextWindowData* self)
+{
+ return self->ClearFlags();
+}
+CIMGUI_API ImGuiNextItemData* ImGuiNextItemData_ImGuiNextItemData(void)
+{
+ return IM_NEW(ImGuiNextItemData)();
+}
+CIMGUI_API void ImGuiNextItemData_destroy(ImGuiNextItemData* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API void ImGuiNextItemData_ClearFlags(ImGuiNextItemData* self)
+{
+ return self->ClearFlags();
+}
+CIMGUI_API ImGuiPtrOrIndex* ImGuiPtrOrIndex_ImGuiPtrOrIndexPtr(void* ptr)
+{
+ return IM_NEW(ImGuiPtrOrIndex)(ptr);
+}
+CIMGUI_API void ImGuiPtrOrIndex_destroy(ImGuiPtrOrIndex* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API ImGuiPtrOrIndex* ImGuiPtrOrIndex_ImGuiPtrOrIndexInt(int index)
+{
+ return IM_NEW(ImGuiPtrOrIndex)(index);
+}
+CIMGUI_API ImGuiContext* ImGuiContext_ImGuiContext(ImFontAtlas* shared_font_atlas)
+{
+ return IM_NEW(ImGuiContext)(shared_font_atlas);
+}
+CIMGUI_API void ImGuiContext_destroy(ImGuiContext* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API ImGuiWindowTempData* ImGuiWindowTempData_ImGuiWindowTempData(void)
+{
+ return IM_NEW(ImGuiWindowTempData)();
+}
+CIMGUI_API void ImGuiWindowTempData_destroy(ImGuiWindowTempData* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API ImGuiWindow* ImGuiWindow_ImGuiWindow(ImGuiContext* context,const char* name)
+{
+ return IM_NEW(ImGuiWindow)(context,name);
+}
+CIMGUI_API void ImGuiWindow_destroy(ImGuiWindow* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API ImGuiID ImGuiWindow_GetIDStr(ImGuiWindow* self,const char* str,const char* str_end)
+{
+ return self->GetID(str,str_end);
+}
+CIMGUI_API ImGuiID ImGuiWindow_GetIDPtr(ImGuiWindow* self,const void* ptr)
+{
+ return self->GetID(ptr);
+}
+CIMGUI_API ImGuiID ImGuiWindow_GetIDInt(ImGuiWindow* self,int n)
+{
+ return self->GetID(n);
+}
+CIMGUI_API ImGuiID ImGuiWindow_GetIDNoKeepAliveStr(ImGuiWindow* self,const char* str,const char* str_end)
+{
+ return self->GetIDNoKeepAlive(str,str_end);
+}
+CIMGUI_API ImGuiID ImGuiWindow_GetIDNoKeepAlivePtr(ImGuiWindow* self,const void* ptr)
+{
+ return self->GetIDNoKeepAlive(ptr);
+}
+CIMGUI_API ImGuiID ImGuiWindow_GetIDNoKeepAliveInt(ImGuiWindow* self,int n)
+{
+ return self->GetIDNoKeepAlive(n);
+}
+CIMGUI_API ImGuiID ImGuiWindow_GetIDFromRectangle(ImGuiWindow* self,const ImRect r_abs)
+{
+ return self->GetIDFromRectangle(r_abs);
+}
+CIMGUI_API void ImGuiWindow_Rect(ImRect *pOut,ImGuiWindow* self)
+{
+ *pOut = self->Rect();
+}
+CIMGUI_API float ImGuiWindow_CalcFontSize(ImGuiWindow* self)
+{
+ return self->CalcFontSize();
+}
+CIMGUI_API float ImGuiWindow_TitleBarHeight(ImGuiWindow* self)
+{
+ return self->TitleBarHeight();
+}
+CIMGUI_API void ImGuiWindow_TitleBarRect(ImRect *pOut,ImGuiWindow* self)
+{
+ *pOut = self->TitleBarRect();
+}
+CIMGUI_API float ImGuiWindow_MenuBarHeight(ImGuiWindow* self)
+{
+ return self->MenuBarHeight();
+}
+CIMGUI_API void ImGuiWindow_MenuBarRect(ImRect *pOut,ImGuiWindow* self)
+{
+ *pOut = self->MenuBarRect();
+}
+CIMGUI_API ImGuiItemHoveredDataBackup* ImGuiItemHoveredDataBackup_ImGuiItemHoveredDataBackup(void)
+{
+ return IM_NEW(ImGuiItemHoveredDataBackup)();
+}
+CIMGUI_API void ImGuiItemHoveredDataBackup_destroy(ImGuiItemHoveredDataBackup* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API void ImGuiItemHoveredDataBackup_Backup(ImGuiItemHoveredDataBackup* self)
+{
+ return self->Backup();
+}
+CIMGUI_API void ImGuiItemHoveredDataBackup_Restore(ImGuiItemHoveredDataBackup* self)
+{
+ return self->Restore();
+}
+CIMGUI_API ImGuiTabItem* ImGuiTabItem_ImGuiTabItem(void)
+{
+ return IM_NEW(ImGuiTabItem)();
+}
+CIMGUI_API void ImGuiTabItem_destroy(ImGuiTabItem* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API ImGuiTabBar* ImGuiTabBar_ImGuiTabBar(void)
+{
+ return IM_NEW(ImGuiTabBar)();
+}
+CIMGUI_API void ImGuiTabBar_destroy(ImGuiTabBar* self)
+{
+ IM_DELETE(self);
+}
+CIMGUI_API int ImGuiTabBar_GetTabOrder(ImGuiTabBar* self,const ImGuiTabItem* tab)
+{
+ return self->GetTabOrder(tab);
+}
+CIMGUI_API const char* ImGuiTabBar_GetTabName(ImGuiTabBar* self,const ImGuiTabItem* tab)
+{
+ return self->GetTabName(tab);
+}
+CIMGUI_API ImGuiWindow* igGetCurrentWindowRead()
+{
+ return ImGui::GetCurrentWindowRead();
+}
+CIMGUI_API ImGuiWindow* igGetCurrentWindow()
+{
+ return ImGui::GetCurrentWindow();
+}
+CIMGUI_API ImGuiWindow* igFindWindowByID(ImGuiID id)
+{
+ return ImGui::FindWindowByID(id);
+}
+CIMGUI_API ImGuiWindow* igFindWindowByName(const char* name)
+{
+ return ImGui::FindWindowByName(name);
+}
+CIMGUI_API void igUpdateWindowParentAndRootLinks(ImGuiWindow* window,ImGuiWindowFlags flags,ImGuiWindow* parent_window)
+{
+ return ImGui::UpdateWindowParentAndRootLinks(window,flags,parent_window);
+}
+CIMGUI_API void igCalcWindowExpectedSize(ImVec2 *pOut,ImGuiWindow* window)
+{
+ *pOut = ImGui::CalcWindowExpectedSize(window);
+}
+CIMGUI_API bool igIsWindowChildOf(ImGuiWindow* window,ImGuiWindow* potential_parent)
+{
+ return ImGui::IsWindowChildOf(window,potential_parent);
+}
+CIMGUI_API bool igIsWindowNavFocusable(ImGuiWindow* window)
+{
+ return ImGui::IsWindowNavFocusable(window);
+}
+CIMGUI_API void igGetWindowAllowedExtentRect(ImRect *pOut,ImGuiWindow* window)
+{
+ *pOut = ImGui::GetWindowAllowedExtentRect(window);
+}
+CIMGUI_API void igSetWindowPosWindowPtr(ImGuiWindow* window,const ImVec2 pos,ImGuiCond cond)
+{
+ return ImGui::SetWindowPos(window,pos,cond);
+}
+CIMGUI_API void igSetWindowSizeWindowPtr(ImGuiWindow* window,const ImVec2 size,ImGuiCond cond)
+{
+ return ImGui::SetWindowSize(window,size,cond);
+}
+CIMGUI_API void igSetWindowCollapsedWindowPtr(ImGuiWindow* window,bool collapsed,ImGuiCond cond)
+{
+ return ImGui::SetWindowCollapsed(window,collapsed,cond);
+}
+CIMGUI_API void igFocusWindow(ImGuiWindow* window)
+{
+ return ImGui::FocusWindow(window);
+}
+CIMGUI_API void igFocusTopMostWindowUnderOne(ImGuiWindow* under_this_window,ImGuiWindow* ignore_window)
+{
+ return ImGui::FocusTopMostWindowUnderOne(under_this_window,ignore_window);
+}
+CIMGUI_API void igBringWindowToFocusFront(ImGuiWindow* window)
+{
+ return ImGui::BringWindowToFocusFront(window);
+}
+CIMGUI_API void igBringWindowToDisplayFront(ImGuiWindow* window)
+{
+ return ImGui::BringWindowToDisplayFront(window);
+}
+CIMGUI_API void igBringWindowToDisplayBack(ImGuiWindow* window)
+{
+ return ImGui::BringWindowToDisplayBack(window);
+}
+CIMGUI_API void igSetCurrentFont(ImFont* font)
+{
+ return ImGui::SetCurrentFont(font);
+}
+CIMGUI_API ImFont* igGetDefaultFont()
+{
+ return ImGui::GetDefaultFont();
+}
+CIMGUI_API ImDrawList* igGetForegroundDrawListWindowPtr(ImGuiWindow* window)
+{
+ return ImGui::GetForegroundDrawList(window);
+}
+CIMGUI_API void igInitialize(ImGuiContext* context)
+{
+ return ImGui::Initialize(context);
+}
+CIMGUI_API void igShutdown(ImGuiContext* context)
+{
+ return ImGui::Shutdown(context);
+}
+CIMGUI_API void igUpdateHoveredWindowAndCaptureFlags()
+{
+ return ImGui::UpdateHoveredWindowAndCaptureFlags();
+}
+CIMGUI_API void igStartMouseMovingWindow(ImGuiWindow* window)
+{
+ return ImGui::StartMouseMovingWindow(window);
+}
+CIMGUI_API void igUpdateMouseMovingWindowNewFrame()
+{
+ return ImGui::UpdateMouseMovingWindowNewFrame();
+}
+CIMGUI_API void igUpdateMouseMovingWindowEndFrame()
+{
+ return ImGui::UpdateMouseMovingWindowEndFrame();
+}
+CIMGUI_API void igMarkIniSettingsDirtyNil()
+{
+ return ImGui::MarkIniSettingsDirty();
+}
+CIMGUI_API void igMarkIniSettingsDirtyWindowPtr(ImGuiWindow* window)
+{
+ return ImGui::MarkIniSettingsDirty(window);
+}
+CIMGUI_API ImGuiWindowSettings* igCreateNewWindowSettings(const char* name)
+{
+ return ImGui::CreateNewWindowSettings(name);
+}
+CIMGUI_API ImGuiWindowSettings* igFindWindowSettings(ImGuiID id)
+{
+ return ImGui::FindWindowSettings(id);
+}
+CIMGUI_API ImGuiWindowSettings* igFindOrCreateWindowSettings(const char* name)
+{
+ return ImGui::FindOrCreateWindowSettings(name);
+}
+CIMGUI_API ImGuiSettingsHandler* igFindSettingsHandler(const char* type_name)
+{
+ return ImGui::FindSettingsHandler(type_name);
+}
+CIMGUI_API void igSetScrollXWindowPtr(ImGuiWindow* window,float new_scroll_x)
+{
+ return ImGui::SetScrollX(window,new_scroll_x);
+}
+CIMGUI_API void igSetScrollYWindowPtr(ImGuiWindow* window,float new_scroll_y)
+{
+ return ImGui::SetScrollY(window,new_scroll_y);
+}
+CIMGUI_API void igSetScrollFromPosXWindowPtr(ImGuiWindow* window,float local_x,float center_x_ratio)
+{
+ return ImGui::SetScrollFromPosX(window,local_x,center_x_ratio);
+}
+CIMGUI_API void igSetScrollFromPosYWindowPtr(ImGuiWindow* window,float local_y,float center_y_ratio)
+{
+ return ImGui::SetScrollFromPosY(window,local_y,center_y_ratio);
+}
+CIMGUI_API void igScrollToBringRectIntoView(ImVec2 *pOut,ImGuiWindow* window,const ImRect item_rect)
+{
+ *pOut = ImGui::ScrollToBringRectIntoView(window,item_rect);
+}
+CIMGUI_API ImGuiID igGetItemID()
+{
+ return ImGui::GetItemID();
+}
+CIMGUI_API ImGuiItemStatusFlags igGetItemStatusFlags()
+{
+ return ImGui::GetItemStatusFlags();
+}
+CIMGUI_API ImGuiID igGetActiveID()
+{
+ return ImGui::GetActiveID();
+}
+CIMGUI_API ImGuiID igGetFocusID()
+{
+ return ImGui::GetFocusID();
+}
+CIMGUI_API void igSetActiveID(ImGuiID id,ImGuiWindow* window)
+{
+ return ImGui::SetActiveID(id,window);
+}
+CIMGUI_API void igSetFocusID(ImGuiID id,ImGuiWindow* window)
+{
+ return ImGui::SetFocusID(id,window);
+}
+CIMGUI_API void igClearActiveID()
+{
+ return ImGui::ClearActiveID();
+}
+CIMGUI_API ImGuiID igGetHoveredID()
+{
+ return ImGui::GetHoveredID();
+}
+CIMGUI_API void igSetHoveredID(ImGuiID id)
+{
+ return ImGui::SetHoveredID(id);
+}
+CIMGUI_API void igKeepAliveID(ImGuiID id)
+{
+ return ImGui::KeepAliveID(id);
+}
+CIMGUI_API void igMarkItemEdited(ImGuiID id)
+{
+ return ImGui::MarkItemEdited(id);
+}
+CIMGUI_API void igPushOverrideID(ImGuiID id)
+{
+ return ImGui::PushOverrideID(id);
+}
+CIMGUI_API void igItemSizeVec2(const ImVec2 size,float text_baseline_y)
+{
+ return ImGui::ItemSize(size,text_baseline_y);
+}
+CIMGUI_API void igItemSizeRect(const ImRect bb,float text_baseline_y)
+{
+ return ImGui::ItemSize(bb,text_baseline_y);
+}
+CIMGUI_API bool igItemAdd(const ImRect bb,ImGuiID id,const ImRect* nav_bb)
+{
+ return ImGui::ItemAdd(bb,id,nav_bb);
+}
+CIMGUI_API bool igItemHoverable(const ImRect bb,ImGuiID id)
+{
+ return ImGui::ItemHoverable(bb,id);
+}
+CIMGUI_API bool igIsClippedEx(const ImRect bb,ImGuiID id,bool clip_even_when_logged)
+{
+ return ImGui::IsClippedEx(bb,id,clip_even_when_logged);
+}
+CIMGUI_API bool igFocusableItemRegister(ImGuiWindow* window,ImGuiID id)
+{
+ return ImGui::FocusableItemRegister(window,id);
+}
+CIMGUI_API void igFocusableItemUnregister(ImGuiWindow* window)
+{
+ return ImGui::FocusableItemUnregister(window);
+}
+CIMGUI_API void igCalcItemSize(ImVec2 *pOut,ImVec2 size,float default_w,float default_h)
+{
+ *pOut = ImGui::CalcItemSize(size,default_w,default_h);
+}
+CIMGUI_API float igCalcWrapWidthForPos(const ImVec2 pos,float wrap_pos_x)
+{
+ return ImGui::CalcWrapWidthForPos(pos,wrap_pos_x);
+}
+CIMGUI_API void igPushMultiItemsWidths(int components,float width_full)
+{
+ return ImGui::PushMultiItemsWidths(components,width_full);
+}
+CIMGUI_API void igPushItemFlag(ImGuiItemFlags option,bool enabled)
+{
+ return ImGui::PushItemFlag(option,enabled);
+}
+CIMGUI_API void igPopItemFlag()
+{
+ return ImGui::PopItemFlag();
+}
+CIMGUI_API bool igIsItemToggledSelection()
+{
+ return ImGui::IsItemToggledSelection();
+}
+CIMGUI_API void igGetContentRegionMaxAbs(ImVec2 *pOut)
+{
+ *pOut = ImGui::GetContentRegionMaxAbs();
+}
+CIMGUI_API void igShrinkWidths(ImGuiShrinkWidthItem* items,int count,float width_excess)
+{
+ return ImGui::ShrinkWidths(items,count,width_excess);
+}
+CIMGUI_API void igLogBegin(ImGuiLogType type,int auto_open_depth)
+{
+ return ImGui::LogBegin(type,auto_open_depth);
+}
+CIMGUI_API void igLogToBuffer(int auto_open_depth)
+{
+ return ImGui::LogToBuffer(auto_open_depth);
+}
+CIMGUI_API bool igBeginChildEx(const char* name,ImGuiID id,const ImVec2 size_arg,bool border,ImGuiWindowFlags flags)
+{
+ return ImGui::BeginChildEx(name,id,size_arg,border,flags);
+}
+CIMGUI_API void igOpenPopupEx(ImGuiID id)
+{
+ return ImGui::OpenPopupEx(id);
+}
+CIMGUI_API void igClosePopupToLevel(int remaining,bool restore_focus_to_window_under_popup)
+{
+ return ImGui::ClosePopupToLevel(remaining,restore_focus_to_window_under_popup);
+}
+CIMGUI_API void igClosePopupsOverWindow(ImGuiWindow* ref_window,bool restore_focus_to_window_under_popup)
+{
+ return ImGui::ClosePopupsOverWindow(ref_window,restore_focus_to_window_under_popup);
+}
+CIMGUI_API bool igIsPopupOpenID(ImGuiID id)
+{
+ return ImGui::IsPopupOpen(id);
+}
+CIMGUI_API bool igBeginPopupEx(ImGuiID id,ImGuiWindowFlags extra_flags)
+{
+ return ImGui::BeginPopupEx(id,extra_flags);
+}
+CIMGUI_API void igBeginTooltipEx(ImGuiWindowFlags extra_flags,ImGuiTooltipFlags tooltip_flags)
+{
+ return ImGui::BeginTooltipEx(extra_flags,tooltip_flags);
+}
+CIMGUI_API ImGuiWindow* igGetTopMostPopupModal()
+{
+ return ImGui::GetTopMostPopupModal();
+}
+CIMGUI_API void igFindBestWindowPosForPopup(ImVec2 *pOut,ImGuiWindow* window)
+{
+ *pOut = ImGui::FindBestWindowPosForPopup(window);
+}
+CIMGUI_API void igFindBestWindowPosForPopupEx(ImVec2 *pOut,const ImVec2 ref_pos,const ImVec2 size,ImGuiDir* last_dir,const ImRect r_outer,const ImRect r_avoid,ImGuiPopupPositionPolicy policy)
+{
+ *pOut = ImGui::FindBestWindowPosForPopupEx(ref_pos,size,last_dir,r_outer,r_avoid,policy);
+}
+CIMGUI_API void igNavInitWindow(ImGuiWindow* window,bool force_reinit)
+{
+ return ImGui::NavInitWindow(window,force_reinit);
+}
+CIMGUI_API bool igNavMoveRequestButNoResultYet()
+{
+ return ImGui::NavMoveRequestButNoResultYet();
+}
+CIMGUI_API void igNavMoveRequestCancel()
+{
+ return ImGui::NavMoveRequestCancel();
+}
+CIMGUI_API void igNavMoveRequestForward(ImGuiDir move_dir,ImGuiDir clip_dir,const ImRect bb_rel,ImGuiNavMoveFlags move_flags)
+{
+ return ImGui::NavMoveRequestForward(move_dir,clip_dir,bb_rel,move_flags);
+}
+CIMGUI_API void igNavMoveRequestTryWrapping(ImGuiWindow* window,ImGuiNavMoveFlags move_flags)
+{
+ return ImGui::NavMoveRequestTryWrapping(window,move_flags);
+}
+CIMGUI_API float igGetNavInputAmount(ImGuiNavInput n,ImGuiInputReadMode mode)
+{
+ return ImGui::GetNavInputAmount(n,mode);
+}
+CIMGUI_API void igGetNavInputAmount2d(ImVec2 *pOut,ImGuiNavDirSourceFlags dir_sources,ImGuiInputReadMode mode,float slow_factor,float fast_factor)
+{
+ *pOut = ImGui::GetNavInputAmount2d(dir_sources,mode,slow_factor,fast_factor);
+}
+CIMGUI_API int igCalcTypematicRepeatAmount(float t0,float t1,float repeat_delay,float repeat_rate)
+{
+ return ImGui::CalcTypematicRepeatAmount(t0,t1,repeat_delay,repeat_rate);
+}
+CIMGUI_API void igActivateItem(ImGuiID id)
+{
+ return ImGui::ActivateItem(id);
+}
+CIMGUI_API void igSetNavID(ImGuiID id,int nav_layer,ImGuiID focus_scope_id)
+{
+ return ImGui::SetNavID(id,nav_layer,focus_scope_id);
+}
+CIMGUI_API void igSetNavIDWithRectRel(ImGuiID id,int nav_layer,ImGuiID focus_scope_id,const ImRect rect_rel)
+{
+ return ImGui::SetNavIDWithRectRel(id,nav_layer,focus_scope_id,rect_rel);
+}
+CIMGUI_API void igPushFocusScope(ImGuiID id)
+{
+ return ImGui::PushFocusScope(id);
+}
+CIMGUI_API void igPopFocusScope()
+{
+ return ImGui::PopFocusScope();
+}
+CIMGUI_API ImGuiID igGetFocusScopeID()
+{
+ return ImGui::GetFocusScopeID();
+}
+CIMGUI_API bool igIsActiveIdUsingNavDir(ImGuiDir dir)
+{
+ return ImGui::IsActiveIdUsingNavDir(dir);
+}
+CIMGUI_API bool igIsActiveIdUsingNavInput(ImGuiNavInput input)
+{
+ return ImGui::IsActiveIdUsingNavInput(input);
+}
+CIMGUI_API bool igIsActiveIdUsingKey(ImGuiKey key)
+{
+ return ImGui::IsActiveIdUsingKey(key);
+}
+CIMGUI_API bool igIsMouseDragPastThreshold(ImGuiMouseButton button,float lock_threshold)
+{
+ return ImGui::IsMouseDragPastThreshold(button,lock_threshold);
+}
+CIMGUI_API bool igIsKeyPressedMap(ImGuiKey key,bool repeat)
+{
+ return ImGui::IsKeyPressedMap(key,repeat);
+}
+CIMGUI_API bool igIsNavInputDown(ImGuiNavInput n)
+{
+ return ImGui::IsNavInputDown(n);
+}
+CIMGUI_API bool igIsNavInputTest(ImGuiNavInput n,ImGuiInputReadMode rm)
+{
+ return ImGui::IsNavInputTest(n,rm);
+}
+CIMGUI_API ImGuiKeyModFlags igGetMergedKeyModFlags()
+{
+ return ImGui::GetMergedKeyModFlags();
+}
+CIMGUI_API bool igBeginDragDropTargetCustom(const ImRect bb,ImGuiID id)
+{
+ return ImGui::BeginDragDropTargetCustom(bb,id);
+}
+CIMGUI_API void igClearDragDrop()
+{
+ return ImGui::ClearDragDrop();
+}
+CIMGUI_API bool igIsDragDropPayloadBeingAccepted()
+{
+ return ImGui::IsDragDropPayloadBeingAccepted();
+}
+CIMGUI_API void igBeginColumns(const char* str_id,int count,ImGuiColumnsFlags flags)
+{
+ return ImGui::BeginColumns(str_id,count,flags);
+}
+CIMGUI_API void igEndColumns()
+{
+ return ImGui::EndColumns();
+}
+CIMGUI_API void igPushColumnClipRect(int column_index)
+{
+ return ImGui::PushColumnClipRect(column_index);
+}
+CIMGUI_API void igPushColumnsBackground()
+{
+ return ImGui::PushColumnsBackground();
+}
+CIMGUI_API void igPopColumnsBackground()
+{
+ return ImGui::PopColumnsBackground();
+}
+CIMGUI_API ImGuiID igGetColumnsID(const char* str_id,int count)
+{
+ return ImGui::GetColumnsID(str_id,count);
+}
+CIMGUI_API ImGuiColumns* igFindOrCreateColumns(ImGuiWindow* window,ImGuiID id)
+{
+ return ImGui::FindOrCreateColumns(window,id);
+}
+CIMGUI_API float igGetColumnOffsetFromNorm(const ImGuiColumns* columns,float offset_norm)
+{
+ return ImGui::GetColumnOffsetFromNorm(columns,offset_norm);
+}
+CIMGUI_API float igGetColumnNormFromOffset(const ImGuiColumns* columns,float offset)
+{
+ return ImGui::GetColumnNormFromOffset(columns,offset);
+}
+CIMGUI_API bool igBeginTabBarEx(ImGuiTabBar* tab_bar,const ImRect bb,ImGuiTabBarFlags flags)
+{
+ return ImGui::BeginTabBarEx(tab_bar,bb,flags);
+}
+CIMGUI_API ImGuiTabItem* igTabBarFindTabByID(ImGuiTabBar* tab_bar,ImGuiID tab_id)
+{
+ return ImGui::TabBarFindTabByID(tab_bar,tab_id);
+}
+CIMGUI_API void igTabBarRemoveTab(ImGuiTabBar* tab_bar,ImGuiID tab_id)
+{
+ return ImGui::TabBarRemoveTab(tab_bar,tab_id);
+}
+CIMGUI_API void igTabBarCloseTab(ImGuiTabBar* tab_bar,ImGuiTabItem* tab)
+{
+ return ImGui::TabBarCloseTab(tab_bar,tab);
+}
+CIMGUI_API void igTabBarQueueChangeTabOrder(ImGuiTabBar* tab_bar,const ImGuiTabItem* tab,int dir)
+{
+ return ImGui::TabBarQueueChangeTabOrder(tab_bar,tab,dir);
+}
+CIMGUI_API bool igTabItemEx(ImGuiTabBar* tab_bar,const char* label,bool* p_open,ImGuiTabItemFlags flags)
+{
+ return ImGui::TabItemEx(tab_bar,label,p_open,flags);
+}
+CIMGUI_API void igTabItemCalcSize(ImVec2 *pOut,const char* label,bool has_close_button)
+{
+ *pOut = ImGui::TabItemCalcSize(label,has_close_button);
+}
+CIMGUI_API void igTabItemBackground(ImDrawList* draw_list,const ImRect bb,ImGuiTabItemFlags flags,ImU32 col)
+{
+ return ImGui::TabItemBackground(draw_list,bb,flags,col);
+}
+CIMGUI_API bool igTabItemLabelAndCloseButton(ImDrawList* draw_list,const ImRect bb,ImGuiTabItemFlags flags,ImVec2 frame_padding,const char* label,ImGuiID tab_id,ImGuiID close_button_id)
+{
+ return ImGui::TabItemLabelAndCloseButton(draw_list,bb,flags,frame_padding,label,tab_id,close_button_id);
+}
+CIMGUI_API void igRenderText(ImVec2 pos,const char* text,const char* text_end,bool hide_text_after_hash)
+{
+ return ImGui::RenderText(pos,text,text_end,hide_text_after_hash);
+}
+CIMGUI_API void igRenderTextWrapped(ImVec2 pos,const char* text,const char* text_end,float wrap_width)
+{
+ return ImGui::RenderTextWrapped(pos,text,text_end,wrap_width);
+}
+CIMGUI_API void igRenderTextClipped(const ImVec2 pos_min,const ImVec2 pos_max,const char* text,const char* text_end,const ImVec2* text_size_if_known,const ImVec2 align,const ImRect* clip_rect)
+{
+ return ImGui::RenderTextClipped(pos_min,pos_max,text,text_end,text_size_if_known,align,clip_rect);
+}
+CIMGUI_API void igRenderTextClippedEx(ImDrawList* draw_list,const ImVec2 pos_min,const ImVec2 pos_max,const char* text,const char* text_end,const ImVec2* text_size_if_known,const ImVec2 align,const ImRect* clip_rect)
+{
+ return ImGui::RenderTextClippedEx(draw_list,pos_min,pos_max,text,text_end,text_size_if_known,align,clip_rect);
+}
+CIMGUI_API void igRenderTextEllipsis(ImDrawList* draw_list,const ImVec2 pos_min,const ImVec2 pos_max,float clip_max_x,float ellipsis_max_x,const char* text,const char* text_end,const ImVec2* text_size_if_known)
+{
+ return ImGui::RenderTextEllipsis(draw_list,pos_min,pos_max,clip_max_x,ellipsis_max_x,text,text_end,text_size_if_known);
+}
+CIMGUI_API void igRenderFrame(ImVec2 p_min,ImVec2 p_max,ImU32 fill_col,bool border,float rounding)
+{
+ return ImGui::RenderFrame(p_min,p_max,fill_col,border,rounding);
+}
+CIMGUI_API void igRenderFrameBorder(ImVec2 p_min,ImVec2 p_max,float rounding)
+{
+ return ImGui::RenderFrameBorder(p_min,p_max,rounding);
+}
+CIMGUI_API void igRenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list,ImVec2 p_min,ImVec2 p_max,ImU32 fill_col,float grid_step,ImVec2 grid_off,float rounding,int rounding_corners_flags)
+{
+ return ImGui::RenderColorRectWithAlphaCheckerboard(draw_list,p_min,p_max,fill_col,grid_step,grid_off,rounding,rounding_corners_flags);
+}
+CIMGUI_API void igRenderNavHighlight(const ImRect bb,ImGuiID id,ImGuiNavHighlightFlags flags)
+{
+ return ImGui::RenderNavHighlight(bb,id,flags);
+}
+CIMGUI_API const char* igFindRenderedTextEnd(const char* text,const char* text_end)
+{
+ return ImGui::FindRenderedTextEnd(text,text_end);
+}
+CIMGUI_API void igLogRenderedText(const ImVec2* ref_pos,const char* text,const char* text_end)
+{
+ return ImGui::LogRenderedText(ref_pos,text,text_end);
+}
+CIMGUI_API void igRenderArrow(ImDrawList* draw_list,ImVec2 pos,ImU32 col,ImGuiDir dir,float scale)
+{
+ return ImGui::RenderArrow(draw_list,pos,col,dir,scale);
+}
+CIMGUI_API void igRenderBullet(ImDrawList* draw_list,ImVec2 pos,ImU32 col)
+{
+ return ImGui::RenderBullet(draw_list,pos,col);
+}
+CIMGUI_API void igRenderCheckMark(ImDrawList* draw_list,ImVec2 pos,ImU32 col,float sz)
+{
+ return ImGui::RenderCheckMark(draw_list,pos,col,sz);
+}
+CIMGUI_API void igRenderMouseCursor(ImDrawList* draw_list,ImVec2 pos,float scale,ImGuiMouseCursor mouse_cursor,ImU32 col_fill,ImU32 col_border,ImU32 col_shadow)
+{
+ return ImGui::RenderMouseCursor(draw_list,pos,scale,mouse_cursor,col_fill,col_border,col_shadow);
+}
+CIMGUI_API void igRenderArrowPointingAt(ImDrawList* draw_list,ImVec2 pos,ImVec2 half_sz,ImGuiDir direction,ImU32 col)
+{
+ return ImGui::RenderArrowPointingAt(draw_list,pos,half_sz,direction,col);
+}
+CIMGUI_API void igRenderRectFilledRangeH(ImDrawList* draw_list,const ImRect rect,ImU32 col,float x_start_norm,float x_end_norm,float rounding)
+{
+ return ImGui::RenderRectFilledRangeH(draw_list,rect,col,x_start_norm,x_end_norm,rounding);
+}
+CIMGUI_API void igTextEx(const char* text,const char* text_end,ImGuiTextFlags flags)
+{
+ return ImGui::TextEx(text,text_end,flags);
+}
+CIMGUI_API bool igButtonEx(const char* label,const ImVec2 size_arg,ImGuiButtonFlags flags)
+{
+ return ImGui::ButtonEx(label,size_arg,flags);
+}
+CIMGUI_API bool igCloseButton(ImGuiID id,const ImVec2 pos)
+{
+ return ImGui::CloseButton(id,pos);
+}
+CIMGUI_API bool igCollapseButton(ImGuiID id,const ImVec2 pos)
+{
+ return ImGui::CollapseButton(id,pos);
+}
+CIMGUI_API bool igArrowButtonEx(const char* str_id,ImGuiDir dir,ImVec2 size_arg,ImGuiButtonFlags flags)
+{
+ return ImGui::ArrowButtonEx(str_id,dir,size_arg,flags);
+}
+CIMGUI_API void igScrollbar(ImGuiAxis axis)
+{
+ return ImGui::Scrollbar(axis);
+}
+CIMGUI_API bool igScrollbarEx(const ImRect bb,ImGuiID id,ImGuiAxis axis,float* p_scroll_v,float avail_v,float contents_v,ImDrawCornerFlags rounding_corners)
+{
+ return ImGui::ScrollbarEx(bb,id,axis,p_scroll_v,avail_v,contents_v,rounding_corners);
+}
+CIMGUI_API void igGetWindowScrollbarRect(ImRect *pOut,ImGuiWindow* window,ImGuiAxis axis)
+{
+ *pOut = ImGui::GetWindowScrollbarRect(window,axis);
+}
+CIMGUI_API ImGuiID igGetWindowScrollbarID(ImGuiWindow* window,ImGuiAxis axis)
+{
+ return ImGui::GetWindowScrollbarID(window,axis);
+}
+CIMGUI_API ImGuiID igGetWindowResizeID(ImGuiWindow* window,int n)
+{
+ return ImGui::GetWindowResizeID(window,n);
+}
+CIMGUI_API void igSeparatorEx(ImGuiSeparatorFlags flags)
+{
+ return ImGui::SeparatorEx(flags);
+}
+CIMGUI_API bool igButtonBehavior(const ImRect bb,ImGuiID id,bool* out_hovered,bool* out_held,ImGuiButtonFlags flags)
+{
+ return ImGui::ButtonBehavior(bb,id,out_hovered,out_held,flags);
+}
+CIMGUI_API bool igDragBehavior(ImGuiID id,ImGuiDataType data_type,void* p_v,float v_speed,const void* p_min,const void* p_max,const char* format,float power,ImGuiDragFlags flags)
+{
+ return ImGui::DragBehavior(id,data_type,p_v,v_speed,p_min,p_max,format,power,flags);
+}
+CIMGUI_API bool igSliderBehavior(const ImRect bb,ImGuiID id,ImGuiDataType data_type,void* p_v,const void* p_min,const void* p_max,const char* format,float power,ImGuiSliderFlags flags,ImRect* out_grab_bb)
+{
+ return ImGui::SliderBehavior(bb,id,data_type,p_v,p_min,p_max,format,power,flags,out_grab_bb);
+}
+CIMGUI_API bool igSplitterBehavior(const ImRect bb,ImGuiID id,ImGuiAxis axis,float* size1,float* size2,float min_size1,float min_size2,float hover_extend,float hover_visibility_delay)
+{
+ return ImGui::SplitterBehavior(bb,id,axis,size1,size2,min_size1,min_size2,hover_extend,hover_visibility_delay);
+}
+CIMGUI_API bool igTreeNodeBehavior(ImGuiID id,ImGuiTreeNodeFlags flags,const char* label,const char* label_end)
+{
+ return ImGui::TreeNodeBehavior(id,flags,label,label_end);
+}
+CIMGUI_API bool igTreeNodeBehaviorIsOpen(ImGuiID id,ImGuiTreeNodeFlags flags)
+{
+ return ImGui::TreeNodeBehaviorIsOpen(id,flags);
+}
+CIMGUI_API void igTreePushOverrideID(ImGuiID id)
+{
+ return ImGui::TreePushOverrideID(id);
+}
+CIMGUI_API const ImGuiDataTypeInfo* igDataTypeGetInfo(ImGuiDataType data_type)
+{
+ return ImGui::DataTypeGetInfo(data_type);
+}
+CIMGUI_API int igDataTypeFormatString(char* buf,int buf_size,ImGuiDataType data_type,const void* p_data,const char* format)
+{
+ return ImGui::DataTypeFormatString(buf,buf_size,data_type,p_data,format);
+}
+CIMGUI_API void igDataTypeApplyOp(ImGuiDataType data_type,int op,void* output,void* arg_1,const void* arg_2)
+{
+ return ImGui::DataTypeApplyOp(data_type,op,output,arg_1,arg_2);
+}
+CIMGUI_API bool igDataTypeApplyOpFromText(const char* buf,const char* initial_value_buf,ImGuiDataType data_type,void* p_data,const char* format)
+{
+ return ImGui::DataTypeApplyOpFromText(buf,initial_value_buf,data_type,p_data,format);
+}
+CIMGUI_API bool igInputTextEx(const char* label,const char* hint,char* buf,int buf_size,const ImVec2 size_arg,ImGuiInputTextFlags flags,ImGuiInputTextCallback callback,void* user_data)
+{
+ return ImGui::InputTextEx(label,hint,buf,buf_size,size_arg,flags,callback,user_data);
+}
+CIMGUI_API bool igTempInputText(const ImRect bb,ImGuiID id,const char* label,char* buf,int buf_size,ImGuiInputTextFlags flags)
+{
+ return ImGui::TempInputText(bb,id,label,buf,buf_size,flags);
+}
+CIMGUI_API bool igTempInputScalar(const ImRect bb,ImGuiID id,const char* label,ImGuiDataType data_type,void* p_data,const char* format)
+{
+ return ImGui::TempInputScalar(bb,id,label,data_type,p_data,format);
+}
+CIMGUI_API bool igTempInputIsActive(ImGuiID id)
+{
+ return ImGui::TempInputIsActive(id);
+}
+CIMGUI_API ImGuiInputTextState* igGetInputTextState(ImGuiID id)
+{
+ return ImGui::GetInputTextState(id);
+}
+CIMGUI_API void igColorTooltip(const char* text,const float* col,ImGuiColorEditFlags flags)
+{
+ return ImGui::ColorTooltip(text,col,flags);
+}
+CIMGUI_API void igColorEditOptionsPopup(const float* col,ImGuiColorEditFlags flags)
+{
+ return ImGui::ColorEditOptionsPopup(col,flags);
+}
+CIMGUI_API void igColorPickerOptionsPopup(const float* ref_col,ImGuiColorEditFlags flags)
+{
+ return ImGui::ColorPickerOptionsPopup(ref_col,flags);
+}
+CIMGUI_API int igPlotEx(ImGuiPlotType plot_type,const char* label,float(*values_getter)(void* data,int idx),void* data,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 frame_size)
+{
+ return ImGui::PlotEx(plot_type,label,values_getter,data,values_count,values_offset,overlay_text,scale_min,scale_max,frame_size);
+}
+CIMGUI_API void igShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list,int vert_start_idx,int vert_end_idx,ImVec2 gradient_p0,ImVec2 gradient_p1,ImU32 col0,ImU32 col1)
+{
+ return ImGui::ShadeVertsLinearColorGradientKeepAlpha(draw_list,vert_start_idx,vert_end_idx,gradient_p0,gradient_p1,col0,col1);
+}
+CIMGUI_API void igShadeVertsLinearUV(ImDrawList* draw_list,int vert_start_idx,int vert_end_idx,const ImVec2 a,const ImVec2 b,const ImVec2 uv_a,const ImVec2 uv_b,bool clamp)
+{
+ return ImGui::ShadeVertsLinearUV(draw_list,vert_start_idx,vert_end_idx,a,b,uv_a,uv_b,clamp);
+}
+CIMGUI_API void igGcCompactTransientWindowBuffers(ImGuiWindow* window)
+{
+ return ImGui::GcCompactTransientWindowBuffers(window);
+}
+CIMGUI_API void igGcAwakeTransientWindowBuffers(ImGuiWindow* window)
+{
+ return ImGui::GcAwakeTransientWindowBuffers(window);
+}
+CIMGUI_API void igDebugDrawItemRect(ImU32 col)
+{
+ return ImGui::DebugDrawItemRect(col);
+}
+CIMGUI_API void igDebugStartItemPicker()
+{
+ return ImGui::DebugStartItemPicker();
+}
+CIMGUI_API bool igImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
+{
+ return ImFontAtlasBuildWithStbTruetype(atlas);
+}
+CIMGUI_API void igImFontAtlasBuildInit(ImFontAtlas* atlas)
+{
+ return ImFontAtlasBuildInit(atlas);
+}
+CIMGUI_API void igImFontAtlasBuildSetupFont(ImFontAtlas* atlas,ImFont* font,ImFontConfig* font_config,float ascent,float descent)
+{
+ return ImFontAtlasBuildSetupFont(atlas,font,font_config,ascent,descent);
+}
+CIMGUI_API void igImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas,void* stbrp_context_opaque)
+{
+ return ImFontAtlasBuildPackCustomRects(atlas,stbrp_context_opaque);
+}
+CIMGUI_API void igImFontAtlasBuildFinish(ImFontAtlas* atlas)
+{
+ return ImFontAtlasBuildFinish(atlas);
+}
+CIMGUI_API void igImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256],float in_multiply_factor)
+{
+ return ImFontAtlasBuildMultiplyCalcLookupTable(out_table,in_multiply_factor);
+}
+CIMGUI_API void igImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256],unsigned char* pixels,int x,int y,int w,int h,int stride)
+{
+ return ImFontAtlasBuildMultiplyRectAlpha8(table,pixels,x,y,w,h,stride);
+}
+
+
+
+/////////////////////////////manual written functions
+CIMGUI_API void igLogText(CONST char *fmt, ...)
+{
+ char buffer[256];
+ va_list args;
+ va_start(args, fmt);
+ vsnprintf(buffer, 256, fmt, args);
+ va_end(args);
+
+ ImGui::LogText("%s", buffer);
+}
+CIMGUI_API void ImGuiTextBuffer_appendf(struct ImGuiTextBuffer *buffer, const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ buffer->appendfv(fmt, args);
+ va_end(args);
+}
+
+CIMGUI_API float igGET_FLT_MAX()
+{
+ return FLT_MAX;
+}
+CIMGUI_API void igColorConvertRGBtoHSV(float r,float g,float b,float *out_h,float *out_s,float *out_v)
+{
+ ImGui::ColorConvertRGBtoHSV(r,g,b,*out_h,*out_s,*out_v);
+}
+CIMGUI_API void igColorConvertHSVtoRGB(float h,float s,float v,float *out_r,float *out_g,float *out_b)
+{
+ ImGui::ColorConvertHSVtoRGB(h,s,v,*out_r,*out_g,*out_b);
+}
+
+CIMGUI_API ImVector_ImWchar* ImVector_ImWchar_create()
+{
+ return IM_NEW(ImVector) ();
+}
+
+CIMGUI_API void ImVector_ImWchar_destroy(ImVector_ImWchar* self)
+{
+ IM_DELETE(self);
+}
+
+CIMGUI_API void ImVector_ImWchar_Init(ImVector_ImWchar* p)
+{
+ IM_PLACEMENT_NEW(p) ImVector();
+}
+CIMGUI_API void ImVector_ImWchar_UnInit(ImVector_ImWchar* p)
+{
+ p->~ImVector();
+}
+
+
+#ifdef IMGUI_HAS_DOCK
+
+// NOTE: Some function pointers in the ImGuiPlatformIO structure are not C-compatible because of their
+// use of a complex return type. To work around this, we store a custom CimguiStorage object inside
+// ImGuiIO::BackendLanguageUserData, which contains C-compatible function pointer variants for these
+// functions. When a user function pointer is provided, we hook up the underlying ImGuiPlatformIO
+// function pointer to a thunk which accesses the user function pointer through CimguiStorage.
+
+struct CimguiStorage
+{
+ void(*Platform_GetWindowPos)(ImGuiViewport* vp, ImVec2* out_pos);
+ void(*Platform_GetWindowSize)(ImGuiViewport* vp, ImVec2* out_pos);
+};
+
+// Gets a reference to the CimguiStorage object stored in the current ImGui context's BackendLanguageUserData.
+CimguiStorage& GetCimguiStorage()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (io.BackendLanguageUserData == NULL)
+ {
+ io.BackendLanguageUserData = new CimguiStorage();
+ }
+
+ return *(CimguiStorage*)io.BackendLanguageUserData;
+}
+
+// Thunk satisfying the signature of ImGuiPlatformIO::Platform_GetWindowPos.
+ImVec2 Platform_GetWindowPos_hook(ImGuiViewport* vp)
+{
+ ImVec2 pos;
+ GetCimguiStorage().Platform_GetWindowPos(vp, &pos);
+ return pos;
+};
+
+// Fully C-compatible function pointer setter for ImGuiPlatformIO::Platform_GetWindowPos.
+CIMGUI_API void ImGuiPlatformIO_Set_Platform_GetWindowPos(ImGuiPlatformIO* platform_io, void(*user_callback)(ImGuiViewport* vp, ImVec2* out_pos))
+{
+ CimguiStorage& storage = GetCimguiStorage();
+ storage.Platform_GetWindowPos = user_callback;
+ platform_io->Platform_GetWindowPos = &Platform_GetWindowPos_hook;
+}
+
+// Thunk satisfying the signature of ImGuiPlatformIO::Platform_GetWindowSize.
+ImVec2 Platform_GetWindowSize_hook(ImGuiViewport* vp)
+{
+ ImVec2 size;
+ GetCimguiStorage().Platform_GetWindowSize(vp, &size);
+ return size;
+};
+
+// Fully C-compatible function pointer setter for ImGuiPlatformIO::Platform_GetWindowSize.
+CIMGUI_API void ImGuiPlatformIO_Set_Platform_GetWindowSize(ImGuiPlatformIO* platform_io, void(*user_callback)(ImGuiViewport* vp, ImVec2* out_size))
+{
+ CimguiStorage& storage = GetCimguiStorage();
+ storage.Platform_GetWindowSize = user_callback;
+ platform_io->Platform_GetWindowSize = &Platform_GetWindowSize_hook;
}
+#endif
diff --git a/Sources/CImGui/imgui/imconfig.h b/Sources/CImGui/imgui/imconfig.h
index 45e75ec..c6817de 100644
--- a/Sources/CImGui/imgui/imconfig.h
+++ b/Sources/CImGui/imgui/imconfig.h
@@ -14,6 +14,7 @@
#pragma once
//---- Define assertion handler. Defaults to calling assert().
+// If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
@@ -22,21 +23,23 @@
//#define IMGUI_API __declspec( dllexport )
//#define IMGUI_API __declspec( dllimport )
-//---- Don't define obsolete functions/enums names. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
+//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
-//---- Don't implement demo windows functionality (ShowDemoWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty)
-// It is very strongly recommended to NOT disable the demo windows during development. Please read the comments in imgui_demo.cpp.
-//#define IMGUI_DISABLE_DEMO_WINDOWS
-//#define IMGUI_DISABLE_METRICS_WINDOW
+//---- Disable all of Dear ImGui or don't implement standard windows.
+// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
+//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
+//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended.
+//#define IMGUI_DISABLE_METRICS_WINDOW // Disable debug/metrics window: ShowMetricsWindow() will be empty.
//---- Don't implement some functions to reduce linkage requirements.
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc.
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow.
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
-//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices').
-//#define IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself if you don't want to link with vsnprintf.
-//#define IMGUI_DISABLE_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 wrapper so you can implement them yourself. Declare your prototypes in imconfig.h.
+//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
+//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
+//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
+//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
//---- Include imgui_user.h at the end of imgui.h as a convenience
@@ -45,6 +48,9 @@
//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
//#define IMGUI_USE_BGRA_PACKED_COLOR
+//---- Use 32-bit for ImWchar (default is 16-bit) to support full unicode code points.
+//#define IMGUI_USE_WCHAR32
+
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
// By default the embedded implementations are declared static and not available outside of imgui cpp files.
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
@@ -52,6 +58,10 @@
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
+//---- Unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined, use the much faster STB sprintf library implementation of vsnprintf instead of the one from the default C library.
+// Note that stb_sprintf.h is meant to be provided by the user and available in the include path at compile time. Also, the compatibility checks of the arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf.
+// #define IMGUI_USE_STB_SPRINTF
+
//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
// This will be inlined as part of ImVec2 and ImVec4 class declarations.
/*
@@ -64,9 +74,9 @@
operator MyVec4() const { return MyVec4(x,y,z,w); }
*/
-//---- Using 32-bits vertex indices (default is 16-bits) is one way to allow large meshes with more than 64K vertices.
-// Your renderer back-end will need to support it (most example renderer back-ends support both 16/32-bits indices).
-// Another way to allow large meshes while keeping 16-bits indices is to handle ImDrawCmd::VtxOffset in your renderer.
+//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
+// Your renderer back-end will need to support it (most example renderer back-ends support both 16/32-bit indices).
+// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
//#define ImDrawIdx unsigned int
@@ -76,14 +86,19 @@
//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
//#define ImDrawCallback MyImDrawCallback
-//---- Debug Tools
-// Use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.
+//---- Debug Tools: Macro to break in Debugger
+// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
//#define IM_DEBUG_BREAK IM_ASSERT(0)
//#define IM_DEBUG_BREAK __debugbreak()
-// Have the Item Picker break in the ItemAdd() function instead of ItemHoverable() - which is earlier in the code, will catch a few extra items, allow picking items other than Hovered one.
+
+//---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(),
+// (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.)
// This adds a small runtime cost which is why it is not enabled by default.
//#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
+//---- Debug Tools: Enable slower asserts
+//#define IMGUI_DEBUG_PARANOID
+
//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
/*
namespace ImGui
diff --git a/Sources/CImGui/imgui/imgui.cpp b/Sources/CImGui/imgui/imgui.cpp
index 2787493..b57bb19 100644
--- a/Sources/CImGui/imgui/imgui.cpp
+++ b/Sources/CImGui/imgui/imgui.cpp
@@ -1,18 +1,26 @@
-// dear imgui, v1.74 WIP
+// dear imgui, v1.76
// (main code and documentation)
-// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
-// Newcomers, read 'Programmer guide' below for notes on how to setup Dear ImGui in your codebase.
-// Get latest version at https://github.com/ocornut/imgui
-// Releases change-log at https://github.com/ocornut/imgui/releases
-// Technical Support for Getting Started https://discourse.dearimgui.org/c/getting-started
-// Gallery (please post your screenshots/video there!): https://github.com/ocornut/imgui/issues/2847
+// Help:
+// - Read FAQ at http://dearimgui.org/faq
+// - Newcomers, read 'Programmer guide' below for notes on how to setup Dear ImGui in your codebase.
+// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code. All applications in examples/ are doing that.
+// Read imgui.cpp for details, links and comments.
+
+// Resources:
+// - FAQ http://dearimgui.org/faq
+// - Homepage & latest https://github.com/ocornut/imgui
+// - Releases & changelog https://github.com/ocornut/imgui/releases
+// - Gallery https://github.com/ocornut/imgui/issues/3075 (please post your screenshots/video there!)
+// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
+// - Wiki https://github.com/ocornut/imgui/wiki
+// - Issues & support https://github.com/ocornut/imgui/issues
// Developed by Omar Cornut and every direct or indirect contributors to the GitHub.
// See LICENSE.txt for copyright and licensing details (standard MIT License).
// This library is free but I need your support to sustain development and maintenance.
-// Businesses: you can support continued maintenance and development via support contracts or sponsoring, see docs/README.
-// Individuals: you can support continued maintenance and development via donations or Patreon https://www.patreon.com/imgui.
+// Businesses: you can support continued development via invoiced technical support, maintenance and sponsoring contracts. Please reach out to "contact AT dearimgui.org".
+// Individuals: you can support continued development via donations. See docs/README or web page.
// It is recommended that you don't modify imgui.cpp! It will become difficult for you to update the library.
// Note that 'ImGui::' being a namespace, you can add functions into the namespace from your own source files, without
@@ -29,12 +37,12 @@ DOCUMENTATION
- MISSION STATEMENT
- END-USER GUIDE
- PROGRAMMER GUIDE
- - Read first.
- - How to update to a newer version of Dear ImGui.
- - Getting started with integrating Dear ImGui in your code/engine.
- - This is how a simple application may look like (2 variations).
- - This is how a simple rendering function may look like.
- - Using gamepad/keyboard navigation controls.
+ - READ FIRST
+ - HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI
+ - GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE
+ - HOW A SIMPLE APPLICATION MAY LOOK LIKE
+ - HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE
+ - USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS
- API BREAKING CHANGES (read me when you update!)
- FREQUENTLY ASKED QUESTIONS (FAQ)
- Read all answers online: https://www.dearimgui.org/faq, or in docs/FAQ.md (with a Markdown viewer)
@@ -42,18 +50,24 @@ DOCUMENTATION
CODE
(search for "[SECTION]" in the code to find them)
+// [SECTION] INCLUDES
// [SECTION] FORWARD DECLARATIONS
// [SECTION] CONTEXT AND MEMORY ALLOCATORS
-// [SECTION] MAIN USER FACING STRUCTURES (ImGuiStyle, ImGuiIO)
-// [SECTION] MISC HELPERS/UTILITIES (Maths, String, Format, Hash, File functions)
+// [SECTION] USER FACING STRUCTURES (ImGuiStyle, ImGuiIO)
+// [SECTION] MISC HELPERS/UTILITIES (Geometry functions)
+// [SECTION] MISC HELPERS/UTILITIES (String, Format, Hash functions)
+// [SECTION] MISC HELPERS/UTILITIES (File functions)
// [SECTION] MISC HELPERS/UTILITIES (ImText* functions)
// [SECTION] MISC HELPERS/UTILITIES (Color functions)
// [SECTION] ImGuiStorage
// [SECTION] ImGuiTextFilter
// [SECTION] ImGuiTextBuffer
// [SECTION] ImGuiListClipper
+// [SECTION] STYLING
// [SECTION] RENDER HELPERS
// [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!)
+// [SECTION] ERROR CHECKING
+// [SECTION] LAYOUT
// [SECTION] SCROLLING
// [SECTION] TOOLTIPS
// [SECTION] POPUPS
@@ -61,8 +75,6 @@ CODE
// [SECTION] DRAG AND DROP
// [SECTION] LOGGING/CAPTURING
// [SECTION] SETTINGS
-// [SECTION] VIEWPORTS, PLATFORM WINDOWS
-// [SECTION] DOCKING
// [SECTION] PLATFORM DEPENDENT HELPERS
// [SECTION] METRICS/DEBUG WINDOW
@@ -119,15 +131,15 @@ CODE
PROGRAMMER GUIDE
================
- READ FIRST:
-
+ READ FIRST
+ ----------
- Remember to read the FAQ (https://www.dearimgui.org/faq)
- Your code creates the UI, if your code doesn't run the UI is gone! The UI can be highly dynamic, there are no construction
or destruction steps, less superfluous data retention on your side, less state duplication, less state synchronization, less bugs.
- Call and read ImGui::ShowDemoWindow() for demo code demonstrating most features.
- The library is designed to be built from sources. Avoid pre-compiled binaries and packaged versions. See imconfig.h to configure your build.
- Dear ImGui is an implementation of the IMGUI paradigm (immediate-mode graphical user interface, a term coined by Casey Muratori).
- You can learn about IMGUI principles at http://www.johno.se/book/imgui.html, http://mollyrocket.com/861 & more links docs/README.md.
+ You can learn about IMGUI principles at http://www.johno.se/book/imgui.html, http://mollyrocket.com/861 & more links in the FAQ.
- Dear ImGui is a "single pass" rasterizing implementation of the IMGUI paradigm, aimed at ease of use and high-performances.
For every application frame your UI code will be called only once. This is in contrast to e.g. Unity's own implementation of an IMGUI,
where the UI code is called multiple times ("multiple passes") from a single entry point. There are pros and cons to both approaches.
@@ -141,8 +153,9 @@ CODE
However, imgui_internal.h can optionally export math operators for ImVec2/ImVec4, which we use in this codebase.
- C++: pay attention that ImVector<> manipulates plain-old-data and does not honor construction/destruction (avoid using it in your code!).
- HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI:
+ HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI
+ ----------------------------------------------
- Overwrite all the sources files except for imconfig.h (if you have made modification to your copy of imconfig.h)
- Or maintain your own branch where you have imconfig.h modified.
- Read the "API BREAKING CHANGES" section (below). This is where we list occasional API breaking changes.
@@ -151,11 +164,13 @@ CODE
likely be a comment about it. Please report any issue to the GitHub page!
- Try to keep your copy of dear imgui reasonably up to date.
- GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE:
+ GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE
+ ---------------------------------------------------------------
- Run and study the examples and demo in imgui_demo.cpp to get acquainted with the library.
+ - In the majority of cases you should be able to use unmodified back-ends files available in the examples/ folder.
- Add the Dear ImGui source files to your projects or using your preferred build system.
- It is recommended you build and statically link the .cpp files as part of your project and not as shared library (DLL).
+ It is recommended you build and statically link the .cpp files as part of your project and NOT as shared library (DLL).
- You can later customize the imconfig.h file to tweak some compile-time behavior, such as integrating Dear ImGui types with your own maths types.
- When using Dear ImGui, your programming IDE is your friend: follow the declaration of variables, functions and types to find comments about them.
- Dear ImGui never touches or knows about your GPU state. The only function that knows about GPU is the draw function that you provide.
@@ -164,8 +179,11 @@ CODE
- Refer to the bindings and demo applications in the examples/ folder for instruction on how to setup your code.
- If you are running over a standard OS with a common graphics API, you should be able to use unmodified imgui_impl_*** files from the examples/ folder.
- HOW A SIMPLE APPLICATION MAY LOOK LIKE:
- EXHIBIT 1: USING THE EXAMPLE BINDINGS (imgui_impl_XXX.cpp files from the examples/ folder).
+
+ HOW A SIMPLE APPLICATION MAY LOOK LIKE
+ --------------------------------------
+ EXHIBIT 1: USING THE EXAMPLE BINDINGS (= imgui_impl_XXX.cpp files from the examples/ folder).
+ The sub-folders in examples/ contains examples applications following this structure.
// Application init: create a dear imgui context, setup some options, load fonts
ImGui::CreateContext();
@@ -174,7 +192,7 @@ CODE
// TODO: Fill optional fields of the io structure later.
// TODO: Load TTF/OTF fonts if you don't want to use the default font.
- // Initialize helper Platform and Renderer bindings (here we are using imgui_impl_win32 and imgui_impl_dx11)
+ // Initialize helper Platform and Renderer bindings (here we are using imgui_impl_win32.cpp and imgui_impl_dx11.cpp)
ImGui_ImplWin32_Init(hwnd);
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
@@ -200,8 +218,7 @@ CODE
ImGui_ImplWin32_Shutdown();
ImGui::DestroyContext();
- HOW A SIMPLE APPLICATION MAY LOOK LIKE:
- EXHIBIT 2: IMPLEMENTING CUSTOM BINDING / CUSTOM ENGINE.
+ EXHIBIT 2: IMPLEMENTING CUSTOM BINDING / CUSTOM ENGINE
// Application init: create a dear imgui context, setup some options, load fonts
ImGui::CreateContext();
@@ -255,7 +272,14 @@ CODE
// Shutdown
ImGui::DestroyContext();
- HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE:
+ To decide whether to dispatch mouse/keyboard inputs to Dear ImGui to the rest your application,
+ you should read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags!
+ Please read the FAQ and example applications for details about this!
+
+
+ HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE
+ ---------------------------------------------
+ The bindings in impl_impl_XXX.cpp files contains many working implementations of a rendering function.
void void MyImGuiRenderFunction(ImDrawData* draw_data)
{
@@ -293,7 +317,7 @@ CODE
MyEngineScissor((int)(pcmd->ClipRect.x - pos.x), (int)(pcmd->ClipRect.y - pos.y), (int)(pcmd->ClipRect.z - pos.x), (int)(pcmd->ClipRect.w - pos.y));
// Render 'pcmd->ElemCount/3' indexed triangles.
- // By default the indices ImDrawIdx are 16-bits, you can change them to 32-bits in imconfig.h if your engine doesn't support 16-bits indices.
+ // By default the indices ImDrawIdx are 16-bit, you can change them to 32-bit in imconfig.h if your engine doesn't support 16-bit indices.
MyEngineDrawIndexedTriangles(pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer, vtx_buffer);
}
idx_buffer += pcmd->ElemCount;
@@ -301,18 +325,22 @@ CODE
}
}
- - The examples/ folders contains many actual implementation of the pseudo-codes above.
- - When calling NewFrame(), the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags are updated.
- They tell you if Dear ImGui intends to use your inputs. When a flag is set you want to hide the corresponding inputs from the
- rest of your application. In every cases you need to pass on the inputs to Dear ImGui.
- - Refer to the FAQ for more information. Amusingly, it is called a FAQ because people frequently run into the same issues!
USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS
-
+ ------------------------------------------
- The gamepad/keyboard navigation is fairly functional and keeps being improved.
- - Gamepad support is particularly useful to use dear imgui on a console system (e.g. PS4, Switch, XB1) without a mouse!
+ - Gamepad support is particularly useful to use Dear ImGui on a console system (e.g. PS4, Switch, XB1) without a mouse!
- You can ask questions and report issues at https://github.com/ocornut/imgui/issues/787
- The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable.
+ - Keyboard:
+ - Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable.
+ NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays.
+ - When keyboard navigation is active (io.NavActive + ImGuiConfigFlags_NavEnableKeyboard), the io.WantCaptureKeyboard flag
+ will be set. For more advanced uses, you may want to read from:
+ - io.NavActive: true when a window is focused and it doesn't have the ImGuiWindowFlags_NoNavInputs flag set.
+ - io.NavVisible: true when the navigation cursor is visible (and usually goes false when mouse is used).
+ - or query focus information with e.g. IsWindowFocused(ImGuiFocusedFlags_AnyWindow), IsItemFocused() etc. functions.
+ Please reach out if you think the game vs navigation input sharing could be improved.
- Gamepad:
- Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable.
- Backend: Set io.BackendFlags |= ImGuiBackendFlags_HasGamepad + fill the io.NavInputs[] fields before calling NewFrame().
@@ -324,15 +352,6 @@ CODE
- You can download PNG/PSD files depicting the gamepad controls for common controllers at: http://goo.gl/9LgVZW.
- If you need to share inputs between your game and the imgui parts, the easiest approach is to go all-or-nothing, with a buttons combo
to toggle the target. Please reach out if you think the game vs navigation input sharing could be improved.
- - Keyboard:
- - Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable.
- NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays.
- - When keyboard navigation is active (io.NavActive + ImGuiConfigFlags_NavEnableKeyboard), the io.WantCaptureKeyboard flag
- will be set. For more advanced uses, you may want to read from:
- - io.NavActive: true when a window is focused and it doesn't have the ImGuiWindowFlags_NoNavInputs flag set.
- - io.NavVisible: true when the navigation cursor is visible (and usually goes false when mouse is used).
- - or query focus information with e.g. IsWindowFocused(ImGuiFocusedFlags_AnyWindow), IsItemFocused() etc. functions.
- Please reach out if you think the game vs navigation input sharing could be improved.
- Mouse:
- PS4 users: Consider emulating a mouse cursor with DualShock4 touch pad or a spare analog stick as a mouse-emulation fallback.
- Consoles/Tablet/Phone users: Consider using a Synergy 1.x server (on your PC) + uSynergy.c (on your console/tablet/phone app) to share your PC mouse/keyboard.
@@ -353,22 +372,37 @@ CODE
When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
- (Docking/Viewport Branch)
- - 2019/XX/XX (1.XX) - when multi-viewports are enabled, all positions will be in your natural OS coordinates space. It means that:
- - reference to hard-coded positions such as in SetNextWindowPos(ImVec2(0,0)) are probably not what you want anymore.
- you may use GetMainViewport()->Pos to offset hard-coded positions, e.g. SetNextWindowPos(GetMainViewport()->Pos)
- - likewise io.MousePos and GetMousePos() will use OS coordinates.
- If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
- - 2019/XX/XX (1.XX) - Moved IME support functions from io.ImeSetInputScreenPosFn, io.ImeWindowHandle to the PlatformIO api.
-
-
+ - 2020/01/22 (1.75) - ImDrawList::AddCircle()/AddCircleFilled() functions don't accept negative radius any more.
+ - 2019/12/17 (1.75) - [undid this change in 1.76] made Columns() limited to 64 columns by asserting above that limit. While the current code technically supports it, future code may not so we're putting the restriction ahead.
+ - 2019/12/13 (1.75) - [imgui_internal.h] changed ImRect() default constructor initializes all fields to 0.0f instead of (FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX). If you used ImRect::Add() to create bounding boxes by adding multiple points into it, you may need to fix your initial value.
+ - 2019/12/08 (1.75) - removed redirecting functions/enums that were marked obsolete in 1.53 (December 2017):
+ - ShowTestWindow() -> use ShowDemoWindow()
+ - IsRootWindowFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootWindow)
+ - IsRootWindowOrAnyChildFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows)
+ - SetNextWindowContentWidth(w) -> use SetNextWindowContentSize(ImVec2(w, 0.0f)
+ - GetItemsLineHeightWithSpacing() -> use GetFrameHeightWithSpacing()
+ - ImGuiCol_ChildWindowBg -> use ImGuiCol_ChildBg
+ - ImGuiStyleVar_ChildWindowRounding -> use ImGuiStyleVar_ChildRounding
+ - ImGuiTreeNodeFlags_AllowOverlapMode -> use ImGuiTreeNodeFlags_AllowItemOverlap
+ - IMGUI_DISABLE_TEST_WINDOWS -> use IMGUI_DISABLE_DEMO_WINDOWS
+ - 2019/12/08 (1.75) - obsoleted calling ImDrawList::PrimReserve() with a negative count (which was the vaguely documented and rarely if ever used). Instead we added an explicit PrimUnreserve() API.
+ - 2019/12/06 (1.75) - removed implicit default parameter to IsMouseDragging(int button = 0) to be consistent with other mouse functions (none of the other functions have it).
+ - 2019/11/21 (1.74) - ImFontAtlas::AddCustomRectRegular() now requires an ID larger than 0x110000 (instead of 0x10000) to conform with supporting Unicode planes 1-16 in a future update. ID below 0x110000 will now assert.
+ - 2019/11/19 (1.74) - renamed IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS to IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS for consistency.
+ - 2019/11/19 (1.74) - renamed IMGUI_DISABLE_MATH_FUNCTIONS to IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS for consistency.
+ - 2019/10/22 (1.74) - removed redirecting functions/enums that were marked obsolete in 1.52 (October 2017):
+ - Begin() [old 5 args version] -> use Begin() [3 args], use SetNextWindowSize() SetNextWindowBgAlpha() if needed
+ - IsRootWindowOrAnyChildHovered() -> use IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows)
+ - AlignFirstTextHeightToWidgets() -> use AlignTextToFramePadding()
+ - SetNextWindowPosCenter() -> use SetNextWindowPos() with a pivot of (0.5f, 0.5f)
+ - ImFont::Glyph -> use ImFontGlyph
- 2019/10/14 (1.74) - inputs: Fixed a miscalculation in the keyboard/mouse "typematic" repeat delay/rate calculation, used by keys and e.g. repeating mouse buttons as well as the GetKeyPressedAmount() function.
if you were using a non-default value for io.KeyRepeatRate (previous default was 0.250), you can add +io.KeyRepeatDelay to it to compensate for the fix.
The function was triggering on: 0.0 and (delay+rate*N) where (N>=1). Fixed formula responds to (N>=0). Effectively it made io.KeyRepeatRate behave like it was set to (io.KeyRepeatRate + io.KeyRepeatDelay).
If you never altered io.KeyRepeatRate nor used GetKeyPressedAmount() this won't affect you.
- 2019/07/15 (1.72) - removed TreeAdvanceToLabelPos() which is rarely used and only does SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()). Kept redirection function (will obsolete).
- 2019/07/12 (1.72) - renamed ImFontAtlas::CustomRect to ImFontAtlasCustomRect. Kept redirection typedef (will obsolete).
- - 2019/06/14 (1.72) - removed redirecting functions/enums names that were marked obsolete in 1.51 (June 2017): ImGuiCol_Column*, ImGuiSetCond_*, IsItemHoveredRect(), IsPosHoveringAnyWindow(), IsMouseHoveringAnyWindow(), IsMouseHoveringWindow(), IMGUI_ONCE_UPON_A_FRAME. Grep this log for details and new names.
+ - 2019/06/14 (1.72) - removed redirecting functions/enums names that were marked obsolete in 1.51 (June 2017): ImGuiCol_Column*, ImGuiSetCond_*, IsItemHoveredRect(), IsPosHoveringAnyWindow(), IsMouseHoveringAnyWindow(), IsMouseHoveringWindow(), IMGUI_ONCE_UPON_A_FRAME. Grep this log for details and new names, or see how they were implemented until 1.71.
- 2019/06/07 (1.71) - rendering of child window outer decorations (bg color, border, scrollbars) is now performed as part of the parent window. If you have
overlapping child windows in a same parent, and relied on their relative z-order to be mapped to their submission order, this will affect your rendering.
This optimization is disabled if the parent window has no visual output, because it appears to be the most common situation leading to the creation of overlapping child windows.
@@ -479,14 +513,9 @@ CODE
- 2016/09/25 (1.50) - style.WindowTitleAlign is now a ImVec2 (ImGuiAlign enum was removed). set to (0.5f,0.5f) for horizontal+vertical centering, (0.0f,0.0f) for upper-left, etc.
- 2016/07/30 (1.50) - SameLine(x) with x>0.0f is now relative to left of column/group if any, and not always to left of window. This was sort of always the intent and hopefully breakage should be minimal.
- 2016/05/12 (1.49) - title bar (using ImGuiCol_TitleBg/ImGuiCol_TitleBgActive colors) isn't rendered over a window background (ImGuiCol_WindowBg color) anymore.
- If your TitleBg/TitleBgActive alpha was 1.0f or you are using the default theme it will not affect you.
- If your TitleBg/TitleBgActive alpha was <1.0f you need to tweak your custom theme to readjust for the fact that we don't draw a WindowBg background behind the title bar.
- This helper function will convert an old TitleBg/TitleBgActive color into a new one with the same visual output, given the OLD color and the OLD WindowBg color.
- ImVec4 ConvertTitleBgCol(const ImVec4& win_bg_col, const ImVec4& title_bg_col)
- {
- float new_a = 1.0f - ((1.0f - win_bg_col.w) * (1.0f - title_bg_col.w)), k = title_bg_col.w / new_a;
- return ImVec4((win_bg_col.x * win_bg_col.w + title_bg_col.x) * k, (win_bg_col.y * win_bg_col.w + title_bg_col.y) * k, (win_bg_col.z * win_bg_col.w + title_bg_col.z) * k, new_a);
- }
+ If your TitleBg/TitleBgActive alpha was 1.0f or you are using the default theme it will not affect you, otherwise if <1.0f you need tweak your custom theme to readjust for the fact that we don't draw a WindowBg background behind the title bar.
+ This helper function will convert an old TitleBg/TitleBgActive color into a new one with the same visual output, given the OLD color and the OLD WindowBg color:
+ ImVec4 ConvertTitleBgCol(const ImVec4& win_bg_col, const ImVec4& title_bg_col) { float new_a = 1.0f - ((1.0f - win_bg_col.w) * (1.0f - title_bg_col.w)), k = title_bg_col.w / new_a; return ImVec4((win_bg_col.x * win_bg_col.w + title_bg_col.x) * k, (win_bg_col.y * win_bg_col.w + title_bg_col.y) * k, (win_bg_col.z * win_bg_col.w + title_bg_col.z) * k, new_a); }
If this is confusing, pick the RGB value from title bar from an old screenshot and apply this as TitleBg/TitleBgActive. Or you may just create TitleBgActive from a tweaked TitleBg color.
- 2016/05/07 (1.49) - removed confusing set of GetInternalState(), GetInternalStateSize(), SetInternalState() functions. Now using CreateContext(), DestroyContext(), GetCurrentContext(), SetCurrentContext().
- 2016/05/02 (1.49) - renamed SetNextTreeNodeOpened() to SetNextTreeNodeOpen(), no redirection.
@@ -545,14 +574,13 @@ CODE
- 2015/02/01 (1.31) - removed IO.MemReallocFn (unused)
- 2015/01/19 (1.30) - renamed ImGuiStorage::GetIntPtr()/GetFloatPtr() to GetIntRef()/GetIntRef() because Ptr was conflicting with actual pointer storage functions.
- 2015/01/11 (1.30) - big font/image API change! now loads TTF file. allow for multiple fonts. no need for a PNG loader.
- (1.30) - removed GetDefaultFontData(). uses io.Fonts->GetTextureData*() API to retrieve uncompressed pixels.
- font init: { const void* png_data; unsigned int png_size; ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size); <..Upload texture to GPU..>; }
- became: { unsigned char* pixels; int width, height; io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); <..Upload texture to GPU>; io.Fonts->TexId = YourTextureIdentifier; }
- you now have more flexibility to load multiple TTF fonts and manage the texture buffer for internal needs.
- it is now recommended that you sample the font texture with bilinear interpolation.
- (1.30) - added texture identifier in ImDrawCmd passed to your render function (we can now render images). make sure to set io.Fonts->TexID.
- (1.30) - removed IO.PixelCenterOffset (unnecessary, can be handled in user projection matrix)
- (1.30) - removed ImGui::IsItemFocused() in favor of ImGui::IsItemActive() which handles all widgets
+ - 2015/01/11 (1.30) - removed GetDefaultFontData(). uses io.Fonts->GetTextureData*() API to retrieve uncompressed pixels.
+ - old: const void* png_data; unsigned int png_size; ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size); [..Upload texture to GPU..];
+ - new: unsigned char* pixels; int width, height; io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); [..Upload texture to GPU..]; io.Fonts->TexId = YourTexIdentifier;
+ you now have more flexibility to load multiple TTF fonts and manage the texture buffer for internal needs. It is now recommended that you sample the font texture with bilinear interpolation.
+ - 2015/01/11 (1.30) - added texture identifier in ImDrawCmd passed to your render function (we can now render images). make sure to set io.Fonts->TexID.
+ - 2015/01/11 (1.30) - removed IO.PixelCenterOffset (unnecessary, can be handled in user projection matrix)
+ - 2015/01/11 (1.30) - removed ImGui::IsItemFocused() in favor of ImGui::IsItemActive() which handles all widgets
- 2014/12/10 (1.18) - removed SetNewWindowDefaultPos() in favor of new generic API SetNextWindowPos(pos, ImGuiSetCondition_FirstUseEver)
- 2014/11/28 (1.17) - moved IO.Font*** options to inside the IO.Font-> structure (FontYOffset, FontTexUvForWhite, FontBaseScale, FontFallbackGlyph)
- 2014/11/26 (1.17) - reworked syntax of IMGUI_ONCE_UPON_A_FRAME helper macro to increase compiler compatibility
@@ -581,42 +609,26 @@ CODE
- See demo code in imgui_demo.cpp and particularly the ImGui::ShowDemoWindow() function.
- The demo covers most features of Dear ImGui, so you can read the code and see its output.
- See documentation and comments at the top of imgui.cpp + effectively imgui.h.
- - Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the examples/
- folder to explain how to integrate Dear ImGui with your own engine/application.
+ - Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the
+ examples/ folder to explain how to integrate Dear ImGui with your own engine/application.
+ - The Wiki (https://github.com/ocornut/imgui/wiki) has many resources and links.
+ - The Glossary (https://github.com/ocornut/imgui/wiki/Glossary) page also may be useful.
- Your programming IDE is your friend, find the type or function declaration to find comments
associated to it.
+ Q: What is this library called?
Q: Which version should I get?
- Q: Why the names "Dear ImGui" vs "ImGui"?
- >> See https://www.dearimgui.org/faq
-
- Q&A: Concerns
- =============
-
- Q: Who uses Dear ImGui?
- Q: Can you create elaborate/serious tools with Dear ImGui?
- Q: Can you reskin the look of Dear ImGui?
- Q: Why using C++ (as opposed to C)?
+ >> This library is called "Dear ImGui", please don't call it "ImGui" :)
>> See https://www.dearimgui.org/faq
Q&A: Integration
================
Q: How can I tell whether to dispatch mouse/keyboard to Dear ImGui or to my application?
- A: You can read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags from the ImGuiIO structure (e.g. if (ImGui::GetIO().WantCaptureMouse) { ... } )
- - When 'io.WantCaptureMouse' is set, imgui wants to use your mouse state, and you may want to discard/hide the inputs from the rest of your application.
- - When 'io.WantCaptureKeyboard' is set, imgui wants to use your keyboard state, and you may want to discard/hide the inputs from the rest of your application.
- - When 'io.WantTextInput' is set to may want to notify your OS to popup an on-screen keyboard, if available (e.g. on a mobile phone, or console OS).
- Note: you should always pass your mouse/keyboard inputs to imgui, even when the io.WantCaptureXXX flag are set false.
- This is because imgui needs to detect that you clicked in the void to unfocus its own windows.
- Note: The 'io.WantCaptureMouse' is more accurate that any attempt to "check if the mouse is hovering a window" (don't do that!).
- It handle mouse dragging correctly (both dragging that started over your application or over an imgui window) and handle e.g. modal windows blocking inputs.
- Those flags are updated by ImGui::NewFrame(). Preferably read the flags after calling NewFrame() if you can afford it, but reading them before is also
- perfectly fine, as the bool toggle fairly rarely. If you have on a touch device, you might find use for an early call to UpdateHoveredWindowAndCaptureFlags().
- Note: Text input widget releases focus on "Return KeyDown", so the subsequent "Return KeyUp" event that your application receive will typically
- have 'io.WantCaptureKeyboard=false'. Depending on your application logic it may or not be inconvenient. You might want to track which key-downs
- were targeted for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.)
+ A: You should read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags!
+ >> See https://www.dearimgui.org/faq for fully detailed answer. You really want to read this.
+ Q. How can I enable keyboard controls?
Q: How can I use this without a mouse, without a keyboard or without a screen? (gamepad, input share, remote display)
Q: I integrated Dear ImGui in my engine and the text or lines are blurry..
Q: I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around..
@@ -756,33 +768,51 @@ CODE
Q: How can I easily use icons in my application?
Q: How can I load multiple fonts?
Q: How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic?
- >> See https://www.dearimgui.org/faq and misc/fonts/README.txt
+ >> See https://www.dearimgui.org/faq and docs/FONTS.txt
+
+ Q&A: Concerns
+ =============
+
+ Q: Who uses Dear ImGui?
+ Q: Can you create elaborate/serious tools with Dear ImGui?
+ Q: Can you reskin the look of Dear ImGui?
+ Q: Why using C++ (as opposed to C)?
+ >> See https://www.dearimgui.org/faq
Q&A: Community
==============
Q: How can I help?
- A: - If you are experienced with Dear ImGui and C++, look at the github issues, look at the Wiki, read docs/TODO.txt
+ A: - Businesses: please reach out to "contact AT dearimgui.org" if you work in a place using Dear ImGui!
+ We can discuss ways for your company to fund development via invoiced technical support, maintenance or sponsoring contacts.
+ This is among the most useful thing you can do for Dear ImGui. With increased funding we can hire more people working on this project.
+ - Individuals: you can support continued development via PayPal donations. See README.
+ - If you are experienced with Dear ImGui and C++, look at the github issues, look at the Wiki, read docs/TODO.txt
and see how you want to help and can help!
- - Businesses: convince your company to fund development via support contracts/sponsoring! This is among the most useful thing you can do for dear imgui.
- - Individuals: you can also become a Patron (http://www.patreon.com/imgui) or donate on PayPal! See README.
- - Disclose your usage of dear imgui via a dev blog post, a tweet, a screenshot, a mention somewhere etc.
- You may post screenshot or links in the gallery threads (github.com/ocornut/imgui/issues/2847). Visuals are ideal as they inspire other programmers.
+ - Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere etc.
+ You may post screenshot or links in the gallery threads (github.com/ocornut/imgui/issues/3075). Visuals are ideal as they inspire other programmers.
But even without visuals, disclosing your use of dear imgui help the library grow credibility, and help other teams and programmers with taking decisions.
- If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues (on github or privately).
*/
+//-------------------------------------------------------------------------
+// [SECTION] INCLUDES
+//-------------------------------------------------------------------------
+
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
#define _CRT_SECURE_NO_WARNINGS
#endif
#include "imgui.h"
+#ifndef IMGUI_DISABLE
+
#ifndef IMGUI_DEFINE_MATH_OPERATORS
#define IMGUI_DEFINE_MATH_OPERATORS
#endif
#include "imgui_internal.h"
+// System includes
#include // toupper
#include // vsnprintf, sscanf, printf
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
@@ -791,15 +821,40 @@ CODE
#include // intptr_t
#endif
-// Debug options
-#define IMGUI_DEBUG_NAV_SCORING 0 // Display navigation scoring preview when hovering items. Display last moving direction matches when holding CTRL
-#define IMGUI_DEBUG_NAV_RECTS 0 // Display the reference navigation rectangle for each window
-#define IMGUI_DEBUG_INI_SETTINGS 0 // Save additional comments in .ini file (particularly helps for Docking, but makes saving slower)
+// [Windows] OS specific includes (optional)
+#if defined(_WIN32) && defined(IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS) && defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS) && defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
+#define IMGUI_DISABLE_WIN32_FUNCTIONS
+#endif
+#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+#ifndef __MINGW32__
+#include // _wfopen, OpenClipboard
+#else
+#include
+#endif
+#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) // UWP doesn't have all Win32 functions
+#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS
+#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS
+#endif
+#endif
+
+// [Apple] OS specific includes
+#if defined(__APPLE__)
+#include
+#endif
// Visual Studio warnings
#ifdef _MSC_VER
-#pragma warning (disable: 4127) // condition expression is constant
-#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
+#pragma warning (disable: 4127) // condition expression is constant
+#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
+#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later
+#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types
+#endif
#endif
// Clang/GCC warnings with -Weverything
@@ -832,6 +887,11 @@ CODE
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
#endif
+// Debug options
+#define IMGUI_DEBUG_NAV_SCORING 0 // Display navigation scoring preview when hovering items. Display last moving direction matches when holding CTRL
+#define IMGUI_DEBUG_NAV_RECTS 0 // Display the reference navigation rectangle for each window
+#define IMGUI_DEBUG_INI_SETTINGS 0 // Save additional comments in .ini file (particularly helps for Docking, but makes saving slower)
+
// When using CTRL+TAB (or Gamepad Square+L/R) we delay the visual a little in order to reduce visual noise doing a fast switch.
static const float NAV_WINDOWING_HIGHLIGHT_DELAY = 0.20f; // Time before the highlight and screen dimming starts fading in
static const float NAV_WINDOWING_LIST_APPEAR_DELAY = 0.15f; // Time before the window list starts to appear
@@ -841,36 +901,32 @@ static const float WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS = 4.0f; // Exten
static const float WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER = 0.04f; // Reduce visual noise by only highlighting the border after a certain time.
static const float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 2.00f; // Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certaint time, unless mouse moved.
-// Docking
-static const float DOCKING_TRANSPARENT_PAYLOAD_ALPHA = 0.50f; // For use with io.ConfigDockingTransparentPayload. Apply to Viewport _or_ WindowBg in host viewport.
-
//-------------------------------------------------------------------------
// [SECTION] FORWARD DECLARATIONS
//-------------------------------------------------------------------------
static void SetCurrentWindow(ImGuiWindow* window);
-static void SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size);
static void FindHoveredWindow();
static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags);
-static void CheckStacksSize(ImGuiWindow* window, bool write);
static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window, bool snap_on_edges);
static void AddDrawListToDrawData(ImVector* out_list, ImDrawList* draw_list);
static void AddWindowToSortBuffer(ImVector* out_sorted_windows, ImGuiWindow* window);
+static ImRect GetViewportRect();
+
// Settings
-static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name);
-static void SettingsHandlerWindow_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line);
-static void SettingsHandlerWindow_WriteAll(ImGuiContext* imgui_ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf);
+static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name);
+static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line);
+static void WindowSettingsHandler_WriteAll(ImGuiContext*, ImGuiSettingsHandler*, ImGuiTextBuffer* buf);
// Platform Dependents default implementation for IO functions
static const char* GetClipboardTextFn_DefaultImpl(void* user_data);
static void SetClipboardTextFn_DefaultImpl(void* user_data, const char* text);
+static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y);
namespace ImGui
{
-static bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags);
-
// Navigation
static void NavUpdate();
static void NavUpdateWindowing();
@@ -885,29 +941,21 @@ static void NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_win
static ImGuiWindow* NavRestoreLastChildNavWindow(ImGuiWindow* window);
static int FindWindowFocusIndex(ImGuiWindow* window);
+// Error Checking
+static void ErrorCheckNewFrameSanityChecks();
+static void ErrorCheckEndFrameSanityChecks();
+static void ErrorCheckBeginEndCompareStacksSize(ImGuiWindow* window, bool write);
+
// Misc
+static void UpdateSettings();
static void UpdateMouseInputs();
static void UpdateMouseWheel();
-static bool UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]);
+static void UpdateTabFocus();
static void UpdateDebugToolItemPicker();
+static bool UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]);
static void RenderWindowOuterBorders(ImGuiWindow* window);
-static void RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, bool handle_borders_and_resize_grips, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size);
+static void RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size);
static void RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open);
-static void EndFrameDrawDimmedBackgrounds();
-
-// Viewports
-const ImGuiID IMGUI_VIEWPORT_DEFAULT_ID = 0x11111111; // Using an arbitrary constant instead of e.g. ImHashStr("ViewportDefault", 0); so it's easier to spot in the debugger. The exact value doesn't matter.
-static ImGuiViewportP* AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const ImVec2& platform_pos, const ImVec2& size, ImGuiViewportFlags flags);
-static void UpdateViewportsNewFrame();
-static void UpdateViewportsEndFrame();
-static void UpdateSelectWindowViewport(ImGuiWindow* window);
-static bool UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImGuiViewportP* host_viewport);
-static bool UpdateTryMergeWindowIntoHostViewports(ImGuiWindow* window);
-static void SetCurrentViewport(ImGuiWindow* window, ImGuiViewportP* viewport);
-static bool GetWindowAlwaysWantOwnViewport(ImGuiWindow* window);
-static int FindPlatformMonitorForPos(const ImVec2& pos);
-static int FindPlatformMonitorForRect(const ImRect& r);
-static void UpdateViewportPlatformMonitor(ImGuiViewportP* viewport);
}
@@ -949,7 +997,7 @@ static void (*GImAllocatorFreeFunc)(void* ptr, void* user_data) = FreeWrapper;
static void* GImAllocatorUserData = NULL;
//-----------------------------------------------------------------------------
-// [SECTION] MAIN USER FACING STRUCTURES (ImGuiStyle, ImGuiIO)
+// [SECTION] USER FACING STRUCTURES (ImGuiStyle, ImGuiIO)
//-----------------------------------------------------------------------------
ImGuiStyle::ImGuiStyle()
@@ -981,13 +1029,14 @@ ImGuiStyle::ImGuiStyle()
TabBorderSize = 0.0f; // Thickness of border around tabs.
ColorButtonPosition = ImGuiDir_Right; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
ButtonTextAlign = ImVec2(0.5f,0.5f);// Alignment of button text when button is larger than text.
- SelectableTextAlign = ImVec2(0.0f,0.0f);// Alignment of selectable text when button is larger than text.
+ SelectableTextAlign = ImVec2(0.0f,0.0f);// Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line.
DisplayWindowPadding = ImVec2(19,19); // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows.
DisplaySafeAreaPadding = ImVec2(3,3); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
MouseCursorScale = 1.0f; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later.
AntiAliasedLines = true; // Enable anti-aliasing on lines/borders. Disable if you are really short on CPU/GPU.
AntiAliasedFill = true; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
CurveTessellationTol = 1.25f; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
+ CircleSegmentMaxError = 1.60f; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry.
// Default theme
ImGui::StyleColorsDark(this);
@@ -1023,6 +1072,7 @@ ImGuiIO::ImGuiIO()
{
// Most fields are initialized with zero
memset(this, 0, sizeof(*this));
+ IM_ASSERT(IM_ARRAYSIZE(ImGuiIO::MouseDown) == ImGuiMouseButton_COUNT && IM_ARRAYSIZE(ImGuiIO::MouseClicked) == ImGuiMouseButton_COUNT); // Our pre-C++11 IM_STATIC_ASSERT() macros triggers warning on modern compilers so we don't use it here.
// Settings
ConfigFlags = ImGuiConfigFlags_None;
@@ -1046,18 +1096,6 @@ ImGuiIO::ImGuiIO()
FontAllowUserScaling = false;
DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
- // Docking options (when ImGuiConfigFlags_DockingEnable is set)
- ConfigDockingNoSplit = false;
- ConfigDockingWithShift = false;
- ConfigDockingAlwaysTabBar = false;
- ConfigDockingTransparentPayload = false;
-
- // Viewport options (when ImGuiConfigFlags_ViewportsEnable is set)
- ConfigViewportsNoAutoMerge = false;
- ConfigViewportsNoTaskBarIcon = false;
- ConfigViewportsNoDecoration = true;
- ConfigViewportsNoDefaultParent = false;
-
// Miscellaneous options
MouseDrawCursor = false;
#ifdef __APPLE__
@@ -1076,6 +1114,8 @@ ImGuiIO::ImGuiIO()
GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations
SetClipboardTextFn = SetClipboardTextFn_DefaultImpl;
ClipboardUserData = NULL;
+ ImeSetInputScreenPosFn = ImeSetInputScreenPosFn_DefaultImpl;
+ ImeWindowHandle = NULL;
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
RenderDrawListsFn = NULL;
@@ -1095,8 +1135,33 @@ ImGuiIO::ImGuiIO()
// - on Windows you can get those using ToAscii+keyboard state, or via the WM_CHAR message
void ImGuiIO::AddInputCharacter(unsigned int c)
{
- if (c > 0 && c < 0x10000)
- InputQueueCharacters.push_back((ImWchar)c);
+ InputQueueCharacters.push_back(c > 0 && c <= IM_UNICODE_CODEPOINT_MAX ? (ImWchar)c : IM_UNICODE_CODEPOINT_INVALID);
+}
+
+// UTF16 strings use surrogate pairs to encode codepoints >= 0x10000, so
+// we should save the high surrogate.
+void ImGuiIO::AddInputCharacterUTF16(ImWchar16 c)
+{
+ if ((c & 0xFC00) == 0xD800) // High surrogate, must save
+ {
+ if (InputQueueSurrogate != 0)
+ InputQueueCharacters.push_back(0xFFFD);
+ InputQueueSurrogate = c;
+ return;
+ }
+
+ ImWchar cp = c;
+ if (InputQueueSurrogate != 0)
+ {
+ if ((c & 0xFC00) != 0xDC00) // Invalid low surrogate
+ InputQueueCharacters.push_back(IM_UNICODE_CODEPOINT_INVALID);
+ else if (IM_UNICODE_CODEPOINT_MAX == (0xFFFF)) // Codepoint will not fit in ImWchar (extra parenthesis around 0xFFFF somehow fixes -Wunreachable-code with Clang)
+ cp = IM_UNICODE_CODEPOINT_INVALID;
+ else
+ cp = (ImWchar)(((InputQueueSurrogate - 0xD800) << 10) + (c - 0xDC00) + 0x10000);
+ InputQueueSurrogate = 0;
+ }
+ InputQueueCharacters.push_back(cp);
}
void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars)
@@ -1105,7 +1170,7 @@ void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars)
{
unsigned int c = 0;
utf8_chars += ImTextCharFromUtf8(&c, utf8_chars, NULL);
- if (c > 0 && c < 0x10000)
+ if (c > 0)
InputQueueCharacters.push_back((ImWchar)c);
}
}
@@ -1116,9 +1181,77 @@ void ImGuiIO::ClearInputCharacters()
}
//-----------------------------------------------------------------------------
-// [SECTION] MISC HELPERS/UTILITIES (Maths, String, Format, Hash, File functions)
+// [SECTION] MISC HELPERS/UTILITIES (Geometry functions)
//-----------------------------------------------------------------------------
+ImVec2 ImBezierClosestPoint(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, int num_segments)
+{
+ IM_ASSERT(num_segments > 0); // Use ImBezierClosestPointCasteljau()
+ ImVec2 p_last = p1;
+ ImVec2 p_closest;
+ float p_closest_dist2 = FLT_MAX;
+ float t_step = 1.0f / (float)num_segments;
+ for (int i_step = 1; i_step <= num_segments; i_step++)
+ {
+ ImVec2 p_current = ImBezierCalc(p1, p2, p3, p4, t_step * i_step);
+ ImVec2 p_line = ImLineClosestPoint(p_last, p_current, p);
+ float dist2 = ImLengthSqr(p - p_line);
+ if (dist2 < p_closest_dist2)
+ {
+ p_closest = p_line;
+ p_closest_dist2 = dist2;
+ }
+ p_last = p_current;
+ }
+ return p_closest;
+}
+
+// Closely mimics PathBezierToCasteljau() in imgui_draw.cpp
+static void BezierClosestPointCasteljauStep(const ImVec2& p, ImVec2& p_closest, ImVec2& p_last, float& p_closest_dist2, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level)
+{
+ float dx = x4 - x1;
+ float dy = y4 - y1;
+ float d2 = ((x2 - x4) * dy - (y2 - y4) * dx);
+ float d3 = ((x3 - x4) * dy - (y3 - y4) * dx);
+ d2 = (d2 >= 0) ? d2 : -d2;
+ d3 = (d3 >= 0) ? d3 : -d3;
+ if ((d2+d3) * (d2+d3) < tess_tol * (dx*dx + dy*dy))
+ {
+ ImVec2 p_current(x4, y4);
+ ImVec2 p_line = ImLineClosestPoint(p_last, p_current, p);
+ float dist2 = ImLengthSqr(p - p_line);
+ if (dist2 < p_closest_dist2)
+ {
+ p_closest = p_line;
+ p_closest_dist2 = dist2;
+ }
+ p_last = p_current;
+ }
+ else if (level < 10)
+ {
+ float x12 = (x1+x2)*0.5f, y12 = (y1+y2)*0.5f;
+ float x23 = (x2+x3)*0.5f, y23 = (y2+y3)*0.5f;
+ float x34 = (x3+x4)*0.5f, y34 = (y3+y4)*0.5f;
+ float x123 = (x12+x23)*0.5f, y123 = (y12+y23)*0.5f;
+ float x234 = (x23+x34)*0.5f, y234 = (y23+y34)*0.5f;
+ float x1234 = (x123+x234)*0.5f, y1234 = (y123+y234)*0.5f;
+ BezierClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1, y1, x12, y12, x123, y123, x1234, y1234, tess_tol, level + 1);
+ BezierClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1234, y1234, x234, y234, x34, y34, x4, y4, tess_tol, level + 1);
+ }
+}
+
+// tess_tol is generally the same value you would find in ImGui::GetStyle().CurveTessellationTol
+// Because those ImXXX functions are lower-level than ImGui:: we cannot access this value automatically.
+ImVec2 ImBezierClosestPointCasteljau(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, float tess_tol)
+{
+ IM_ASSERT(tess_tol > 0.0f);
+ ImVec2 p_last = p1;
+ ImVec2 p_closest;
+ float p_closest_dist2 = FLT_MAX;
+ BezierClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, tess_tol, 0);
+ return p_closest;
+}
+
ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p)
{
ImVec2 ap = p - a;
@@ -1167,6 +1300,10 @@ ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c,
return proj_ca;
}
+//-----------------------------------------------------------------------------
+// [SECTION] MISC HELPERS/UTILITIES (String, Format, Hash functions)
+//-----------------------------------------------------------------------------
+
// Consider using _stricmp/_strnicmp under Windows or strcasecmp/strncasecmp. We don't actually use either ImStricmp/ImStrnicmp in the codebase any more.
int ImStricmp(const char* str1, const char* str2)
{
@@ -1220,7 +1357,7 @@ const char* ImStrchrRange(const char* str, const char* str_end, char c)
int ImStrlenW(const ImWchar* str)
{
- //return (int)wcslen((const wchar_t*)str); // FIXME-OPT: Could use this when wchar_t are 16-bits
+ //return (int)wcslen((const wchar_t*)str); // FIXME-OPT: Could use this when wchar_t are 16-bit
int n = 0;
while (*str++) n++;
return n;
@@ -1288,12 +1425,15 @@ const char* ImStrSkipBlank(const char* str)
// A) MSVC version appears to return -1 on overflow, whereas glibc appears to return total count (which may be >= buf_size).
// Ideally we would test for only one of those limits at runtime depending on the behavior the vsnprintf(), but trying to deduct it at compile time sounds like a pandora can of worm.
// B) When buf==NULL vsnprintf() will return the output size.
-#ifndef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
+#ifndef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
-//#define IMGUI_USE_STB_SPRINTF
+// We support stb_sprintf which is much faster (see: https://github.com/nothings/stb/blob/master/stb_sprintf.h)
+// You may set IMGUI_USE_STB_SPRINTF to use our default wrapper, or set IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
+// and setup the wrapper yourself. (FIXME-OPT: Some of our high-level operations such as ImGuiTextBuffer::appendfv() are
+// designed using two-passes worst case, which probably could be improved using the stbsp_vsprintfcb() function.)
#ifdef IMGUI_USE_STB_SPRINTF
#define STB_SPRINTF_IMPLEMENTATION
-#include "imstb_sprintf.h"
+#include "stb_sprintf.h"
#endif
#if defined(_MSC_VER) && !defined(vsnprintf)
@@ -1332,7 +1472,7 @@ int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args)
buf[w] = 0;
return w;
}
-#endif // #ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
+#endif // #ifdef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
// CRC32 needs a 1KB lookup table (not cache friendly)
// Although the code to generate the table is simple and shorter than the table itself, using a const table allows us to easily:
@@ -1404,58 +1544,73 @@ ImU32 ImHashStr(const char* data_p, size_t data_size, ImU32 seed)
return ~crc;
}
-FILE* ImFileOpen(const char* filename, const char* mode)
+//-----------------------------------------------------------------------------
+// [SECTION] MISC HELPERS/UTILITIES (File functions)
+//-----------------------------------------------------------------------------
+
+// Default file functions
+#ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
+
+ImFileHandle ImFileOpen(const char* filename, const char* mode)
{
-#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__GNUC__)
- // We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames. Converting both strings from UTF-8 to wchar format (using a single allocation, because we can)
- const int filename_wsize = ImTextCountCharsFromUtf8(filename, NULL) + 1;
- const int mode_wsize = ImTextCountCharsFromUtf8(mode, NULL) + 1;
+#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(__CYGWIN__) && !defined(__GNUC__)
+ // We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames.
+ // Previously we used ImTextCountCharsFromUtf8/ImTextStrFromUtf8 here but we now need to support ImWchar16 and ImWchar32!
+ const int filename_wsize = ::MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0);
+ const int mode_wsize = ::MultiByteToWideChar(CP_UTF8, 0, mode, -1, NULL, 0);
ImVector buf;
buf.resize(filename_wsize + mode_wsize);
- ImTextStrFromUtf8(&buf[0], filename_wsize, filename, NULL);
- ImTextStrFromUtf8(&buf[filename_wsize], mode_wsize, mode, NULL);
- return _wfopen((wchar_t*)&buf[0], (wchar_t*)&buf[filename_wsize]);
+ ::MultiByteToWideChar(CP_UTF8, 0, filename, -1, (wchar_t*)&buf[0], filename_wsize);
+ ::MultiByteToWideChar(CP_UTF8, 0, mode, -1, (wchar_t*)&buf[filename_wsize], mode_wsize);
+ return ::_wfopen((const wchar_t*)&buf[0], (const wchar_t*)&buf[filename_wsize]);
#else
return fopen(filename, mode);
#endif
}
-// Load file content into memory
+// We should in theory be using fseeko()/ftello() with off_t and _fseeki64()/_ftelli64() with __int64, waiting for the PR that does that in a very portable pre-C++11 zero-warnings way.
+bool ImFileClose(ImFileHandle f) { return fclose(f) == 0; }
+ImU64 ImFileGetSize(ImFileHandle f) { long off = 0, sz = 0; return ((off = ftell(f)) != -1 && !fseek(f, 0, SEEK_END) && (sz = ftell(f)) != -1 && !fseek(f, off, SEEK_SET)) ? (ImU64)sz : (ImU64)-1; }
+ImU64 ImFileRead(void* data, ImU64 sz, ImU64 count, ImFileHandle f) { return fread(data, (size_t)sz, (size_t)count, f); }
+ImU64 ImFileWrite(const void* data, ImU64 sz, ImU64 count, ImFileHandle f) { return fwrite(data, (size_t)sz, (size_t)count, f); }
+#endif // #ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
+
+// Helper: Load file content into memory
// Memory allocated with IM_ALLOC(), must be freed by user using IM_FREE() == ImGui::MemFree()
-void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_t* out_file_size, int padding_bytes)
+// This can't really be used with "rt" because fseek size won't match read size.
+void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_file_size, int padding_bytes)
{
- IM_ASSERT(filename && file_open_mode);
+ IM_ASSERT(filename && mode);
if (out_file_size)
*out_file_size = 0;
- FILE* f;
- if ((f = ImFileOpen(filename, file_open_mode)) == NULL)
+ ImFileHandle f;
+ if ((f = ImFileOpen(filename, mode)) == NULL)
return NULL;
- long file_size_signed;
- if (fseek(f, 0, SEEK_END) || (file_size_signed = ftell(f)) == -1 || fseek(f, 0, SEEK_SET))
+ size_t file_size = (size_t)ImFileGetSize(f);
+ if (file_size == (size_t)-1)
{
- fclose(f);
+ ImFileClose(f);
return NULL;
}
- size_t file_size = (size_t)file_size_signed;
void* file_data = IM_ALLOC(file_size + padding_bytes);
if (file_data == NULL)
{
- fclose(f);
+ ImFileClose(f);
return NULL;
}
- if (fread(file_data, 1, file_size, f) != file_size)
+ if (ImFileRead(file_data, 1, file_size, f) != file_size)
{
- fclose(f);
+ ImFileClose(f);
IM_FREE(file_data);
return NULL;
}
if (padding_bytes > 0)
memset((void*)(((char*)file_data) + file_size), 0, (size_t)padding_bytes);
- fclose(f);
+ ImFileClose(f);
if (out_file_size)
*out_file_size = file_size;
@@ -1466,7 +1621,7 @@ void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_
// [SECTION] MISC HELPERS/UTILITIES (ImText* functions)
//-----------------------------------------------------------------------------
-// Convert UTF-8 to 32-bits character, process single character input.
+// Convert UTF-8 to 32-bit character, process single character input.
// Based on stb_from_utf8() from github.com/nothings/stb/
// We handle UTF-8 decoding error by skipping forward.
int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end)
@@ -1481,7 +1636,7 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char*
}
if ((*str & 0xe0) == 0xc0)
{
- *out_char = 0xFFFD; // will be invalid but not end of string
+ *out_char = IM_UNICODE_CODEPOINT_INVALID; // will be invalid but not end of string
if (in_text_end && in_text_end - (const char*)str < 2) return 1;
if (*str < 0xc2) return 2;
c = (unsigned int)((*str++ & 0x1f) << 6);
@@ -1492,7 +1647,7 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char*
}
if ((*str & 0xf0) == 0xe0)
{
- *out_char = 0xFFFD; // will be invalid but not end of string
+ *out_char = IM_UNICODE_CODEPOINT_INVALID; // will be invalid but not end of string
if (in_text_end && in_text_end - (const char*)str < 3) return 1;
if (*str == 0xe0 && (str[1] < 0xa0 || str[1] > 0xbf)) return 3;
if (*str == 0xed && str[1] > 0x9f) return 3; // str[1] < 0x80 is checked below
@@ -1506,7 +1661,7 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char*
}
if ((*str & 0xf8) == 0xf0)
{
- *out_char = 0xFFFD; // will be invalid but not end of string
+ *out_char = IM_UNICODE_CODEPOINT_INVALID; // will be invalid but not end of string
if (in_text_end && in_text_end - (const char*)str < 4) return 1;
if (*str > 0xf4) return 4;
if (*str == 0xf0 && (str[1] < 0x90 || str[1] > 0xbf)) return 4;
@@ -1520,6 +1675,8 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char*
c += (*str++ & 0x3f);
// utf-8 encodings of values used in surrogate pairs are invalid
if ((c & 0xFFFFF800) == 0xD800) return 4;
+ // If codepoint does not fit in ImWchar, use replacement character U+FFFD instead
+ if (c > IM_UNICODE_CODEPOINT_MAX) c = IM_UNICODE_CODEPOINT_INVALID;
*out_char = c;
return 4;
}
@@ -1537,8 +1694,7 @@ int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const cha
in_text += ImTextCharFromUtf8(&c, in_text, in_text_end);
if (c == 0)
break;
- if (c < 0x10000) // FIXME: Losing characters that don't fit in 2 bytes
- *buf_out++ = (ImWchar)c;
+ *buf_out++ = (ImWchar)c;
}
*buf_out = 0;
if (in_text_remaining)
@@ -1555,8 +1711,7 @@ int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end)
in_text += ImTextCharFromUtf8(&c, in_text, in_text_end);
if (c == 0)
break;
- if (c < 0x10000)
- char_count++;
+ char_count++;
}
return char_count;
}
@@ -1576,11 +1731,15 @@ static inline int ImTextCharToUtf8(char* buf, int buf_size, unsigned int c)
buf[1] = (char)(0x80 + (c & 0x3f));
return 2;
}
- if (c >= 0xdc00 && c < 0xe000)
+ if (c < 0x10000)
{
- return 0;
+ if (buf_size < 3) return 0;
+ buf[0] = (char)(0xe0 + (c >> 12));
+ buf[1] = (char)(0x80 + ((c>> 6) & 0x3f));
+ buf[2] = (char)(0x80 + ((c ) & 0x3f));
+ return 3;
}
- if (c >= 0xd800 && c < 0xdc00)
+ if (c <= 0x10FFFF)
{
if (buf_size < 4) return 0;
buf[0] = (char)(0xf0 + (c >> 18));
@@ -1589,14 +1748,8 @@ static inline int ImTextCharToUtf8(char* buf, int buf_size, unsigned int c)
buf[3] = (char)(0x80 + ((c ) & 0x3f));
return 4;
}
- //else if (c < 0x10000)
- {
- if (buf_size < 3) return 0;
- buf[0] = (char)(0xe0 + (c >> 12));
- buf[1] = (char)(0x80 + ((c>> 6) & 0x3f));
- buf[2] = (char)(0x80 + ((c ) & 0x3f));
- return 3;
- }
+ // Invalid code point, the max unicode is 0x10FFFF
+ return 0;
}
// Not optimal but we very rarely use this function.
@@ -1610,8 +1763,8 @@ static inline int ImTextCountUtf8BytesFromChar(unsigned int c)
{
if (c < 0x80) return 1;
if (c < 0x800) return 2;
- if (c >= 0xdc00 && c < 0xe000) return 0;
- if (c >= 0xd800 && c < 0xdc00) return 4;
+ if (c < 0x10000) return 3;
+ if (c <= 0x10FFFF) return 4;
return 3;
}
@@ -1646,10 +1799,19 @@ int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_e
}
//-----------------------------------------------------------------------------
-// [SECTION] MISC HELPERS/UTILTIES (Color functions)
+// [SECTION] MISC HELPERS/UTILITIES (Color functions)
// Note: The Convert functions are early design which are not consistent with other API.
//-----------------------------------------------------------------------------
+IMGUI_API ImU32 ImAlphaBlendColors(ImU32 col_a, ImU32 col_b)
+{
+ float t = ((col_b >> IM_COL32_A_SHIFT) & 0xFF) / 255.f;
+ int r = ImLerp((int)(col_a >> IM_COL32_R_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_R_SHIFT) & 0xFF, t);
+ int g = ImLerp((int)(col_a >> IM_COL32_G_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_G_SHIFT) & 0xFF, t);
+ int b = ImLerp((int)(col_a >> IM_COL32_B_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_B_SHIFT) & 0xFF, t);
+ return IM_COL32(r, g, b, 0xFF);
+}
+
ImVec4 ImGui::ColorConvertU32ToFloat4(ImU32 in)
{
float s = 1.0f/255.0f;
@@ -1721,38 +1883,6 @@ void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float&
}
}
-ImU32 ImGui::GetColorU32(ImGuiCol idx, float alpha_mul)
-{
- ImGuiStyle& style = GImGui->Style;
- ImVec4 c = style.Colors[idx];
- c.w *= style.Alpha * alpha_mul;
- return ColorConvertFloat4ToU32(c);
-}
-
-ImU32 ImGui::GetColorU32(const ImVec4& col)
-{
- ImGuiStyle& style = GImGui->Style;
- ImVec4 c = col;
- c.w *= style.Alpha;
- return ColorConvertFloat4ToU32(c);
-}
-
-const ImVec4& ImGui::GetStyleColorVec4(ImGuiCol idx)
-{
- ImGuiStyle& style = GImGui->Style;
- return style.Colors[idx];
-}
-
-ImU32 ImGui::GetColorU32(ImU32 col)
-{
- float style_alpha = GImGui->Style.Alpha;
- if (style_alpha >= 1.0f)
- return col;
- ImU32 a = (col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT;
- a = (ImU32)(a * style_alpha); // We don't need to clamp 0..255 because Style.Alpha is in 0..1 range.
- return (col & ~IM_COL32_A_MASK) | (a << IM_COL32_A_SHIFT);
-}
-
//-----------------------------------------------------------------------------
// [SECTION] ImGuiStorage
// Helper: Key->value storage
@@ -2102,7 +2232,9 @@ void ImGui::CalcListClipping(int items_count, float items_height, int* out_items
// We create the union of the ClipRect and the NavScoringRect which at worst should be 1 page away from ClipRect
ImRect unclipped_rect = window->ClipRect;
if (g.NavMoveRequest)
- unclipped_rect.Add(g.NavScoringRectScreen);
+ unclipped_rect.Add(g.NavScoringRect);
+ if (g.NavJustMovedToId && window->NavLastIds[0] == g.NavJustMovedToId)
+ unclipped_rect.Add(ImRect(window->Pos + window->NavRectRel[0].Min, window->Pos + window->NavRectRel[0].Max));
const ImVec2 pos = window->DC.CursorPos;
int start = (int)((unclipped_rect.Min.y - pos.y) / items_height);
@@ -2209,63 +2341,283 @@ bool ImGuiListClipper::Step()
}
//-----------------------------------------------------------------------------
-// [SECTION] RENDER HELPERS
-// Those (internal) functions are currently quite a legacy mess - their signature and behavior will change.
-// Also see imgui_draw.cpp for some more which have been reworked to not rely on ImGui:: state.
+// [SECTION] STYLING
//-----------------------------------------------------------------------------
-const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end)
+ImGuiStyle& ImGui::GetStyle()
{
- const char* text_display_end = text;
- if (!text_end)
- text_end = (const char*)-1;
+ IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
+ return GImGui->Style;
+}
- while (text_display_end < text_end && *text_display_end != '\0' && (text_display_end[0] != '#' || text_display_end[1] != '#'))
- text_display_end++;
- return text_display_end;
+ImU32 ImGui::GetColorU32(ImGuiCol idx, float alpha_mul)
+{
+ ImGuiStyle& style = GImGui->Style;
+ ImVec4 c = style.Colors[idx];
+ c.w *= style.Alpha * alpha_mul;
+ return ColorConvertFloat4ToU32(c);
}
-// Internal ImGui functions to render text
-// RenderText***() functions calls ImDrawList::AddText() calls ImBitmapFont::RenderText()
-void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool hide_text_after_hash)
+ImU32 ImGui::GetColorU32(const ImVec4& col)
{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
+ ImGuiStyle& style = GImGui->Style;
+ ImVec4 c = col;
+ c.w *= style.Alpha;
+ return ColorConvertFloat4ToU32(c);
+}
- // Hide anything after a '##' string
- const char* text_display_end;
- if (hide_text_after_hash)
- {
- text_display_end = FindRenderedTextEnd(text, text_end);
- }
- else
- {
- if (!text_end)
- text_end = text + strlen(text); // FIXME-OPT
- text_display_end = text_end;
- }
+const ImVec4& ImGui::GetStyleColorVec4(ImGuiCol idx)
+{
+ ImGuiStyle& style = GImGui->Style;
+ return style.Colors[idx];
+}
- if (text != text_display_end)
- {
- window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_display_end);
- if (g.LogEnabled)
- LogRenderedText(&pos, text, text_display_end);
- }
+ImU32 ImGui::GetColorU32(ImU32 col)
+{
+ ImGuiStyle& style = GImGui->Style;
+ if (style.Alpha >= 1.0f)
+ return col;
+ ImU32 a = (col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT;
+ a = (ImU32)(a * style.Alpha); // We don't need to clamp 0..255 because Style.Alpha is in 0..1 range.
+ return (col & ~IM_COL32_A_MASK) | (a << IM_COL32_A_SHIFT);
}
-void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width)
+// FIXME: This may incur a round-trip (if the end user got their data from a float4) but eventually we aim to store the in-flight colors as ImU32
+void ImGui::PushStyleColor(ImGuiCol idx, ImU32 col)
{
ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
+ ImGuiColorMod backup;
+ backup.Col = idx;
+ backup.BackupValue = g.Style.Colors[idx];
+ g.ColorModifiers.push_back(backup);
+ g.Style.Colors[idx] = ColorConvertU32ToFloat4(col);
+}
- if (!text_end)
- text_end = text + strlen(text); // FIXME-OPT
+void ImGui::PushStyleColor(ImGuiCol idx, const ImVec4& col)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiColorMod backup;
+ backup.Col = idx;
+ backup.BackupValue = g.Style.Colors[idx];
+ g.ColorModifiers.push_back(backup);
+ g.Style.Colors[idx] = col;
+}
- if (text != text_end)
+void ImGui::PopStyleColor(int count)
+{
+ ImGuiContext& g = *GImGui;
+ while (count > 0)
{
- window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_end, wrap_width);
- if (g.LogEnabled)
- LogRenderedText(&pos, text, text_end);
+ ImGuiColorMod& backup = g.ColorModifiers.back();
+ g.Style.Colors[backup.Col] = backup.BackupValue;
+ g.ColorModifiers.pop_back();
+ count--;
+ }
+}
+
+struct ImGuiStyleVarInfo
+{
+ ImGuiDataType Type;
+ ImU32 Count;
+ ImU32 Offset;
+ void* GetVarPtr(ImGuiStyle* style) const { return (void*)((unsigned char*)style + Offset); }
+};
+
+static const ImGuiStyleVarInfo GStyleVarInfo[] =
+{
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, Alpha) }, // ImGuiStyleVar_Alpha
+ { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowRounding) }, // ImGuiStyleVar_WindowRounding
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowBorderSize) }, // ImGuiStyleVar_WindowBorderSize
+ { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowMinSize) }, // ImGuiStyleVar_WindowMinSize
+ { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowTitleAlign) }, // ImGuiStyleVar_WindowTitleAlign
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildRounding) }, // ImGuiStyleVar_ChildRounding
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildBorderSize) }, // ImGuiStyleVar_ChildBorderSize
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupRounding) }, // ImGuiStyleVar_PopupRounding
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupBorderSize) }, // ImGuiStyleVar_PopupBorderSize
+ { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, FramePadding) }, // ImGuiStyleVar_FramePadding
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameRounding) }, // ImGuiStyleVar_FrameRounding
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameBorderSize) }, // ImGuiStyleVar_FrameBorderSize
+ { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing
+ { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing) }, // ImGuiStyleVar_IndentSpacing
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarSize) }, // ImGuiStyleVar_ScrollbarSize
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarRounding) }, // ImGuiStyleVar_ScrollbarRounding
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding
+ { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign
+ { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SelectableTextAlign) }, // ImGuiStyleVar_SelectableTextAlign
+};
+
+static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx)
+{
+ IM_ASSERT(idx >= 0 && idx < ImGuiStyleVar_COUNT);
+ IM_ASSERT(IM_ARRAYSIZE(GStyleVarInfo) == ImGuiStyleVar_COUNT);
+ return &GStyleVarInfo[idx];
+}
+
+void ImGui::PushStyleVar(ImGuiStyleVar idx, float val)
+{
+ const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx);
+ if (var_info->Type == ImGuiDataType_Float && var_info->Count == 1)
+ {
+ ImGuiContext& g = *GImGui;
+ float* pvar = (float*)var_info->GetVarPtr(&g.Style);
+ g.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar));
+ *pvar = val;
+ return;
+ }
+ IM_ASSERT(0 && "Called PushStyleVar() float variant but variable is not a float!");
+}
+
+void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val)
+{
+ const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx);
+ if (var_info->Type == ImGuiDataType_Float && var_info->Count == 2)
+ {
+ ImGuiContext& g = *GImGui;
+ ImVec2* pvar = (ImVec2*)var_info->GetVarPtr(&g.Style);
+ g.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar));
+ *pvar = val;
+ return;
+ }
+ IM_ASSERT(0 && "Called PushStyleVar() ImVec2 variant but variable is not a ImVec2!");
+}
+
+void ImGui::PopStyleVar(int count)
+{
+ ImGuiContext& g = *GImGui;
+ while (count > 0)
+ {
+ // We avoid a generic memcpy(data, &backup.Backup.., GDataTypeSize[info->Type] * info->Count), the overhead in Debug is not worth it.
+ ImGuiStyleMod& backup = g.StyleModifiers.back();
+ const ImGuiStyleVarInfo* info = GetStyleVarInfo(backup.VarIdx);
+ void* data = info->GetVarPtr(&g.Style);
+ if (info->Type == ImGuiDataType_Float && info->Count == 1) { ((float*)data)[0] = backup.BackupFloat[0]; }
+ else if (info->Type == ImGuiDataType_Float && info->Count == 2) { ((float*)data)[0] = backup.BackupFloat[0]; ((float*)data)[1] = backup.BackupFloat[1]; }
+ g.StyleModifiers.pop_back();
+ count--;
+ }
+}
+
+const char* ImGui::GetStyleColorName(ImGuiCol idx)
+{
+ // Create switch-case from enum with regexp: ImGuiCol_{.*}, --> case ImGuiCol_\1: return "\1";
+ switch (idx)
+ {
+ case ImGuiCol_Text: return "Text";
+ case ImGuiCol_TextDisabled: return "TextDisabled";
+ case ImGuiCol_WindowBg: return "WindowBg";
+ case ImGuiCol_ChildBg: return "ChildBg";
+ case ImGuiCol_PopupBg: return "PopupBg";
+ case ImGuiCol_Border: return "Border";
+ case ImGuiCol_BorderShadow: return "BorderShadow";
+ case ImGuiCol_FrameBg: return "FrameBg";
+ case ImGuiCol_FrameBgHovered: return "FrameBgHovered";
+ case ImGuiCol_FrameBgActive: return "FrameBgActive";
+ case ImGuiCol_TitleBg: return "TitleBg";
+ case ImGuiCol_TitleBgActive: return "TitleBgActive";
+ case ImGuiCol_TitleBgCollapsed: return "TitleBgCollapsed";
+ case ImGuiCol_MenuBarBg: return "MenuBarBg";
+ case ImGuiCol_ScrollbarBg: return "ScrollbarBg";
+ case ImGuiCol_ScrollbarGrab: return "ScrollbarGrab";
+ case ImGuiCol_ScrollbarGrabHovered: return "ScrollbarGrabHovered";
+ case ImGuiCol_ScrollbarGrabActive: return "ScrollbarGrabActive";
+ case ImGuiCol_CheckMark: return "CheckMark";
+ case ImGuiCol_SliderGrab: return "SliderGrab";
+ case ImGuiCol_SliderGrabActive: return "SliderGrabActive";
+ case ImGuiCol_Button: return "Button";
+ case ImGuiCol_ButtonHovered: return "ButtonHovered";
+ case ImGuiCol_ButtonActive: return "ButtonActive";
+ case ImGuiCol_Header: return "Header";
+ case ImGuiCol_HeaderHovered: return "HeaderHovered";
+ case ImGuiCol_HeaderActive: return "HeaderActive";
+ case ImGuiCol_Separator: return "Separator";
+ case ImGuiCol_SeparatorHovered: return "SeparatorHovered";
+ case ImGuiCol_SeparatorActive: return "SeparatorActive";
+ case ImGuiCol_ResizeGrip: return "ResizeGrip";
+ case ImGuiCol_ResizeGripHovered: return "ResizeGripHovered";
+ case ImGuiCol_ResizeGripActive: return "ResizeGripActive";
+ case ImGuiCol_Tab: return "Tab";
+ case ImGuiCol_TabHovered: return "TabHovered";
+ case ImGuiCol_TabActive: return "TabActive";
+ case ImGuiCol_TabUnfocused: return "TabUnfocused";
+ case ImGuiCol_TabUnfocusedActive: return "TabUnfocusedActive";
+ case ImGuiCol_PlotLines: return "PlotLines";
+ case ImGuiCol_PlotLinesHovered: return "PlotLinesHovered";
+ case ImGuiCol_PlotHistogram: return "PlotHistogram";
+ case ImGuiCol_PlotHistogramHovered: return "PlotHistogramHovered";
+ case ImGuiCol_TextSelectedBg: return "TextSelectedBg";
+ case ImGuiCol_DragDropTarget: return "DragDropTarget";
+ case ImGuiCol_NavHighlight: return "NavHighlight";
+ case ImGuiCol_NavWindowingHighlight: return "NavWindowingHighlight";
+ case ImGuiCol_NavWindowingDimBg: return "NavWindowingDimBg";
+ case ImGuiCol_ModalWindowDimBg: return "ModalWindowDimBg";
+ }
+ IM_ASSERT(0);
+ return "Unknown";
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] RENDER HELPERS
+// Some of those (internal) functions are currently quite a legacy mess - their signature and behavior will change,
+// we need a nicer separation between low-level functions and high-level functions relying on the ImGui context.
+// Also see imgui_draw.cpp for some more which have been reworked to not rely on ImGui:: context.
+//-----------------------------------------------------------------------------
+
+const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end)
+{
+ const char* text_display_end = text;
+ if (!text_end)
+ text_end = (const char*)-1;
+
+ while (text_display_end < text_end && *text_display_end != '\0' && (text_display_end[0] != '#' || text_display_end[1] != '#'))
+ text_display_end++;
+ return text_display_end;
+}
+
+// Internal ImGui functions to render text
+// RenderText***() functions calls ImDrawList::AddText() calls ImBitmapFont::RenderText()
+void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool hide_text_after_hash)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ // Hide anything after a '##' string
+ const char* text_display_end;
+ if (hide_text_after_hash)
+ {
+ text_display_end = FindRenderedTextEnd(text, text_end);
+ }
+ else
+ {
+ if (!text_end)
+ text_end = text + strlen(text); // FIXME-OPT
+ text_display_end = text_end;
+ }
+
+ if (text != text_display_end)
+ {
+ window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_display_end);
+ if (g.LogEnabled)
+ LogRenderedText(&pos, text, text_display_end);
+ }
+}
+
+void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ if (!text_end)
+ text_end = text + strlen(text); // FIXME-OPT
+
+ if (text != text_end)
+ {
+ window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_end, wrap_width);
+ if (g.LogEnabled)
+ LogRenderedText(&pos, text, text_end);
}
}
@@ -2421,61 +2773,6 @@ void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding)
}
}
-// Render an arrow aimed to be aligned with text (p_min is a position in the same space text would be positioned). To e.g. denote expanded/collapsed state
-void ImGui::RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir dir, float scale)
-{
- const float h = draw_list->_Data->FontSize * 1.00f;
- float r = h * 0.40f * scale;
- ImVec2 center = pos + ImVec2(h * 0.50f, h * 0.50f * scale);
-
- ImVec2 a, b, c;
- switch (dir)
- {
- case ImGuiDir_Up:
- case ImGuiDir_Down:
- if (dir == ImGuiDir_Up) r = -r;
- a = ImVec2(+0.000f,+0.750f) * r;
- b = ImVec2(-0.866f,-0.750f) * r;
- c = ImVec2(+0.866f,-0.750f) * r;
- break;
- case ImGuiDir_Left:
- case ImGuiDir_Right:
- if (dir == ImGuiDir_Left) r = -r;
- a = ImVec2(+0.750f,+0.000f) * r;
- b = ImVec2(-0.750f,+0.866f) * r;
- c = ImVec2(-0.750f,-0.866f) * r;
- break;
- case ImGuiDir_None:
- case ImGuiDir_COUNT:
- IM_ASSERT(0);
- break;
- }
- draw_list->AddTriangleFilled(center + a, center + b, center + c, col);
-}
-
-void ImGui::RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col)
-{
- draw_list->AddCircleFilled(pos, draw_list->_Data->FontSize * 0.20f, col, 8);
-}
-
-void ImGui::RenderCheckMark(ImVec2 pos, ImU32 col, float sz)
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
-
- float thickness = ImMax(sz / 5.0f, 1.0f);
- sz -= thickness*0.5f;
- pos += ImVec2(thickness*0.25f, thickness*0.25f);
-
- float third = sz / 3.0f;
- float bx = pos.x + third;
- float by = pos.y + sz - third*0.5f;
- window->DrawList->PathLineTo(ImVec2(bx - third, by - third));
- window->DrawList->PathLineTo(ImVec2(bx, by));
- window->DrawList->PathLineTo(ImVec2(bx + third*2, by - third*2));
- window->DrawList->PathStroke(col, false, thickness);
-}
-
void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags)
{
ImGuiContext& g = *GImGui;
@@ -2519,11 +2816,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
Name = ImStrdup(name);
ID = ImHashStr(name);
IDStack.push_back(ID);
- Flags = FlagsPreviousFrame = ImGuiWindowFlags_None;
- Viewport = NULL;
- ViewportId = 0;
- ViewportAllowPlatformMonitorExtend = -1;
- ViewportPos = ImVec2(FLT_MAX, FLT_MAX);
+ Flags = ImGuiWindowFlags_None;
Pos = ImVec2(0.0f, 0.0f);
Size = SizeFull = ImVec2(0.0f, 0.0f);
ContentSize = ContentSizeExplicit = ImVec2(0.0f, 0.0f);
@@ -2538,7 +2831,6 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
ScrollTargetCenterRatio = ImVec2(0.5f, 0.5f);
ScrollbarSizes = ImVec2(0.0f, 0.0f);
ScrollbarX = ScrollbarY = false;
- ViewportOwned = false;
Active = WasActive = false;
WriteAccessed = false;
Collapsed = false;
@@ -2558,23 +2850,21 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
AutoFitOnlyGrows = false;
AutoPosLastDirection = ImGuiDir_None;
HiddenFramesCanSkipItems = HiddenFramesCannotSkipItems = 0;
- SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = SetWindowDockAllowFlags = ImGuiCond_Always | ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing;
+ SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = ImGuiCond_Always | ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing;
SetWindowPosVal = SetWindowPosPivot = ImVec2(FLT_MAX, FLT_MAX);
InnerRect = ImRect(0.0f, 0.0f, 0.0f, 0.0f); // Clear so the InnerRect.GetSize() code in Begin() doesn't lead to overflow even if the result isn't used.
LastFrameActive = -1;
- LastFrameJustFocused = -1;
LastTimeActive = -1.0f;
ItemWidthDefault = 0.0f;
- FontWindowScale = FontDpiScale = 1.0f;
- SettingsIdx = -1;
+ FontWindowScale = 1.0f;
+ SettingsOffset = -1;
DrawList = &DrawListInst;
DrawList->_OwnerName = Name;
ParentWindow = NULL;
RootWindow = NULL;
- RootWindowDockStop = NULL;
RootWindowForTitleBarHighlight = NULL;
RootWindowForNav = NULL;
@@ -2584,12 +2874,6 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
MemoryCompacted = false;
MemoryDrawListIdxCapacity = MemoryDrawListVtxCapacity = 0;
-
- DockNode = DockNodeAsHost = NULL;
- DockId = 0;
- DockTabItemStatusFlags = ImGuiItemStatusFlags_None;
- DockOrder = -1;
- DockIsActive = DockTabIsVisible = DockTabWantClose = false;
}
ImGuiWindow::~ImGuiWindow()
@@ -2690,25 +2974,6 @@ void ImGui::GcAwakeTransientWindowBuffers(ImGuiWindow* window)
window->MemoryDrawListIdxCapacity = window->MemoryDrawListVtxCapacity = 0;
}
-void ImGui::SetNavID(ImGuiID id, int nav_layer)
-{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(g.NavWindow);
- IM_ASSERT(nav_layer == 0 || nav_layer == 1);
- g.NavId = id;
- g.NavWindow->NavLastIds[nav_layer] = id;
-}
-
-void ImGui::SetNavIDWithRectRel(ImGuiID id, int nav_layer, const ImRect& rect_rel)
-{
- ImGuiContext& g = *GImGui;
- SetNavID(id, nav_layer);
- g.NavWindow->NavRectRel[nav_layer] = rect_rel;
- g.NavMousePosDirty = true;
- g.NavDisableHighlight = false;
- g.NavDisableMouseHover = true;
-}
-
void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
@@ -2741,42 +3006,19 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
g.ActiveIdUsingKeyInputMask = 0x00;
}
-// FIXME-NAV: The existence of SetNavID/SetNavIDWithRectRel/SetFocusID is incredibly messy and confusing and needs some explanation or refactoring.
-void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
+void ImGui::ClearActiveID()
+{
+ SetActiveID(0, NULL);
+}
+
+void ImGui::SetHoveredID(ImGuiID id)
{
ImGuiContext& g = *GImGui;
- IM_ASSERT(id != 0);
-
- // Assume that SetFocusID() is called in the context where its NavLayer is the current layer, which is the case everywhere we call it.
- const ImGuiNavLayer nav_layer = window->DC.NavLayerCurrent;
- if (g.NavWindow != window)
- g.NavInitRequest = false;
- g.NavId = id;
- g.NavWindow = window;
- g.NavLayer = nav_layer;
- window->NavLastIds[nav_layer] = id;
- if (window->DC.LastItemId == id)
- window->NavRectRel[nav_layer] = ImRect(window->DC.LastItemRect.Min - window->Pos, window->DC.LastItemRect.Max - window->Pos);
-
- if (g.ActiveIdSource == ImGuiInputSource_Nav)
- g.NavDisableMouseHover = true;
- else
- g.NavDisableHighlight = true;
-}
-
-void ImGui::ClearActiveID()
-{
- SetActiveID(0, NULL);
-}
-
-void ImGui::SetHoveredID(ImGuiID id)
-{
- ImGuiContext& g = *GImGui;
- g.HoveredId = id;
- g.HoveredIdAllowOverlap = false;
- if (id != 0 && g.HoveredIdPreviousFrame != id)
- g.HoveredIdTimer = g.HoveredIdNotActiveTimer = 0.0f;
-}
+ g.HoveredId = id;
+ g.HoveredIdAllowOverlap = false;
+ if (id != 0 && g.HoveredIdPreviousFrame != id)
+ g.HoveredIdTimer = g.HoveredIdNotActiveTimer = 0.0f;
+}
ImGuiID ImGui::GetHoveredID()
{
@@ -2822,103 +3064,6 @@ static inline bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFla
if ((focused_root_window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiHoveredFlags_AllowWhenBlockedByPopup))
return false;
}
-
- // Filter by viewport
- if (window->Viewport != g.MouseViewport)
- if (g.MovingWindow == NULL || window->RootWindow != g.MovingWindow->RootWindow)
- return false;
-
- return true;
-}
-
-// Advance cursor given item size for layout.
-void ImGui::ItemSize(const ImVec2& size, float text_baseline_y)
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
- if (window->SkipItems)
- return;
-
- // Always align ourselves on pixel boundaries
- const float line_height = ImMax(window->DC.CurrLineSize.y, size.y);
- //if (g.IO.KeyAlt) window->DrawList->AddRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(size.x, line_height), IM_COL32(255,0,0,200)); // [DEBUG]
- window->DC.CursorPosPrevLine.x = window->DC.CursorPos.x + size.x;
- window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y;
- window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); // Next line
- window->DC.CursorPos.y = IM_FLOOR(window->DC.CursorPos.y + line_height + g.Style.ItemSpacing.y); // Next line
- window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPosPrevLine.x);
- window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y - g.Style.ItemSpacing.y);
- //if (g.IO.KeyAlt) window->DrawList->AddCircle(window->DC.CursorMaxPos, 3.0f, IM_COL32(255,0,0,255), 4); // [DEBUG]
-
- window->DC.PrevLineSize.y = line_height;
- window->DC.CurrLineSize.y = 0.0f;
- window->DC.PrevLineTextBaseOffset = ImMax(window->DC.CurrLineTextBaseOffset, text_baseline_y);
- window->DC.CurrLineTextBaseOffset = 0.0f;
-
- // Horizontal layout mode
- if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
- SameLine();
-}
-
-void ImGui::ItemSize(const ImRect& bb, float text_baseline_y)
-{
- ItemSize(bb.GetSize(), text_baseline_y);
-}
-
-// Declare item bounding box for clipping and interaction.
-// Note that the size can be different than the one provided to ItemSize(). Typically, widgets that spread over available surface
-// declare their minimum size requirement to ItemSize() and then use a larger region for drawing/interaction, which is passed to ItemAdd().
-bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg)
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
-
- if (id != 0)
- {
- // Navigation processing runs prior to clipping early-out
- // (a) So that NavInitRequest can be honored, for newly opened windows to select a default widget
- // (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests
- // unfortunately, but it is still limited to one window. It may not scale very well for windows with ten of
- // thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame.
- // We could early out with "if (is_clipped && !g.NavInitRequest) return false;" but when we wouldn't be able
- // to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick).
- // We intentionally don't check if g.NavWindow != NULL because g.NavAnyRequest should only be set when it is non null.
- // If we crash on a NULL g.NavWindow we need to fix the bug elsewhere.
- window->DC.NavLayerActiveMaskNext |= window->DC.NavLayerCurrentMask;
- if (g.NavId == id || g.NavAnyRequest)
- if (g.NavWindow->RootWindowForNav == window->RootWindowForNav)
- if (window == g.NavWindow || ((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened))
- NavProcessItem(window, nav_bb_arg ? *nav_bb_arg : bb, id);
-
- // [DEBUG] Item Picker tool, when enabling the "extended" version we perform the check in ItemAdd()
-#ifdef IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
- if (id == g.DebugItemPickerBreakID)
- {
- IM_DEBUG_BREAK();
- g.DebugItemPickerBreakID = 0;
- }
-#endif
- }
-
- window->DC.LastItemId = id;
- window->DC.LastItemRect = bb;
- window->DC.LastItemStatusFlags = ImGuiItemStatusFlags_None;
- g.NextItemData.Flags = ImGuiNextItemDataFlags_None;
-
-#ifdef IMGUI_ENABLE_TEST_ENGINE
- if (id != 0)
- IMGUI_TEST_ENGINE_ITEM_ADD(nav_bb_arg ? *nav_bb_arg : bb, id);
-#endif
-
- // Clipping test
- const bool is_clipped = IsClippedEx(bb, id, false);
- if (is_clipped)
- return false;
- //if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG]
-
- // We need to calculate this now to take account of the current clipping rectangle (as items like Selectable may change them)
- if (IsMouseHoveringRect(bb.Min, bb.Max))
- window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HoveredRect;
return true;
}
@@ -2961,7 +3106,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
// Special handling for the dummy item after Begin() which represent the title bar or tab.
// When the window is collapsed (SkipItems==true) that last item will never be overwritten so we need to detect the case.
- if ((window->DC.LastItemId == window->ID || window->DC.LastItemId == window->MoveId) && window->WriteAccessed)
+ if (window->DC.LastItemId == window->MoveId && window->WriteAccessed)
return false;
return true;
}
@@ -2994,7 +3139,7 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id)
// #define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX in imconfig.h if you want this check to also be performed in ItemAdd().
if (g.DebugItemPickerActive && g.HoveredIdPreviousFrame == id)
GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(255, 255, 0, 255));
- if (g.DebugItemPickerBreakID == id)
+ if (g.DebugItemPickerBreakId == id)
IM_DEBUG_BREAK();
return true;
@@ -3005,7 +3150,7 @@ bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
if (!bb.Overlaps(window->ClipRect))
- if (id == 0 || id != g.ActiveId)
+ if (id == 0 || (id != g.ActiveId && id != g.NavId))
if (clip_even_when_logged || !g.LogEnabled)
return true;
return false;
@@ -3018,24 +3163,24 @@ bool ImGui::FocusableItemRegister(ImGuiWindow* window, ImGuiID id)
// Increment counters
const bool is_tab_stop = (window->DC.ItemFlags & (ImGuiItemFlags_NoTabStop | ImGuiItemFlags_Disabled)) == 0;
- window->DC.FocusCounterAll++;
+ window->DC.FocusCounterRegular++;
if (is_tab_stop)
- window->DC.FocusCounterTab++;
+ window->DC.FocusCounterTabStop++;
// Process TAB/Shift-TAB to tab *OUT* of the currently focused item.
// (Note that we can always TAB out of a widget that doesn't allow tabbing in)
if (g.ActiveId == id && g.FocusTabPressed && !IsActiveIdUsingKey(ImGuiKey_Tab) && g.FocusRequestNextWindow == NULL)
{
g.FocusRequestNextWindow = window;
- g.FocusRequestNextCounterTab = window->DC.FocusCounterTab + (g.IO.KeyShift ? (is_tab_stop ? -1 : 0) : +1); // Modulo on index will be applied at the end of frame once we've got the total counter of items.
+ g.FocusRequestNextCounterTabStop = window->DC.FocusCounterTabStop + (g.IO.KeyShift ? (is_tab_stop ? -1 : 0) : +1); // Modulo on index will be applied at the end of frame once we've got the total counter of items.
}
// Handle focus requests
if (g.FocusRequestCurrWindow == window)
{
- if (window->DC.FocusCounterAll == g.FocusRequestCurrCounterAll)
+ if (window->DC.FocusCounterRegular == g.FocusRequestCurrCounterRegular)
return true;
- if (is_tab_stop && window->DC.FocusCounterTab == g.FocusRequestCurrCounterTab)
+ if (is_tab_stop && window->DC.FocusCounterTabStop == g.FocusRequestCurrCounterTabStop)
{
g.NavJustTabbedId = id;
return true;
@@ -3051,8 +3196,8 @@ bool ImGui::FocusableItemRegister(ImGuiWindow* window, ImGuiID id)
void ImGui::FocusableItemUnregister(ImGuiWindow* window)
{
- window->DC.FocusCounterAll--;
- window->DC.FocusCounterTab--;
+ window->DC.FocusCounterRegular--;
+ window->DC.FocusCounterTabStop--;
}
float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
@@ -3120,24 +3265,6 @@ void ImGui::SetCurrentContext(ImGuiContext* ctx)
#endif
}
-// Helper function to verify ABI compatibility between caller code and compiled version of Dear ImGui.
-// Verify that the type sizes are matching between the calling file's compilation unit and imgui.cpp's compilation unit
-// If the user has inconsistent compilation settings, imgui configuration #define, packing pragma, etc. your user code
-// may see different structures than what imgui.cpp sees, which is problematic.
-// We usually require settings to be in imconfig.h to make sure that they are accessible to all compilation units involved with Dear ImGui.
-bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_vert, size_t sz_idx)
-{
- bool error = false;
- if (strcmp(version, IMGUI_VERSION)!=0) { error = true; IM_ASSERT(strcmp(version,IMGUI_VERSION)==0 && "Mismatched version string!"); }
- if (sz_io != sizeof(ImGuiIO)) { error = true; IM_ASSERT(sz_io == sizeof(ImGuiIO) && "Mismatched struct layout!"); }
- if (sz_style != sizeof(ImGuiStyle)) { error = true; IM_ASSERT(sz_style == sizeof(ImGuiStyle) && "Mismatched struct layout!"); }
- if (sz_vec2 != sizeof(ImVec2)) { error = true; IM_ASSERT(sz_vec2 == sizeof(ImVec2) && "Mismatched struct layout!"); }
- if (sz_vec4 != sizeof(ImVec4)) { error = true; IM_ASSERT(sz_vec4 == sizeof(ImVec4) && "Mismatched struct layout!"); }
- if (sz_vert != sizeof(ImDrawVert)) { error = true; IM_ASSERT(sz_vert == sizeof(ImDrawVert) && "Mismatched struct layout!"); }
- if (sz_idx != sizeof(ImDrawIdx)) { error = true; IM_ASSERT(sz_idx == sizeof(ImDrawIdx) && "Mismatched struct layout!"); }
- return !error;
-}
-
void ImGui::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data)
{
GImAllocatorAllocFunc = alloc_func;
@@ -3170,23 +3297,11 @@ ImGuiIO& ImGui::GetIO()
return GImGui->IO;
}
-ImGuiPlatformIO& ImGui::GetPlatformIO()
-{
- IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() or ImGui::SetCurrentContext()?");
- return GImGui->PlatformIO;
-}
-
-ImGuiStyle& ImGui::GetStyle()
-{
- IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
- return GImGui->Style;
-}
-
// Same value as passed to the old io.RenderDrawListsFn function. Valid after Render() and until the next call to NewFrame()
ImDrawData* ImGui::GetDrawData()
{
ImGuiContext& g = *GImGui;
- return g.Viewports[0]->DrawDataP.Valid ? &g.Viewports[0]->DrawDataP : NULL;
+ return g.DrawData.Valid ? &g.DrawData : NULL;
}
double ImGui::GetTime()
@@ -3199,50 +3314,14 @@ int ImGui::GetFrameCount()
return GImGui->FrameCount;
}
-static ImDrawList* GetViewportDrawList(ImGuiViewportP* viewport, size_t drawlist_no, const char* drawlist_name)
-{
- // Create the draw list on demand, because they are not frequently used for all viewports
- ImGuiContext& g = *GImGui;
- IM_ASSERT(drawlist_no >= 0 && drawlist_no < IM_ARRAYSIZE(viewport->DrawLists));
- ImDrawList* draw_list = viewport->DrawLists[drawlist_no];
- if (draw_list == NULL)
- {
- draw_list = IM_NEW(ImDrawList)(&g.DrawListSharedData);
- draw_list->_OwnerName = drawlist_name;
- viewport->DrawLists[drawlist_no] = draw_list;
- }
-
- // Our ImDrawList system requires that there is always a command
- if (viewport->LastFrameDrawLists[drawlist_no] != g.FrameCount)
- {
- draw_list->Clear();
- draw_list->PushTextureID(g.IO.Fonts->TexID);
- draw_list->PushClipRect(viewport->Pos, viewport->Pos + viewport->Size, false);
- viewport->LastFrameDrawLists[drawlist_no] = g.FrameCount;
- }
- return draw_list;
-}
-
-ImDrawList* ImGui::GetBackgroundDrawList(ImGuiViewport* viewport)
-{
- return GetViewportDrawList((ImGuiViewportP*)viewport, 0, "##Background");
-}
-
ImDrawList* ImGui::GetBackgroundDrawList()
{
- ImGuiWindow* window = GImGui->CurrentWindow;
- return GetBackgroundDrawList(window->Viewport);
-}
-
-ImDrawList* ImGui::GetForegroundDrawList(ImGuiViewport* viewport)
-{
- return GetViewportDrawList((ImGuiViewportP*)viewport, 1, "##Foreground");
+ return &GImGui->BackgroundDrawList;
}
ImDrawList* ImGui::GetForegroundDrawList()
{
- ImGuiWindow* window = GImGui->CurrentWindow;
- return GetForegroundDrawList(window->Viewport);
+ return &GImGui->ForegroundDrawList;
}
ImDrawListSharedData* ImGui::GetDrawListSharedData()
@@ -3264,41 +3343,15 @@ void ImGui::StartMouseMovingWindow(ImGuiWindow* window)
bool can_move_window = true;
if ((window->Flags & ImGuiWindowFlags_NoMove) || (window->RootWindow->Flags & ImGuiWindowFlags_NoMove))
can_move_window = false;
- if (ImGuiDockNode* node = window->DockNodeAsHost)
- if (node->VisibleWindow && (node->VisibleWindow->Flags & ImGuiWindowFlags_NoMove))
- can_move_window = false;
if (can_move_window)
g.MovingWindow = window;
}
-void ImGui::StartMouseDragFromTitleBar(ImGuiWindow* window, ImGuiDockNode* node, bool from_collapse_button)
-{
- ImGuiContext& g = *GImGui;
- bool can_extract_dock_node = false;
- if (node != NULL && node->VisibleWindow && (node->VisibleWindow->Flags & ImGuiWindowFlags_NoMove) == 0)
- {
- ImGuiDockNode* root_node = DockNodeGetRootNode(node);
- if (root_node->OnlyNodeWithWindows != node || (root_node->CentralNode != NULL))
- if (from_collapse_button || root_node->IsDockSpace())
- can_extract_dock_node = true;
- }
-
- const bool clicked = IsMouseClicked(0);
- const bool dragging = IsMouseDragging(0, g.IO.MouseDragThreshold * 1.70f);
- if (can_extract_dock_node && dragging)
- {
- DockContextQueueUndockNode(&g, node);
- g.ActiveIdClickOffset = g.IO.MouseClickedPos[0] - node->Pos;
- }
- else if (!can_extract_dock_node && (clicked || dragging) && g.MovingWindow != window)
- {
- StartMouseMovingWindow(window);
- g.ActiveIdClickOffset = g.IO.MouseClickedPos[0] - window->RootWindow->Pos;
- }
-}
-
// Handle mouse moving window
// Note: moving window with the navigation keys (Square + d-pad / CTRL+TAB + Arrows) are processed in NavUpdateWindowing()
+// FIXME: We don't have strong guarantee that g.MovingWindow stay synched with g.ActiveId == g.MovingWindow->MoveId.
+// This is currently enforced by the fact that BeginDragDropSource() is setting all g.ActiveIdUsingXXXX flags to inhibit navigation inputs,
+// but if we should more thoroughly test cases where g.ActiveId or g.MovingWindow gets changed and not the other.
void ImGui::UpdateMouseMovingWindowNewFrame()
{
ImGuiContext& g = *GImGui;
@@ -3316,25 +3369,11 @@ void ImGui::UpdateMouseMovingWindowNewFrame()
{
MarkIniSettingsDirty(moving_window);
SetWindowPos(moving_window, pos, ImGuiCond_Always);
- if (moving_window->ViewportOwned) // Synchronize viewport immediately because some overlays may relies on clipping rectangle before we Begin() into the window.
- moving_window->Viewport->Pos = pos;
}
FocusWindow(g.MovingWindow);
}
else
{
- // Try to merge the window back into the main viewport.
- // This works because MouseViewport should be != MovingWindow->Viewport on release (as per code in UpdateViewports)
- if (g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable)
- UpdateTryMergeWindowIntoHostViewport(moving_window, g.MouseViewport);
-
- // Restore the mouse viewport so that we don't hover the viewport _under_ the moved window during the frame we released the mouse button.
- if (!IsDragDropPayloadBeingAccepted())
- g.MouseViewport = moving_window->Viewport;
-
- // Clear the NoInput window flag set by the Viewport system
- moving_window->Viewport->Flags &= ~ImGuiViewportFlags_NoInputs;
-
ClearActiveID();
g.MovingWindow = NULL;
}
@@ -3351,10 +3390,10 @@ void ImGui::UpdateMouseMovingWindowNewFrame()
}
}
-// Initiate moving window, handle left-click and right-click focus
+// Initiate moving window when clicking on empty space or title bar.
+// Handle left-click and right-click focus.
void ImGui::UpdateMouseMovingWindowEndFrame()
{
- // Initiate moving window
ImGuiContext& g = *GImGui;
if (g.ActiveId != 0 || g.HoveredId != 0)
return;
@@ -3369,7 +3408,7 @@ void ImGui::UpdateMouseMovingWindowEndFrame()
if (g.HoveredRootWindow != NULL)
{
StartMouseMovingWindow(g.HoveredWindow);
- if (g.IO.ConfigWindowsMoveFromTitleBarOnly && (!(g.HoveredRootWindow->Flags & ImGuiWindowFlags_NoTitleBar) || g.HoveredWindow->RootWindowDockStop->DockIsActive))
+ if (g.IO.ConfigWindowsMoveFromTitleBarOnly && !(g.HoveredRootWindow->Flags & ImGuiWindowFlags_NoTitleBar))
if (!g.HoveredRootWindow->TitleBarRect().Contains(g.IO.MouseClickedPos[0]))
g.MovingWindow = NULL;
}
@@ -3403,28 +3442,6 @@ void ImGui::UpdateMouseMovingWindowEndFrame()
}
}
-static void TranslateWindow(ImGuiWindow* window, const ImVec2& delta)
-{
- window->Pos += delta;
- window->ClipRect.Translate(delta);
- window->OuterRectClipped.Translate(delta);
- window->InnerRect.Translate(delta);
- window->DC.CursorPos += delta;
- window->DC.CursorStartPos += delta;
- window->DC.CursorMaxPos += delta;
- window->DC.LastItemRect.Translate(delta);
- window->DC.LastItemDisplayRect.Translate(delta);
-}
-
-static void ScaleWindow(ImGuiWindow* window, float scale)
-{
- ImVec2 origin = window->Viewport->Pos;
- window->Pos = ImFloor((window->Pos - origin) * scale + origin);
- window->Size = ImFloor(window->Size * scale);
- window->SizeFull = ImFloor(window->SizeFull * scale);
- window->ContentSize = ImFloor(window->ContentSize * scale);
-}
-
static bool IsWindowActiveAndVisible(ImGuiWindow* window)
{
return (window->Active) && (!window->Hidden);
@@ -3461,7 +3478,7 @@ static void ImGui::UpdateMouseInputs()
ImVec2 delta_from_click_pos = IsMousePosValid(&g.IO.MousePos) ? (g.IO.MousePos - g.IO.MouseClickedPos[i]) : ImVec2(0.0f, 0.0f);
if (ImLengthSqr(delta_from_click_pos) < g.IO.MouseDoubleClickMaxDist * g.IO.MouseDoubleClickMaxDist)
g.IO.MouseDoubleClicked[i] = true;
- g.IO.MouseClickedTime[i] = -FLT_MAX; // so the third click isn't turned into a double-click
+ g.IO.MouseClickedTime[i] = -DBL_MAX; // so the third click isn't turned into a double-click
}
else
{
@@ -3573,6 +3590,42 @@ void ImGui::UpdateMouseWheel()
}
}
+void ImGui::UpdateTabFocus()
+{
+ ImGuiContext& g = *GImGui;
+
+ // Pressing TAB activate widget focus
+ g.FocusTabPressed = (g.NavWindow && g.NavWindow->Active && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab));
+ if (g.ActiveId == 0 && g.FocusTabPressed)
+ {
+ // Note that SetKeyboardFocusHere() sets the Next fields mid-frame. To be consistent we also
+ // manipulate the Next fields even, even though they will be turned into Curr fields by the code below.
+ g.FocusRequestNextWindow = g.NavWindow;
+ g.FocusRequestNextCounterRegular = INT_MAX;
+ if (g.NavId != 0 && g.NavIdTabCounter != INT_MAX)
+ g.FocusRequestNextCounterTabStop = g.NavIdTabCounter + 1 + (g.IO.KeyShift ? -1 : 1);
+ else
+ g.FocusRequestNextCounterTabStop = g.IO.KeyShift ? -1 : 0;
+ }
+
+ // Turn queued focus request into current one
+ g.FocusRequestCurrWindow = NULL;
+ g.FocusRequestCurrCounterRegular = g.FocusRequestCurrCounterTabStop = INT_MAX;
+ if (g.FocusRequestNextWindow != NULL)
+ {
+ ImGuiWindow* window = g.FocusRequestNextWindow;
+ g.FocusRequestCurrWindow = window;
+ if (g.FocusRequestNextCounterRegular != INT_MAX && window->DC.FocusCounterRegular != -1)
+ g.FocusRequestCurrCounterRegular = ImModPositive(g.FocusRequestNextCounterRegular, window->DC.FocusCounterRegular + 1);
+ if (g.FocusRequestNextCounterTabStop != INT_MAX && window->DC.FocusCounterTabStop != -1)
+ g.FocusRequestCurrCounterTabStop = ImModPositive(g.FocusRequestNextCounterTabStop, window->DC.FocusCounterTabStop + 1);
+ g.FocusRequestNextWindow = NULL;
+ g.FocusRequestNextCounterRegular = g.FocusRequestNextCounterTabStop = INT_MAX;
+ }
+
+ g.NavIdTabCounter = INT_MAX;
+}
+
// The reason this is exposed in imgui_internal.h is: on touch-based system that don't have hovering, we want to dispatch inputs to the right target (imgui vs imgui+app)
void ImGui::UpdateHoveredWindowAndCaptureFlags()
{
@@ -3583,17 +3636,16 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
// - When moving a window we can skip the search, which also conveniently bypasses the fact that window->WindowRectClipped is lagging as this point of the frame.
// - We also support the moved window toggling the NoInputs flag after moving has started in order to be able to detect windows below it, which is useful for e.g. docking mechanisms.
FindHoveredWindow();
- IM_ASSERT(g.HoveredWindow == NULL || g.HoveredWindow == g.MovingWindow || g.HoveredWindow->Viewport == g.MouseViewport);
// Modal windows prevents cursor from hovering behind them.
ImGuiWindow* modal_window = GetTopMostPopupModal();
if (modal_window)
if (g.HoveredRootWindow && !IsWindowChildOf(g.HoveredRootWindow, modal_window))
- g.HoveredWindow = g.HoveredRootWindow = g.HoveredWindowUnderMovingWindow = NULL;
+ g.HoveredRootWindow = g.HoveredWindow = NULL;
// Disabled mouse?
if (g.IO.ConfigFlags & ImGuiConfigFlags_NoMouse)
- g.HoveredWindow = g.HoveredRootWindow = g.HoveredWindowUnderMovingWindow = NULL;
+ g.HoveredWindow = g.HoveredRootWindow = NULL;
// We track click ownership. When clicked outside of a window the click is owned by the application and won't report hovering nor request capture even while dragging over our windows afterward.
int mouse_earliest_button_down = -1;
@@ -3613,7 +3665,7 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
// FIXME: For patterns of drag and drop across OS windows, we may need to rework/remove this test (first committed 311c0ca9 on 2015/02)
const bool mouse_dragging_extern_payload = g.DragDropActive && (g.DragDropSourceFlags & ImGuiDragDropFlags_SourceExtern) != 0;
if (!mouse_avail_to_imgui && !mouse_dragging_extern_payload)
- g.HoveredWindow = g.HoveredRootWindow = g.HoveredWindowUnderMovingWindow = NULL;
+ g.HoveredWindow = g.HoveredRootWindow = NULL;
// Update io.WantCaptureMouse for the user application (true = dispatch mouse info to imgui, false = dispatch mouse info to Dear ImGui + app)
if (g.WantCaptureMouseNextFrame != -1)
@@ -3633,32 +3685,15 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
g.IO.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false;
}
-static void NewFrameSanityChecks()
+ImGuiKeyModFlags ImGui::GetMergedKeyModFlags()
{
ImGuiContext& g = *GImGui;
-
- // Check user data
- // (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument)
- IM_ASSERT(g.Initialized);
- IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!");
- IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?");
- IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!");
- IM_ASSERT(g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
- IM_ASSERT(g.IO.Fonts->Fonts[0]->IsLoaded() && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
- IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!");
- IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)!");
- IM_ASSERT(g.Style.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting.");
- IM_ASSERT(g.Style.WindowMenuButtonPosition == ImGuiDir_None || g.Style.WindowMenuButtonPosition == ImGuiDir_Left || g.Style.WindowMenuButtonPosition == ImGuiDir_Right);
- for (int n = 0; n < ImGuiKey_COUNT; n++)
- IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
-
- // Perform simple check: required key mapping (we intentionally do NOT check all keys to not pressure user into setting up everything, but Space is required and was only recently added in 1.60 WIP)
- if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard)
- IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation.");
-
- // Perform simple check: the beta io.ConfigWindowsResizeFromEdges option requires back-end to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly.
- if (g.IO.ConfigWindowsResizeFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors))
- g.IO.ConfigWindowsResizeFromEdges = false;
+ ImGuiKeyModFlags key_mod_flags = ImGuiKeyModFlags_None;
+ if (g.IO.KeyCtrl) { key_mod_flags |= ImGuiKeyModFlags_Ctrl; }
+ if (g.IO.KeyShift) { key_mod_flags |= ImGuiKeyModFlags_Shift; }
+ if (g.IO.KeyAlt) { key_mod_flags |= ImGuiKeyModFlags_Alt; }
+ if (g.IO.KeySuper) { key_mod_flags |= ImGuiKeyModFlags_Super; }
+ return key_mod_flags;
}
void ImGui::NewFrame()
@@ -3671,94 +3706,31 @@ void ImGui::NewFrame()
#endif
// Check and assert for various common IO and Configuration mistakes
- NewFrameSanityChecks();
-
- // Perform simple check: error if Docking or Viewport are enabled _exactly_ on frame 1 (instead of frame 0 or later), which is a common error leading to loss of .ini data.
- g.ConfigFlagsLastFrame = g.ConfigFlagsCurrFrame;
- if (g.FrameCount == 1 && (g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable) && (g.ConfigFlagsLastFrame & ImGuiConfigFlags_DockingEnable) == 0)
- IM_ASSERT(0 && "Please set DockingEnable before the first call to NewFrame()! Otherwise you will lose your .ini settings!");
- if (g.FrameCount == 1 && (g.IO.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) && (g.ConfigFlagsLastFrame & ImGuiConfigFlags_ViewportsEnable) == 0)
- IM_ASSERT(0 && "Please set ViewportsEnable before the first call to NewFrame()! Otherwise you will lose your .ini settings!");
-
- // Perform simple checks: multi-viewport and platform windows support
- if (g.IO.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
- {
- if ((g.IO.BackendFlags & ImGuiBackendFlags_PlatformHasViewports) && (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasViewports))
- {
- IM_ASSERT((g.FrameCount == 0 || g.FrameCount == g.FrameCountPlatformEnded) && "Forgot to call UpdatePlatformWindows() in main loop after EndFrame()? Check examples/ applications for reference.");
- IM_ASSERT(g.PlatformIO.Platform_CreateWindow != NULL && "Platform init didn't install handlers?");
- IM_ASSERT(g.PlatformIO.Platform_DestroyWindow != NULL && "Platform init didn't install handlers?");
- IM_ASSERT(g.PlatformIO.Platform_GetWindowPos != NULL && "Platform init didn't install handlers?");
- IM_ASSERT(g.PlatformIO.Platform_SetWindowPos != NULL && "Platform init didn't install handlers?");
- IM_ASSERT(g.PlatformIO.Platform_GetWindowSize != NULL && "Platform init didn't install handlers?");
- IM_ASSERT(g.PlatformIO.Platform_SetWindowSize != NULL && "Platform init didn't install handlers?");
- IM_ASSERT(g.PlatformIO.Monitors.Size > 0 && "Platform init didn't setup Monitors list?");
- IM_ASSERT((g.Viewports[0]->PlatformUserData != NULL || g.Viewports[0]->PlatformHandle != NULL) && "Platform init didn't setup main viewport.");
- if (g.IO.ConfigDockingTransparentPayload && (g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable))
- IM_ASSERT(g.PlatformIO.Platform_SetWindowAlpha != NULL && "Platform_SetWindowAlpha handler is required to use io.ConfigDockingTransparent!");
-#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
- IM_ASSERT(g.IO.RenderDrawListsFn == NULL); // Call ImGui::Render() then pass ImGui::GetDrawData() yourself to your render function!
-#endif
- }
- else
- {
- // Disable feature, our back-ends do not support it
- g.IO.ConfigFlags &= ~ImGuiConfigFlags_ViewportsEnable;
- }
-
- // Perform simple checks on platform monitor data + compute a total bounding box for quick early outs
- for (int monitor_n = 0; monitor_n < g.PlatformIO.Monitors.Size; monitor_n++)
- {
- ImGuiPlatformMonitor& mon = g.PlatformIO.Monitors[monitor_n];
- IM_UNUSED(mon);
- IM_ASSERT(mon.MainSize.x > 0.0f && mon.MainSize.y > 0.0f && "Monitor bounds not setup properly.");
- IM_ASSERT(mon.WorkSize.x > 0.0f && mon.WorkSize.y > 0.0f && "Monitor bounds not setup properly. If you don't have work area information, just copy Min/Max into them.");
- IM_ASSERT(mon.DpiScale != 0.0f);
- }
- }
- g.ConfigFlagsCurrFrame = g.IO.ConfigFlags;
-
- // Load settings on first frame (if not explicitly loaded manually before)
- if (!g.SettingsLoaded)
- {
- IM_ASSERT(g.SettingsWindows.empty());
- if (g.IO.IniFilename)
- LoadIniSettingsFromDisk(g.IO.IniFilename);
- g.SettingsLoaded = true;
- }
+ ErrorCheckNewFrameSanityChecks();
- // Save settings (with a delay after the last modification, so we don't spam disk too much)
- if (g.SettingsDirtyTimer > 0.0f)
- {
- g.SettingsDirtyTimer -= g.IO.DeltaTime;
- if (g.SettingsDirtyTimer <= 0.0f)
- {
- if (g.IO.IniFilename != NULL)
- SaveIniSettingsToDisk(g.IO.IniFilename);
- else
- g.IO.WantSaveIniSettings = true; // Let user know they can call SaveIniSettingsToMemory(). user will need to clear io.WantSaveIniSettings themselves.
- g.SettingsDirtyTimer = 0.0f;
- }
- }
+ // Load settings on first frame, save settings when modified (after a delay)
+ UpdateSettings();
g.Time += g.IO.DeltaTime;
- g.FrameScopeActive = true;
+ g.WithinFrameScope = true;
g.FrameCount += 1;
g.TooltipOverrideCount = 0;
g.WindowsActiveCount = 0;
+ g.MenusIdSubmittedThisFrame.resize(0);
+
+ // Calculate frame-rate for the user, as a purely luxurious feature
+ g.FramerateSecPerFrameAccum += g.IO.DeltaTime - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx];
+ g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx] = g.IO.DeltaTime;
+ g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame);
+ g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)IM_ARRAYSIZE(g.FramerateSecPerFrame))) : FLT_MAX;
- UpdateViewportsNewFrame();
-
// Setup current font and draw list shared data
- // FIXME-VIEWPORT: the concept of a single ClipRectFullscreen is not ideal!
g.IO.Fonts->Locked = true;
SetCurrentFont(GetDefaultFont());
IM_ASSERT(g.Font->IsLoaded());
- ImRect virtual_space(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
- for (int n = 0; n < g.Viewports.Size; n++)
- virtual_space.Add(g.Viewports[n]->GetRect());
- g.DrawListSharedData.ClipRectFullscreen = ImVec4(virtual_space.Min.x, virtual_space.Min.y, virtual_space.Max.x, virtual_space.Max.y);
+ g.DrawListSharedData.ClipRectFullscreen = ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y);
g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol;
+ g.DrawListSharedData.SetCircleSegmentMaxError(g.Style.CircleSegmentMaxError);
g.DrawListSharedData.InitialFlags = ImDrawListFlags_None;
if (g.Style.AntiAliasedLines)
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLines;
@@ -3767,19 +3739,22 @@ void ImGui::NewFrame()
if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset)
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AllowVtxOffset;
+ g.BackgroundDrawList.Clear();
+ g.BackgroundDrawList.PushTextureID(g.IO.Fonts->TexID);
+ g.BackgroundDrawList.PushClipRectFullScreen();
+
+ g.ForegroundDrawList.Clear();
+ g.ForegroundDrawList.PushTextureID(g.IO.Fonts->TexID);
+ g.ForegroundDrawList.PushClipRectFullScreen();
+
// Mark rendering data as invalid to prevent user who may have a handle on it to use it.
- for (int n = 0; n < g.Viewports.Size; n++)
- {
- ImGuiViewportP* viewport = g.Viewports[n];
- viewport->DrawData = NULL;
- viewport->DrawDataP.Clear();
- }
+ g.DrawData.Clear();
// Drag and drop keep the source ID alive so even if the source disappear our state is consistent
if (g.DragDropActive && g.DragDropPayload.SourceId == g.ActiveId)
KeepAliveID(g.DragDropPayload.SourceId);
- // Clear reference to active widget if the widget isn't alive anymore
+ // Update HoveredId data
if (!g.HoveredIdPreviousFrame)
g.HoveredIdTimer = 0.0f;
if (!g.HoveredIdPreviousFrame || (g.HoveredId && g.ActiveId == g.HoveredId))
@@ -3791,6 +3766,8 @@ void ImGui::NewFrame()
g.HoveredIdPreviousFrame = g.HoveredId;
g.HoveredId = 0;
g.HoveredIdAllowOverlap = false;
+
+ // Update ActiveId data (clear reference to active widget if the widget isn't alive anymore)
if (g.ActiveIdIsAlive != g.ActiveId && g.ActiveIdPreviousFrame == g.ActiveId && g.ActiveId != 0)
ClearActiveID();
if (g.ActiveId)
@@ -3803,41 +3780,35 @@ void ImGui::NewFrame()
g.ActiveIdHasBeenEditedThisFrame = false;
g.ActiveIdPreviousFrameIsAlive = false;
g.ActiveIdIsJustActivated = false;
- if (g.TempInputTextId != 0 && g.ActiveId != g.TempInputTextId)
- g.TempInputTextId = 0;
+ if (g.TempInputId != 0 && g.ActiveId != g.TempInputId)
+ g.TempInputId = 0;
if (g.ActiveId == 0)
{
- g.ActiveIdUsingNavDirMask = g.ActiveIdUsingNavInputMask = 0;
- g.ActiveIdUsingKeyInputMask = 0;
+ g.ActiveIdUsingNavDirMask = 0x00;
+ g.ActiveIdUsingNavInputMask = 0x00;
+ g.ActiveIdUsingKeyInputMask = 0x00;
}
// Drag and drop
g.DragDropAcceptIdPrev = g.DragDropAcceptIdCurr;
g.DragDropAcceptIdCurr = 0;
g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
- g.DragDropWithinSourceOrTarget = false;
+ g.DragDropWithinSource = false;
+ g.DragDropWithinTarget = false;
// Update keyboard input state
+ // Synchronize io.KeyMods with individual modifiers io.KeyXXX bools
+ g.IO.KeyMods = GetMergedKeyModFlags();
memcpy(g.IO.KeysDownDurationPrev, g.IO.KeysDownDuration, sizeof(g.IO.KeysDownDuration));
for (int i = 0; i < IM_ARRAYSIZE(g.IO.KeysDown); i++)
g.IO.KeysDownDuration[i] = g.IO.KeysDown[i] ? (g.IO.KeysDownDuration[i] < 0.0f ? 0.0f : g.IO.KeysDownDuration[i] + g.IO.DeltaTime) : -1.0f;
- // Update gamepad/keyboard directional navigation
+ // Update gamepad/keyboard navigation
NavUpdate();
// Update mouse input state
UpdateMouseInputs();
- // Calculate frame-rate for the user, as a purely luxurious feature
- g.FramerateSecPerFrameAccum += g.IO.DeltaTime - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx];
- g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx] = g.IO.DeltaTime;
- g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame);
- g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)IM_ARRAYSIZE(g.FramerateSecPerFrame))) : FLT_MAX;
-
- // Undocking
- // (needs to be before UpdateMouseMovingWindowNewFrame so the window is already offset and following the mouse on the detaching frame)
- DockContextUpdateUndocking(&g);
-
// Find hovered window
// (needs to be before UpdateMouseMovingWindowNewFrame so we fill g.HoveredWindowUnderMovingWindow on the mouse release frame)
UpdateHoveredWindowAndCaptureFlags();
@@ -3854,41 +3825,12 @@ void ImGui::NewFrame()
g.MouseCursor = ImGuiMouseCursor_Arrow;
g.WantCaptureMouseNextFrame = g.WantCaptureKeyboardNextFrame = g.WantTextInputNextFrame = -1;
g.PlatformImePos = ImVec2(1.0f, 1.0f); // OS Input Method Editor showing on top-left of our window by default
- g.PlatformImePosViewport = NULL;
// Mouse wheel scrolling, scale
UpdateMouseWheel();
- // Pressing TAB activate widget focus
- g.FocusTabPressed = (g.NavWindow && g.NavWindow->Active && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab));
- if (g.ActiveId == 0 && g.FocusTabPressed)
- {
- // Note that SetKeyboardFocusHere() sets the Next fields mid-frame. To be consistent we also
- // manipulate the Next fields even, even though they will be turned into Curr fields by the code below.
- g.FocusRequestNextWindow = g.NavWindow;
- g.FocusRequestNextCounterAll = INT_MAX;
- if (g.NavId != 0 && g.NavIdTabCounter != INT_MAX)
- g.FocusRequestNextCounterTab = g.NavIdTabCounter + 1 + (g.IO.KeyShift ? -1 : 1);
- else
- g.FocusRequestNextCounterTab = g.IO.KeyShift ? -1 : 0;
- }
-
- // Turn queued focus request into current one
- g.FocusRequestCurrWindow = NULL;
- g.FocusRequestCurrCounterAll = g.FocusRequestCurrCounterTab = INT_MAX;
- if (g.FocusRequestNextWindow != NULL)
- {
- ImGuiWindow* window = g.FocusRequestNextWindow;
- g.FocusRequestCurrWindow = window;
- if (g.FocusRequestNextCounterAll != INT_MAX && window->DC.FocusCounterAll != -1)
- g.FocusRequestCurrCounterAll = ImModPositive(g.FocusRequestNextCounterAll, window->DC.FocusCounterAll + 1);
- if (g.FocusRequestNextCounterTab != INT_MAX && window->DC.FocusCounterTab != -1)
- g.FocusRequestCurrCounterTab = ImModPositive(g.FocusRequestNextCounterTab, window->DC.FocusCounterTab + 1);
- g.FocusRequestNextWindow = NULL;
- g.FocusRequestNextCounterAll = g.FocusRequestNextCounterTab = INT_MAX;
- }
-
- g.NavIdTabCounter = INT_MAX;
+ // Update legacy TAB focus
+ UpdateTabFocus();
// Mark all windows as not visible and compact unused memory.
IM_ASSERT(g.WindowsFocusOrder.Size == g.Windows.Size);
@@ -3901,7 +3843,7 @@ void ImGui::NewFrame()
window->Active = false;
window->WriteAccessed = false;
- // Garbage collect (this is totally functional but we may need decide if the side-effects are desirable)
+ // Garbage collect transient buffers of recently unused windows
if (!window->WasActive && !window->MemoryCompacted && window->LastTimeActive < memory_compact_start_time)
GcCompactTransientWindowBuffers(window);
}
@@ -3916,16 +3858,13 @@ void ImGui::NewFrame()
g.BeginPopupStack.resize(0);
ClosePopupsOverWindow(g.NavWindow, false);
- // Docking
- DockContextUpdateDocking(&g);
-
// [DEBUG] Item picker tool - start with DebugStartItemPicker() - useful to visually select an item and break into its call-stack.
UpdateDebugToolItemPicker();
// Create implicit/fallback window - which we will only render it if the user has added something to it.
// We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags.
// This fallback is particularly important as it avoid ImGui:: calls from crashing.
- g.FrameScopePushedFallbackWindow = true;
+ g.WithinFrameScopeWithImplicitWindow = true;
SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver);
Begin("Debug##Default");
IM_ASSERT(g.CurrentWindow->IsFallbackWindow == true);
@@ -3939,7 +3878,7 @@ void ImGui::NewFrame()
void ImGui::UpdateDebugToolItemPicker()
{
ImGuiContext& g = *GImGui;
- g.DebugItemPickerBreakID = 0;
+ g.DebugItemPickerBreakId = 0;
if (g.DebugItemPickerActive)
{
const ImGuiID hovered_id = g.HoveredIdPreviousFrame;
@@ -3948,7 +3887,7 @@ void ImGui::UpdateDebugToolItemPicker()
g.DebugItemPickerActive = false;
if (ImGui::IsMouseClicked(0) && hovered_id)
{
- g.DebugItemPickerBreakID = hovered_id;
+ g.DebugItemPickerBreakId = hovered_id;
g.DebugItemPickerActive = false;
}
ImGui::SetNextWindowBgAlpha(0.60f);
@@ -3966,26 +3905,31 @@ void ImGui::Initialize(ImGuiContext* context)
IM_ASSERT(!g.Initialized && !g.SettingsLoaded);
// Add .ini handle for ImGuiWindow type
- ImGuiSettingsHandler ini_handler;
- ini_handler.TypeName = "Window";
- ini_handler.TypeHash = ImHashStr("Window");
- ini_handler.ReadOpenFn = SettingsHandlerWindow_ReadOpen;
- ini_handler.ReadLineFn = SettingsHandlerWindow_ReadLine;
- ini_handler.WriteAllFn = SettingsHandlerWindow_WriteAll;
- g.SettingsHandlers.push_back(ini_handler);
-
- // Create default viewport
- ImGuiViewportP* viewport = IM_NEW(ImGuiViewportP)();
- viewport->ID = IMGUI_VIEWPORT_DEFAULT_ID;
- viewport->Idx = 0;
- viewport->PlatformWindowCreated = true;
- g.Viewports.push_back(viewport);
- g.PlatformIO.MainViewport = g.Viewports[0]; // Make it accessible in public-facing GetPlatformIO() immediately (before the first call to EndFrame)
- g.PlatformIO.Viewports.push_back(g.Viewports[0]);
-
- // Extensions
- IM_ASSERT(g.DockContext == NULL);
- DockContextInitialize(&g);
+ {
+ ImGuiSettingsHandler ini_handler;
+ ini_handler.TypeName = "Window";
+ ini_handler.TypeHash = ImHashStr("Window");
+ ini_handler.ReadOpenFn = WindowSettingsHandler_ReadOpen;
+ ini_handler.ReadLineFn = WindowSettingsHandler_ReadLine;
+ ini_handler.WriteAllFn = WindowSettingsHandler_WriteAll;
+ g.SettingsHandlers.push_back(ini_handler);
+ }
+
+#ifdef IMGUI_HAS_TABLE
+ // Add .ini handle for ImGuiTable type
+ {
+ ImGuiSettingsHandler ini_handler;
+ ini_handler.TypeName = "Table";
+ ini_handler.TypeHash = ImHashStr("Table");
+ ini_handler.ReadOpenFn = TableSettingsHandler_ReadOpen;
+ ini_handler.ReadLineFn = TableSettingsHandler_ReadLine;
+ ini_handler.WriteAllFn = TableSettingsHandler_WriteAll;
+ g.SettingsHandlers.push_back(ini_handler);
+ }
+#endif // #ifdef IMGUI_HAS_TABLE
+
+#ifdef IMGUI_HAS_DOCK
+#endif // #ifdef IMGUI_HAS_DOCK
g.Initialized = true;
}
@@ -4015,27 +3959,17 @@ void ImGui::Shutdown(ImGuiContext* context)
SetCurrentContext(backup_context);
}
- // Destroy platform windows
- ImGuiContext* backup_context = ImGui::GetCurrentContext();
- SetCurrentContext(context);
- DestroyPlatformWindows();
- SetCurrentContext(backup_context);
-
- // Shutdown extensions
- IM_ASSERT(g.DockContext != NULL);
- DockContextShutdown(&g);
-
// Clear everything else
for (int i = 0; i < g.Windows.Size; i++)
IM_DELETE(g.Windows[i]);
g.Windows.clear();
g.WindowsFocusOrder.clear();
- g.WindowsSortBuffer.clear();
+ g.WindowsTempSortBuffer.clear();
g.CurrentWindow = NULL;
g.CurrentWindowStack.clear();
g.WindowsById.Clear();
g.NavWindow = NULL;
- g.HoveredWindow = g.HoveredRootWindow = g.HoveredWindowUnderMovingWindow = NULL;
+ g.HoveredWindow = g.HoveredRootWindow = NULL;
g.ActiveIdWindow = g.ActiveIdPreviousFrameWindow = NULL;
g.MovingWindow = NULL;
g.ColorModifiers.clear();
@@ -4043,27 +3977,27 @@ void ImGui::Shutdown(ImGuiContext* context)
g.FontStack.clear();
g.OpenPopupStack.clear();
g.BeginPopupStack.clear();
-
- g.CurrentViewport = g.MouseViewport = g.MouseLastHoveredViewport = NULL;
- for (int i = 0; i < g.Viewports.Size; i++)
- IM_DELETE(g.Viewports[i]);
- g.Viewports.clear();
+ g.DrawDataBuilder.ClearFreeMemory();
+ g.BackgroundDrawList.ClearFreeMemory();
+ g.ForegroundDrawList.ClearFreeMemory();
g.TabBars.Clear();
g.CurrentTabBarStack.clear();
g.ShrinkWidthBuffer.clear();
- g.PrivateClipboard.clear();
+ g.ClipboardHandlerData.clear();
+ g.MenusIdSubmittedThisFrame.clear();
g.InputTextState.ClearFreeMemory();
- for (int i = 0; i < g.SettingsWindows.Size; i++)
- IM_DELETE(g.SettingsWindows[i].Name);
g.SettingsWindows.clear();
g.SettingsHandlers.clear();
- if (g.LogFile && g.LogFile != stdout)
+ if (g.LogFile)
{
- fclose(g.LogFile);
+#ifndef IMGUI_DISABLE_TTY_FUNCTIONS
+ if (g.LogFile != stdout)
+#endif
+ ImFileClose(g.LogFile);
g.LogFile = NULL;
}
g.LogBuffer.clear();
@@ -4129,7 +4063,7 @@ static void AddDrawListToDrawData(ImVector* out_list, ImDrawList* d
// (A) Handle the ImDrawCmd::VtxOffset value in your renderer back-end, and set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset'.
// Most example back-ends already support this from 1.71. Pre-1.71 back-ends won't.
// Some graphics API such as GL ES 1/2 don't have a way to offset the starting vertex so it is not supported for them.
- // (B) Or handle 32-bits indices in your renderer back-end, and uncomment '#define ImDrawIdx unsigned int' line in imconfig.h.
+ // (B) Or handle 32-bit indices in your renderer back-end, and uncomment '#define ImDrawIdx unsigned int' line in imconfig.h.
// Most example back-ends already support this. For example, the OpenGL example code detect index size at compile-time:
// glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);
// Your own engine or render API may use different parameters or function calls to specify index sizes.
@@ -4142,24 +4076,25 @@ static void AddDrawListToDrawData(ImVector* out_list, ImDrawList* d
out_list->push_back(draw_list);
}
-static void AddWindowToDrawData(ImGuiWindow* window, int layer)
+static void AddWindowToDrawData(ImVector* out_render_list, ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
g.IO.MetricsRenderWindows++;
- AddDrawListToDrawData(&window->Viewport->DrawDataBuilder.Layers[layer], window->DrawList);
+ AddDrawListToDrawData(out_render_list, window->DrawList);
for (int i = 0; i < window->DC.ChildWindows.Size; i++)
{
ImGuiWindow* child = window->DC.ChildWindows[i];
- if (IsWindowActiveAndVisible(child)) // Clipped children may have been marked not active
- AddWindowToDrawData(child, layer);
+ if (IsWindowActiveAndVisible(child)) // clipped children may have been marked not active
+ AddWindowToDrawData(out_render_list, child);
}
}
// Layer is locked for the root window, however child windows may use a different viewport (e.g. extruding menu)
static void AddRootWindowToDrawData(ImGuiWindow* window)
{
+ ImGuiContext& g = *GImGui;
int layer = (window->Flags & ImGuiWindowFlags_Tooltip) ? 1 : 0;
- AddWindowToDrawData(window, layer);
+ AddWindowToDrawData(&g.DrawDataBuilder.Layers[layer], window);
}
void ImDrawDataBuilder::FlattenIntoSingleLayer()
@@ -4180,18 +4115,16 @@ void ImDrawDataBuilder::FlattenIntoSingleLayer()
}
}
-static void SetupViewportDrawData(ImGuiViewportP* viewport, ImVector* draw_lists)
+static void SetupDrawData(ImVector* draw_lists, ImDrawData* draw_data)
{
- ImDrawData* draw_data = &viewport->DrawDataP;
- viewport->DrawData = draw_data; // Make publicly accessible
+ ImGuiIO& io = ImGui::GetIO();
draw_data->Valid = true;
draw_data->CmdLists = (draw_lists->Size > 0) ? draw_lists->Data : NULL;
draw_data->CmdListsCount = draw_lists->Size;
draw_data->TotalVtxCount = draw_data->TotalIdxCount = 0;
- draw_data->DisplayPos = viewport->Pos;
- draw_data->DisplaySize = viewport->Size;
- draw_data->FramebufferScale = ImGui::GetIO().DisplayFramebufferScale; // FIXME-VIEWPORT: This may vary on a per-monitor/viewport basis?
- draw_data->OwnerViewport = viewport;
+ draw_data->DisplayPos = ImVec2(0.0f, 0.0f);
+ draw_data->DisplaySize = io.DisplaySize;
+ draw_data->FramebufferScale = io.DisplayFramebufferScale;
for (int n = 0; n < draw_lists->Size; n++)
{
draw_data->TotalVtxCount += draw_lists->Data[n]->VtxBuffer.Size;
@@ -4214,113 +4147,36 @@ void ImGui::PopClipRect()
window->ClipRect = window->DrawList->_ClipRectStack.back();
}
-static ImGuiWindow* FindFrontMostVisibleChildWindow(ImGuiWindow* window)
-{
- for (int n = window->DC.ChildWindows.Size - 1; n >= 0; n--)
- if (IsWindowActiveAndVisible(window->DC.ChildWindows[n]))
- return FindFrontMostVisibleChildWindow(window->DC.ChildWindows[n]);
- return window;
-}
-
-static void ImGui::EndFrameDrawDimmedBackgrounds()
-{
- ImGuiContext& g = *GImGui;
-
- // Draw modal whitening background on _other_ viewports than the one the modal is one
- ImGuiWindow* modal_window = GetTopMostPopupModal();
- const bool dim_bg_for_modal = (modal_window != NULL);
- const bool dim_bg_for_window_list = (g.NavWindowingTargetAnim != NULL);
- if (dim_bg_for_modal || dim_bg_for_window_list)
- for (int viewport_n = 0; viewport_n < g.Viewports.Size; viewport_n++)
- {
- ImGuiViewportP* viewport = g.Viewports[viewport_n];
- if (modal_window && viewport == modal_window->Viewport)
- continue;
- if (g.NavWindowingList && viewport == g.NavWindowingList->Viewport)
- continue;
- if (g.NavWindowingTargetAnim && viewport == g.NavWindowingTargetAnim->Viewport)
- continue;
- ImDrawList* draw_list = GetForegroundDrawList(viewport);
- const ImU32 dim_bg_col = GetColorU32(dim_bg_for_modal ? ImGuiCol_ModalWindowDimBg : ImGuiCol_NavWindowingDimBg, g.DimBgRatio);
- draw_list->AddRectFilled(viewport->Pos, viewport->Pos + viewport->Size, dim_bg_col);
- }
-
- // Draw modal whitening background between CTRL-TAB list
- if (dim_bg_for_window_list)
- {
- // Choose a draw list that will be front-most across all our children
- ImGuiWindow* window = g.NavWindowingTargetAnim;
- ImDrawList* draw_list = FindFrontMostVisibleChildWindow(window->RootWindow)->DrawList;
- draw_list->PushClipRectFullScreen();
-
- // Docking: draw modal whitening background on other nodes of a same dock tree
- if (window->RootWindowDockStop->DockIsActive)
- if (window->RootWindow != window->RootWindowDockStop)
- RenderRectFilledWithHole(draw_list, window->RootWindow->Rect(), window->RootWindowDockStop->Rect(), GetColorU32(ImGuiCol_NavWindowingDimBg, g.DimBgRatio), g.Style.WindowRounding);
-
- // Draw navigation selection/windowing rectangle border
- float rounding = ImMax(window->WindowRounding, g.Style.WindowRounding);
- ImRect bb = window->Rect();
- bb.Expand(g.FontSize);
- if (bb.Contains(window->Viewport->GetRect())) // If a window fits the entire viewport, adjust its highlight inward
- {
- bb.Expand(-g.FontSize - 1.0f);
- rounding = window->WindowRounding;
- }
- draw_list->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha), rounding, ~0, 3.0f);
- draw_list->PopClipRect();
- }
-}
-
// This is normally called by Render(). You may want to call it directly if you want to avoid calling Render() but the gain will be very minimal.
void ImGui::EndFrame()
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.Initialized);
- if (g.FrameCountEnded == g.FrameCount) // Don't process EndFrame() multiple times.
+
+ // Don't process EndFrame() multiple times.
+ if (g.FrameCountEnded == g.FrameCount)
return;
- IM_ASSERT(g.FrameScopeActive && "Forgot to call ImGui::NewFrame()?");
+ IM_ASSERT(g.WithinFrameScope && "Forgot to call ImGui::NewFrame()?");
- // Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME)
- if (g.PlatformIO.Platform_SetImeInputPos && (g.PlatformImeLastPos.x == FLT_MAX || ImLengthSqr(g.PlatformImePos - g.PlatformImeLastPos) > 0.0001f))
- if (g.PlatformImePosViewport && g.PlatformImePosViewport->PlatformWindowCreated)
- {
- g.PlatformIO.Platform_SetImeInputPos(g.PlatformImePosViewport, g.PlatformImePos);
- g.PlatformImeLastPos = g.PlatformImePos;
- g.PlatformImePosViewport = NULL;
- }
+ ErrorCheckEndFrameSanityChecks();
- // Report when there is a mismatch of Begin/BeginChild vs End/EndChild calls. Important: Remember that the Begin/BeginChild API requires you
- // to always call End/EndChild even if Begin/BeginChild returns false! (this is unfortunately inconsistent with most other Begin* API).
- if (g.CurrentWindowStack.Size != 1)
+ // Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME)
+ if (g.IO.ImeSetInputScreenPosFn && (g.PlatformImeLastPos.x == FLT_MAX || ImLengthSqr(g.PlatformImeLastPos - g.PlatformImePos) > 0.0001f))
{
- if (g.CurrentWindowStack.Size > 1)
- {
- IM_ASSERT(g.CurrentWindowStack.Size == 1 && "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?");
- while (g.CurrentWindowStack.Size > 1) // FIXME-ERRORHANDLING
- End();
- }
- else
- {
- IM_ASSERT(g.CurrentWindowStack.Size == 1 && "Mismatched Begin/BeginChild vs End/EndChild calls: did you call End/EndChild too much?");
- }
+ g.IO.ImeSetInputScreenPosFn((int)g.PlatformImePos.x, (int)g.PlatformImePos.y);
+ g.PlatformImeLastPos = g.PlatformImePos;
}
// Hide implicit/fallback "Debug" window if it hasn't been used
- g.FrameScopePushedFallbackWindow = false;
+ g.WithinFrameScopeWithImplicitWindow = false;
if (g.CurrentWindow && !g.CurrentWindow->WriteAccessed)
g.CurrentWindow->Active = false;
End();
- // Draw modal whitening background on _other_ viewports than the one the modal is one
- EndFrameDrawDimmedBackgrounds();
-
// Show CTRL+TAB list window
if (g.NavWindowingTarget != NULL)
NavUpdateWindowingOverlay();
- SetCurrentViewport(NULL, NULL);
-
// Drag and Drop: Elapse payload (if delivered, or if source stops being submitted)
if (g.DragDropActive)
{
@@ -4333,36 +4189,33 @@ void ImGui::EndFrame()
// Drag and Drop: Fallback for source tooltip. This is not ideal but better than nothing.
if (g.DragDropActive && g.DragDropSourceFrameCount < g.FrameCount)
{
- g.DragDropWithinSourceOrTarget = true;
+ g.DragDropWithinSource = true;
SetTooltip("...");
- g.DragDropWithinSourceOrTarget = false;
+ g.DragDropWithinSource = false;
}
// End frame
- g.FrameScopeActive = false;
+ g.WithinFrameScope = false;
g.FrameCountEnded = g.FrameCount;
// Initiate moving window + handle left-click and right-click focus
UpdateMouseMovingWindowEndFrame();
- // Update user-facing viewport list (g.Viewports -> g.PlatformIO.Viewports after filtering out some)
- UpdateViewportsEndFrame();
-
// Sort the window list so that all child windows are after their parent
// We cannot do that on FocusWindow() because childs may not exist yet
- g.WindowsSortBuffer.resize(0);
- g.WindowsSortBuffer.reserve(g.Windows.Size);
+ g.WindowsTempSortBuffer.resize(0);
+ g.WindowsTempSortBuffer.reserve(g.Windows.Size);
for (int i = 0; i != g.Windows.Size; i++)
{
ImGuiWindow* window = g.Windows[i];
if (window->Active && (window->Flags & ImGuiWindowFlags_ChildWindow)) // if a child is active its parent will add it
continue;
- AddWindowToSortBuffer(&g.WindowsSortBuffer, window);
+ AddWindowToSortBuffer(&g.WindowsTempSortBuffer, window);
}
// This usually assert if there is a mismatch between the ImGuiWindowFlags_ChildWindow / ParentWindow values and DC.ChildWindows[] in parents, aka we've done something wrong.
- IM_ASSERT(g.Windows.Size == g.WindowsSortBuffer.Size);
- g.Windows.swap(g.WindowsSortBuffer);
+ IM_ASSERT(g.Windows.Size == g.WindowsTempSortBuffer.Size);
+ g.Windows.swap(g.WindowsTempSortBuffer);
g.IO.MetricsActiveWindows = g.WindowsActiveCount;
// Unlock font atlas
@@ -4382,18 +4235,14 @@ void ImGui::Render()
if (g.FrameCountEnded != g.FrameCount)
EndFrame();
g.FrameCountRendered = g.FrameCount;
- g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = g.IO.MetricsRenderWindows = 0;
+ g.IO.MetricsRenderWindows = 0;
+ g.DrawDataBuilder.Clear();
- // Add background ImDrawList (for each active viewport)
- for (int n = 0; n != g.Viewports.Size; n++)
- {
- ImGuiViewportP* viewport = g.Viewports[n];
- viewport->DrawDataBuilder.Clear();
- if (viewport->DrawLists[0] != NULL)
- AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport));
- }
+ // Add background ImDrawList
+ if (!g.BackgroundDrawList.VtxBuffer.empty())
+ AddDrawListToDrawData(&g.DrawDataBuilder.Layers[0], &g.BackgroundDrawList);
- // Add ImDrawList to render (for each active window)
+ // Add ImDrawList to render
ImGuiWindow* windows_to_render_top_most[2];
windows_to_render_top_most[0] = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget->RootWindow : NULL;
windows_to_render_top_most[1] = (g.NavWindowingTarget ? g.NavWindowingList : NULL);
@@ -4404,41 +4253,27 @@ void ImGui::Render()
AddRootWindowToDrawData(window);
}
for (int n = 0; n < IM_ARRAYSIZE(windows_to_render_top_most); n++)
- if (windows_to_render_top_most[n] && IsWindowActiveAndVisible(windows_to_render_top_most[n])) // NavWindowingTarget is always temporarily displayed as the tp-most window
+ if (windows_to_render_top_most[n] && IsWindowActiveAndVisible(windows_to_render_top_most[n])) // NavWindowingTarget is always temporarily displayed as the top-most window
AddRootWindowToDrawData(windows_to_render_top_most[n]);
+ g.DrawDataBuilder.FlattenIntoSingleLayer();
// Draw software mouse cursor if requested
- ImRect mouse_cursor_rect;
- if (g.IO.MouseDrawCursor && g.MouseCursor != ImGuiMouseCursor_None)
- {
- ImVec2 offset, size, uv[4];
- if (g.IO.Fonts->GetMouseCursorTexData(g.MouseCursor, &offset, &size, &uv[0], &uv[2]))
- mouse_cursor_rect = ImRect(g.IO.MousePos, g.IO.MousePos + ImVec2(size.x + 2, size.y + 2) * g.Style.MouseCursorScale);
- }
-
- // Setup ImDrawData structures for end-user
- g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = 0;
- for (int n = 0; n < g.Viewports.Size; n++)
- {
- ImGuiViewportP* viewport = g.Viewports[n];
- viewport->DrawDataBuilder.FlattenIntoSingleLayer();
-
- if (viewport->GetRect().Overlaps(mouse_cursor_rect))
- RenderMouseCursor(GetForegroundDrawList(viewport), g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32(0, 0, 0, 48));
+ if (g.IO.MouseDrawCursor)
+ RenderMouseCursor(&g.ForegroundDrawList, g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32(0, 0, 0, 48));
- // Add foreground ImDrawList (for each active viewport)
- if (viewport->DrawLists[1] != NULL)
- AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[0], GetForegroundDrawList(viewport));
+ // Add foreground ImDrawList
+ if (!g.ForegroundDrawList.VtxBuffer.empty())
+ AddDrawListToDrawData(&g.DrawDataBuilder.Layers[0], &g.ForegroundDrawList);
- SetupViewportDrawData(viewport, &viewport->DrawDataBuilder.Layers[0]);
- g.IO.MetricsRenderVertices += viewport->DrawData->TotalVtxCount;
- g.IO.MetricsRenderIndices += viewport->DrawData->TotalIdxCount;
- }
+ // Setup ImDrawData structure for end-user
+ SetupDrawData(&g.DrawDataBuilder.Layers[0], &g.DrawData);
+ g.IO.MetricsRenderVertices = g.DrawData.TotalVtxCount;
+ g.IO.MetricsRenderIndices = g.DrawData.TotalIdxCount;
// (Legacy) Call the Render callback function. The current prefer way is to let the user retrieve GetDrawData() and call the render function themselves.
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
- if (g.Viewports[0]->DrawData->CmdListsCount > 0 && g.IO.RenderDrawListsFn != NULL)
- g.IO.RenderDrawListsFn(g.Viewports[0]->DrawData);
+ if (g.DrawData.CmdListsCount > 0 && g.IO.RenderDrawListsFn != NULL)
+ g.IO.RenderDrawListsFn(&g.DrawData);
#endif
}
@@ -4474,13 +4309,7 @@ static void FindHoveredWindow()
{
ImGuiContext& g = *GImGui;
- // Special handling for the window being moved: Ignore the mouse viewport check (because it may reset/lose its viewport during the undocking frame)
- ImGuiViewportP* moving_window_viewport = g.MovingWindow ? g.MovingWindow->Viewport : NULL;
- if (g.MovingWindow)
- g.MovingWindow->Viewport = g.MouseViewport;
-
ImGuiWindow* hovered_window = NULL;
- ImGuiWindow* hovered_window_ignoring_moving_window = NULL;
if (g.MovingWindow && !(g.MovingWindow->Flags & ImGuiWindowFlags_NoMouseInputs))
hovered_window = g.MovingWindow;
@@ -4493,9 +4322,6 @@ static void FindHoveredWindow()
continue;
if (window->Flags & ImGuiWindowFlags_NoMouseInputs)
continue;
- IM_ASSERT(window->Viewport);
- if (window->Viewport != g.MouseViewport)
- continue;
// Using the clipped AABB, a child window will typically be clipped by its parent (not always)
ImRect bb(window->OuterRectClipped);
@@ -4506,29 +4332,16 @@ static void FindHoveredWindow()
if (!bb.Contains(g.IO.MousePos))
continue;
- if (window->HitTestHoleSize.x != 0)
- {
- // FIXME: Consider generalizing hit-testing override (with more generic data, callback, etc.) (#1512)
- ImRect hole_bb((float)(window->HitTestHoleOffset.x), (float)(window->HitTestHoleOffset.y),
- (float)(window->HitTestHoleOffset.x + window->HitTestHoleSize.x), (float)(window->HitTestHoleOffset.y + window->HitTestHoleSize.y));
- if (hole_bb.Contains(g.IO.MousePos - window->Pos))
- continue;
- }
-
+ // Those seemingly unnecessary extra tests are because the code here is a little different in viewport/docking branches.
if (hovered_window == NULL)
hovered_window = window;
- if (hovered_window_ignoring_moving_window == NULL && (!g.MovingWindow || window->RootWindow != g.MovingWindow->RootWindow))
- hovered_window_ignoring_moving_window = window;
- if (hovered_window && hovered_window_ignoring_moving_window)
+ if (hovered_window)
break;
}
g.HoveredWindow = hovered_window;
g.HoveredRootWindow = g.HoveredWindow ? g.HoveredWindow->RootWindow : NULL;
- g.HoveredWindowUnderMovingWindow = hovered_window_ignoring_moving_window;
- if (g.MovingWindow)
- g.MovingWindow->Viewport = moving_window_viewport;
}
// Test if mouse cursor is hovering given rectangle
@@ -4547,8 +4360,6 @@ bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool c
const ImRect rect_for_touch(rect_clipped.Min - g.Style.TouchExtraPadding, rect_clipped.Max + g.Style.TouchExtraPadding);
if (!rect_for_touch.Contains(g.IO.MousePos))
return false;
- if (!g.MouseViewport->GetRect().Overlaps(rect_clipped))
- return false;
return true;
}
@@ -4559,7 +4370,8 @@ int ImGui::GetKeyIndex(ImGuiKey imgui_key)
return g.IO.KeyMap[imgui_key];
}
-// Note that imgui doesn't know the semantic of each entry of io.KeysDown[]. Use your own indices/enums according to how your back-end/engine stored them into io.KeysDown[]!
+// Note that dear imgui doesn't know the semantic of each entry of io.KeysDown[]!
+// Use your own indices/enums according to how your back-end/engine stored them into io.KeysDown[]!
bool ImGui::IsKeyDown(int user_key_index)
{
if (user_key_index < 0)
@@ -4619,23 +4431,14 @@ bool ImGui::IsKeyReleased(int user_key_index)
return g.IO.KeysDownDurationPrev[user_key_index] >= 0.0f && !g.IO.KeysDown[user_key_index];
}
-bool ImGui::IsMouseDown(int button)
+bool ImGui::IsMouseDown(ImGuiMouseButton button)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
return g.IO.MouseDown[button];
}
-bool ImGui::IsAnyMouseDown()
-{
- ImGuiContext& g = *GImGui;
- for (int n = 0; n < IM_ARRAYSIZE(g.IO.MouseDown); n++)
- if (g.IO.MouseDown[n])
- return true;
- return false;
-}
-
-bool ImGui::IsMouseClicked(int button, bool repeat)
+bool ImGui::IsMouseClicked(ImGuiMouseButton button, bool repeat)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
@@ -4650,18 +4453,17 @@ bool ImGui::IsMouseClicked(int button, bool repeat)
if (amount > 0)
return true;
}
-
return false;
}
-bool ImGui::IsMouseReleased(int button)
+bool ImGui::IsMouseReleased(ImGuiMouseButton button)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
return g.IO.MouseReleased[button];
}
-bool ImGui::IsMouseDoubleClicked(int button)
+bool ImGui::IsMouseDoubleClicked(ImGuiMouseButton button)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
@@ -4669,7 +4471,7 @@ bool ImGui::IsMouseDoubleClicked(int button)
}
// [Internal] This doesn't test if the button is pressed
-bool ImGui::IsMouseDragPastThreshold(int button, float lock_threshold)
+bool ImGui::IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
@@ -4678,7 +4480,7 @@ bool ImGui::IsMouseDragPastThreshold(int button, float lock_threshold)
return g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold;
}
-bool ImGui::IsMouseDragging(int button, float lock_threshold)
+bool ImGui::IsMouseDragging(ImGuiMouseButton button, float lock_threshold)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
@@ -4689,7 +4491,8 @@ bool ImGui::IsMouseDragging(int button, float lock_threshold)
ImVec2 ImGui::GetMousePos()
{
- return GImGui->IO.MousePos;
+ ImGuiContext& g = *GImGui;
+ return g.IO.MousePos;
}
// NB: prefer to call right after BeginPopup(). At the time Selectable/MenuItem is activated, the popup is already closed!
@@ -4712,10 +4515,19 @@ bool ImGui::IsMousePosValid(const ImVec2* mouse_pos)
return p.x >= MOUSE_INVALID && p.y >= MOUSE_INVALID;
}
+bool ImGui::IsAnyMouseDown()
+{
+ ImGuiContext& g = *GImGui;
+ for (int n = 0; n < IM_ARRAYSIZE(g.IO.MouseDown); n++)
+ if (g.IO.MouseDown[n])
+ return true;
+ return false;
+}
+
// Return the delta from the initial clicking position while the mouse button is clicked or was just released.
// This is locked and return 0.0f until the mouse moves past a distance threshold at least once.
// NB: This is only valid if IsMousePosValid(). Back-ends in theory should always keep mouse position valid when dragging even outside the client window.
-ImVec2 ImGui::GetMouseDragDelta(int button, float lock_threshold)
+ImVec2 ImGui::GetMouseDragDelta(ImGuiMouseButton button, float lock_threshold)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
@@ -4728,7 +4540,7 @@ ImVec2 ImGui::GetMouseDragDelta(int button, float lock_threshold)
return ImVec2(0.0f, 0.0f);
}
-void ImGui::ResetMouseDragDelta(int button)
+void ImGui::ResetMouseDragDelta(ImGuiMouseButton button)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
@@ -4801,20 +4613,20 @@ bool ImGui::IsItemFocused()
if (g.NavId == 0 || g.NavDisableHighlight || g.NavId != window->DC.LastItemId)
return false;
-
- // Special handling for the dummy item after Begin() which represent the title bar or tab.
- // When the window is collapsed (SkipItems==true) that last item will never be overwritten so we need to detect the case.
- if (window->DC.LastItemId == window->ID && window->WriteAccessed)
- return false;
-
return true;
}
-bool ImGui::IsItemClicked(int mouse_button)
+bool ImGui::IsItemClicked(ImGuiMouseButton mouse_button)
{
return IsMouseClicked(mouse_button) && IsItemHovered(ImGuiHoveredFlags_None);
}
+bool ImGui::IsItemToggledOpen()
+{
+ ImGuiContext& g = *GImGui;
+ return (g.CurrentWindow->DC.LastItemStatusFlags & ImGuiItemStatusFlags_ToggledOpen) ? true : false;
+}
+
bool ImGui::IsItemToggledSelection()
{
ImGuiContext& g = *GImGui;
@@ -4879,12 +4691,18 @@ ImVec2 ImGui::GetItemRectSize()
return window->DC.LastItemRect.GetSize();
}
-static bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags)
+static ImRect GetViewportRect()
+{
+ ImGuiContext& g = *GImGui;
+ return ImRect(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y);
+}
+
+bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* parent_window = g.CurrentWindow;
- flags |= ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_ChildWindow|ImGuiWindowFlags_NoDocking;
+ flags |= ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_ChildWindow;
flags |= (parent_window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag
// Size
@@ -4947,7 +4765,10 @@ void ImGui::EndChild()
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
- IM_ASSERT(window->Flags & ImGuiWindowFlags_ChildWindow); // Mismatched BeginChild()/EndChild() callss
+ IM_ASSERT(g.WithinEndChild == false);
+ IM_ASSERT(window->Flags & ImGuiWindowFlags_ChildWindow); // Mismatched BeginChild()/EndChild() calls
+
+ g.WithinEndChild = true;
if (window->BeginCount > 1)
{
End();
@@ -4979,6 +4800,7 @@ void ImGui::EndChild()
ItemAdd(bb, 0);
}
}
+ g.WithinEndChild = false;
}
// Helper to create a child window / scrolling region that looks like a normal widget frame.
@@ -5001,28 +4823,11 @@ void ImGui::EndChildFrame()
EndChild();
}
-// Save and compare stack sizes on Begin()/End() to detect usage errors
-static void CheckStacksSize(ImGuiWindow* window, bool write)
-{
- // NOT checking: DC.ItemWidth, DC.AllowKeyboardFocus, DC.ButtonRepeat, DC.TextWrapPos (per window) to allow user to conveniently push once and not pop (they are cleared on Begin)
- ImGuiContext& g = *GImGui;
- short* p_backup = &window->DC.StackSizesBackup[0];
- { int current = window->IDStack.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup == current && "PushID/PopID or TreeNode/TreePop Mismatch!"); p_backup++; } // Too few or too many PopID()/TreePop()
- { int current = window->DC.GroupStack.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup == current && "BeginGroup/EndGroup Mismatch!"); p_backup++; } // Too few or too many EndGroup()
- { int current = g.BeginPopupStack.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup == current && "BeginMenu/EndMenu or BeginPopup/EndPopup Mismatch"); p_backup++;}// Too few or too many EndMenu()/EndPopup()
- // For color, style and font stacks there is an incentive to use Push/Begin/Pop/.../End patterns, so we relax our checks a little to allow them.
- { int current = g.ColorModifiers.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup >= current && "PushStyleColor/PopStyleColor Mismatch!"); p_backup++; } // Too few or too many PopStyleColor()
- { int current = g.StyleModifiers.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup >= current && "PushStyleVar/PopStyleVar Mismatch!"); p_backup++; } // Too few or too many PopStyleVar()
- { int current = g.FontStack.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup >= current && "PushFont/PopFont Mismatch!"); p_backup++; } // Too few or too many PopFont()
- IM_ASSERT(p_backup == window->DC.StackSizesBackup + IM_ARRAYSIZE(window->DC.StackSizesBackup));
-}
-
static void SetWindowConditionAllowFlags(ImGuiWindow* window, ImGuiCond flags, bool enabled)
{
window->SetWindowPosAllowFlags = enabled ? (window->SetWindowPosAllowFlags | flags) : (window->SetWindowPosAllowFlags & ~flags);
window->SetWindowSizeAllowFlags = enabled ? (window->SetWindowSizeAllowFlags | flags) : (window->SetWindowSizeAllowFlags & ~flags);
window->SetWindowCollapsedAllowFlags = enabled ? (window->SetWindowCollapsedAllowFlags | flags) : (window->SetWindowCollapsedAllowFlags & ~flags);
- window->SetWindowDockAllowFlags = enabled ? (window->SetWindowDockAllowFlags | flags) : (window->SetWindowDockAllowFlags & ~flags);
}
ImGuiWindow* ImGui::FindWindowByID(ImGuiID id)
@@ -5048,31 +4853,19 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
g.WindowsById.SetVoidPtr(window->ID, window);
// Default/arbitrary window position. Use SetNextWindowPos() with the appropriate condition flag to change the initial position of a window.
- ImGuiViewport* main_viewport = ImGui::GetMainViewport();
- window->Pos = main_viewport->Pos + ImVec2(60, 60);
+ window->Pos = ImVec2(60, 60);
// User can disable loading and saving of settings. Tooltip and child windows also don't store settings.
if (!(flags & ImGuiWindowFlags_NoSavedSettings))
if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID))
{
// Retrieve settings from .ini file
- window->SettingsIdx = g.SettingsWindows.index_from_ptr(settings);
+ window->SettingsOffset = g.SettingsWindows.offset_from_ptr(settings);
SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false);
- if (settings->ViewportId)
- {
- window->ViewportId = settings->ViewportId;
- window->ViewportPos = ImVec2(settings->ViewportPos.x, settings->ViewportPos.y);
- }
- else
- {
- window->ViewportPos = main_viewport->Pos;
- }
- window->Pos = ImVec2(settings->Pos.x + window->ViewportPos.x, settings->Pos.y + window->ViewportPos.y);
+ window->Pos = ImVec2(settings->Pos.x, settings->Pos.y);
window->Collapsed = settings->Collapsed;
if (settings->Size.x > 0 && settings->Size.y > 0)
size = ImVec2(settings->Size.x, settings->Size.y);
- window->DockId = settings->DockId;
- window->DockOrder = settings->DockOrder;
}
window->Size = window->SizeFull = ImFloor(size);
window->DC.CursorStartPos = window->DC.CursorMaxPos = window->Pos; // So first call to CalcContentSize() doesn't return crazy values
@@ -5099,16 +4892,6 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
return window;
}
-static ImGuiWindow* GetWindowForTitleDisplay(ImGuiWindow* window)
-{
- return window->DockNodeAsHost ? window->DockNodeAsHost->VisibleWindow : window;
-}
-
-static ImGuiWindow* GetWindowForTitleAndMenuHeight(ImGuiWindow* window)
-{
- return (window->DockNodeAsHost && window->DockNodeAsHost->VisibleWindow) ? window->DockNodeAsHost->VisibleWindow : window;
-}
-
static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, ImVec2 new_size)
{
ImGuiContext& g = *GImGui;
@@ -5128,14 +4911,14 @@ static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, ImVec2 new_size
g.NextWindowData.SizeCallback(&data);
new_size = data.DesiredSize;
}
- new_size.x = ImFloor(new_size.x);
- new_size.y = ImFloor(new_size.y);
+ new_size.x = IM_FLOOR(new_size.x);
+ new_size.y = IM_FLOOR(new_size.y);
}
// Minimum size
if (!(window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysAutoResize)))
{
- ImGuiWindow* window_for_height = GetWindowForTitleAndMenuHeight(window);
+ ImGuiWindow* window_for_height = window;
new_size = ImMax(new_size, g.Style.WindowMinSize);
new_size.y = ImMax(new_size.y, window_for_height->TitleBarHeight() + window_for_height->MenuBarHeight() + ImMax(0.0f, g.Style.WindowRounding - 1.0f)); // Reduce artifacts with very small windows
}
@@ -5176,14 +4959,7 @@ static ImVec2 CalcWindowAutoFitSize(ImGuiWindow* window, const ImVec2& size_cont
ImVec2 size_min = style.WindowMinSize;
if (is_popup || is_menu) // Popups and menus bypass style.WindowMinSize by default, but we give then a non-zero minimum size to facilitate understanding problematic cases (e.g. empty popups)
size_min = ImMin(size_min, ImVec2(4.0f, 4.0f));
-
- ImVec2 avail_size = window->Viewport->Size;
- if (window->ViewportOwned)
- avail_size = ImVec2(FLT_MAX, FLT_MAX);
- const int monitor_idx = window->ViewportAllowPlatformMonitorExtend;
- if (monitor_idx >= 0 && monitor_idx < g.PlatformIO.Monitors.Size)
- avail_size = g.PlatformIO.Monitors[monitor_idx].WorkSize;
- ImVec2 size_auto_fit = ImClamp(size_desired, size_min, ImMax(size_min, avail_size - g.Style.DisplaySafeAreaPadding * 2.0f));
+ ImVec2 size_auto_fit = ImClamp(size_desired, size_min, ImMax(size_min, g.IO.DisplaySize - style.DisplaySafeAreaPadding * 2.0f));
// When the window cannot fit all contents (either because of constraints, either because screen is too small),
// we are growing the size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than ViewportSize-WindowPadding.
@@ -5238,10 +5014,10 @@ struct ImGuiResizeGripDef
static const ImGuiResizeGripDef resize_grip_def[4] =
{
- { ImVec2(1,1), ImVec2(-1,-1), 0, 3 }, // Lower right
- { ImVec2(0,1), ImVec2(+1,-1), 3, 6 }, // Lower left
- { ImVec2(0,0), ImVec2(+1,+1), 6, 9 }, // Upper left
- { ImVec2(1,0), ImVec2(-1,+1), 9,12 }, // Upper right
+ { ImVec2(1,1), ImVec2(-1,-1), 0, 3 }, // Lower-right
+ { ImVec2(0,1), ImVec2(+1,-1), 3, 6 }, // Lower-left
+ { ImVec2(0,0), ImVec2(+1,+1), 6, 9 }, // Upper-left (Unused)
+ { ImVec2(1,0), ImVec2(-1,+1), 9,12 }, // Upper-right (Unused)
};
static ImRect GetResizeBorderRect(ImGuiWindow* window, int border_n, float perp_padding, float thickness)
@@ -5256,9 +5032,20 @@ static ImRect GetResizeBorderRect(ImGuiWindow* window, int border_n, float perp_
return ImRect();
}
+// 0..3: corners (Lower-right, Lower-left, Unused, Unused)
+// 4..7: borders (Top, Right, Bottom, Left)
+ImGuiID ImGui::GetWindowResizeID(ImGuiWindow* window, int n)
+{
+ IM_ASSERT(n >= 0 && n <= 7);
+ ImGuiID id = window->ID;
+ id = ImHashStr("#RESIZE", 0, id);
+ id = ImHashData(&n, sizeof(int), id);
+ return id;
+}
+
// Handle resize for: Resize Grips, Borders, Gamepad
// Return true when using auto-fit (double click on resize grip)
-static bool ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4])
+static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4])
{
ImGuiContext& g = *GImGui;
ImGuiWindowFlags flags = window->Flags;
@@ -5277,15 +5064,6 @@ static bool ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
ImVec2 pos_target(FLT_MAX, FLT_MAX);
ImVec2 size_target(FLT_MAX, FLT_MAX);
- // Clip mouse interaction rectangles within the viewport (in practice the narrowing is going to happen most of the time).
- // - Not narrowing would mostly benefit the situation where OS windows _without_ decoration have a threshold for hovering when outside their limits.
- // This is however not the case with current back-ends under Win32, but a custom borderless window implementation would benefit from it.
- // - When decoration are enabled we typically benefit from that distance, but then our resize elements would be conflicting with OS resize elements, so we also narrow.
- // - Note that we are unable to tell if the platform setup allows hovering with a distance threshold (on Win32, decorated window have such threshold).
- ImRect clip_viewport_rect(-FLT_MAX, -FLT_MAX, +FLT_MAX, +FLT_MAX);
- if (!(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport) || (g.IO.MouseHoveredViewport != window->ViewportId) || !(window->Viewport->Flags & ImGuiViewportFlags_NoDecoration))
- clip_viewport_rect = window->Viewport->GetRect();
-
// Resize grips and borders are on layer 1
window->DC.NavLayerCurrent = ImGuiNavLayer_Menu;
window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Menu);
@@ -5301,9 +5079,8 @@ static bool ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
ImRect resize_rect(corner - grip.InnerDir * grip_hover_outer_size, corner + grip.InnerDir * grip_hover_inner_size);
if (resize_rect.Min.x > resize_rect.Max.x) ImSwap(resize_rect.Min.x, resize_rect.Max.x);
if (resize_rect.Min.y > resize_rect.Max.y) ImSwap(resize_rect.Min.y, resize_rect.Max.y);
- resize_rect.ClipWith(clip_viewport_rect);
bool hovered, held;
- ButtonBehavior(resize_rect, window->GetID((void*)(intptr_t)resize_grip_n), &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus);
+ ButtonBehavior(resize_rect, window->GetID(resize_grip_n), &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus);
//GetForegroundDrawList(window)->AddRect(resize_rect.Min, resize_rect.Max, IM_COL32(255, 255, 0, 255));
if (hovered || held)
g.MouseCursor = (resize_grip_n & 1) ? ImGuiMouseCursor_ResizeNESW : ImGuiMouseCursor_ResizeNWSE;
@@ -5329,9 +5106,8 @@ static bool ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
{
bool hovered, held;
ImRect border_rect = GetResizeBorderRect(window, border_n, grip_hover_inner_size, WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS);
- border_rect.ClipWith(clip_viewport_rect);
- ButtonBehavior(border_rect, window->GetID((void*)(intptr_t)(border_n + 4)), &hovered, &held, ImGuiButtonFlags_FlattenChildren);
- //GetForegroundDrawList(window)->AddRect(border_rect.Min, border_rect.Max, IM_COL32(255, 255, 0, 255));
+ ButtonBehavior(border_rect, window->GetID(border_n + 4), &hovered, &held, ImGuiButtonFlags_FlattenChildren);
+ //GetForegroundDrawLists(window)->AddRect(border_rect.Min, border_rect.Max, IM_COL32(255, 255, 0, 255));
if ((hovered && g.HoveredIdTimer > WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER) || held)
{
g.MouseCursor = (border_n & 1) ? ImGuiMouseCursor_ResizeEW : ImGuiMouseCursor_ResizeNS;
@@ -5351,7 +5127,7 @@ static bool ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
}
PopID();
- // Resize nav layer
+ // Restore nav layer
window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
@@ -5428,7 +5204,7 @@ static void ImGui::RenderWindowOuterBorders(ImGuiWindow* window)
window->DrawList->PathArcTo(ImLerp(border_r.Min, border_r.Max, def.CornerPosN2) + ImVec2(0.5f, 0.5f) + def.InnerDir * rounding, rounding, def.OuterAngle, def.OuterAngle + IM_PI*0.25f);
window->DrawList->PathStroke(GetColorU32(ImGuiCol_SeparatorActive), false, ImMax(2.0f, border_size)); // Thicker than usual
}
- if (g.Style.FrameBorderSize > 0 && !(window->Flags & ImGuiWindowFlags_NoTitleBar) && !window->DockIsActive)
+ if (g.Style.FrameBorderSize > 0 && !(window->Flags & ImGuiWindowFlags_NoTitleBar))
{
float y = window->Pos.y + window->TitleBarHeight() - 1;
window->DrawList->AddLine(ImVec2(window->Pos.x + border_size, y), ImVec2(window->Pos.x + window->Size.x - border_size, y), GetColorU32(ImGuiCol_Border), g.Style.FrameBorderSize);
@@ -5437,12 +5213,15 @@ static void ImGui::RenderWindowOuterBorders(ImGuiWindow* window)
// Draw background and borders
// Draw and handle scrollbars
-void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, bool handle_borders_and_resize_grips, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size)
+void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size)
{
ImGuiContext& g = *GImGui;
ImGuiStyle& style = g.Style;
ImGuiWindowFlags flags = window->Flags;
+ // Ensure that ScrollBar doesn't read last frame's SkipItems
+ window->SkipItems = false;
+
// Draw window + handle manual resize
// As we highlight the title bar when want_focus is set, multiple reappearing windows will have have their title bar highlighted on their reappearing frame.
const float window_rounding = window->WindowRounding;
@@ -5461,37 +5240,21 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
// Window background
if (!(flags & ImGuiWindowFlags_NoBackground))
{
- bool is_docking_transparent_payload = false;
- if (g.DragDropActive && (g.FrameCount - g.DragDropAcceptFrameCount) <= 1 && g.IO.ConfigDockingTransparentPayload)
- if (g.DragDropPayload.IsDataType(IMGUI_PAYLOAD_TYPE_WINDOW) && *(ImGuiWindow**)g.DragDropPayload.Data == window)
- is_docking_transparent_payload = true;
-
ImU32 bg_col = GetColorU32(GetWindowBgColorIdxFromFlags(flags));
- if (window->ViewportOwned)
- {
- // No alpha
- bg_col = (bg_col | IM_COL32_A_MASK);
- if (is_docking_transparent_payload)
- window->Viewport->Alpha *= DOCKING_TRANSPARENT_PAYLOAD_ALPHA;
- }
- else
+ bool override_alpha = false;
+ float alpha = 1.0f;
+ if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasBgAlpha)
{
- // Adjust alpha. For docking
- float alpha = 1.0f;
- if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasBgAlpha)
- alpha = g.NextWindowData.BgAlphaVal;
- if (is_docking_transparent_payload)
- alpha *= DOCKING_TRANSPARENT_PAYLOAD_ALPHA;
- if (alpha != 1.0f)
- bg_col = (bg_col & ~IM_COL32_A_MASK) | (IM_F32_TO_INT8_SAT(alpha) << IM_COL32_A_SHIFT);
+ alpha = g.NextWindowData.BgAlphaVal;
+ override_alpha = true;
}
+ if (override_alpha)
+ bg_col = (bg_col & ~IM_COL32_A_MASK) | (IM_F32_TO_INT8_SAT(alpha) << IM_COL32_A_SHIFT);
window->DrawList->AddRectFilled(window->Pos + ImVec2(0, window->TitleBarHeight()), window->Pos + window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Bot);
}
// Title bar
- // (when docked, DockNode are drawing their own title bar. Individual windows however do NOT set the _NoTitleBar flag,
- // in order for their pos/size to be matching their undocking state.)
- if (!(flags & ImGuiWindowFlags_NoTitleBar) && !window->DockIsActive)
+ if (!(flags & ImGuiWindowFlags_NoTitleBar))
{
ImU32 title_bar_col = GetColorU32(title_bar_is_highlight ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg);
window->DrawList->AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, window_rounding, ImDrawCornerFlags_Top);
@@ -5507,21 +5270,6 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
window->DrawList->AddLine(menu_bar_rect.GetBL(), menu_bar_rect.GetBR(), GetColorU32(ImGuiCol_Border), style.FrameBorderSize);
}
- // Docking: Unhide tab bar (small triangle in the corner)
- if (window->DockNode && window->DockNode->IsHiddenTabBar() && !window->DockNode->IsNoTabBar())
- {
- float unhide_sz_draw = ImFloor(g.FontSize * 0.70f);
- float unhide_sz_hit = ImFloor(g.FontSize * 0.55f);
- ImVec2 p = window->DockNode->Pos;
- ImRect r(p, p + ImVec2(unhide_sz_hit, unhide_sz_hit));
- bool hovered, held;
- if (ButtonBehavior(r, window->GetID("#UNHIDE"), &hovered, &held, ImGuiButtonFlags_FlattenChildren))
- window->DockNode->WantHiddenTabBarToggle = true;
- // FIXME-DOCK: Ideally we'd use ImGuiCol_TitleBgActive/ImGuiCol_TitleBg here, but neither is guaranteed to be visible enough at this sort of size..
- ImU32 col = GetColorU32(((held && hovered) || (window->DockNode->IsFocused && !hovered)) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
- window->DrawList->AddTriangleFilled(p, p + ImVec2(unhide_sz_draw, 0.0f), p + ImVec2(0.0f, unhide_sz_draw), col);
- }
-
// Scrollbars
if (window->ScrollbarX)
Scrollbar(ImGuiAxis_X);
@@ -5529,7 +5277,7 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
Scrollbar(ImGuiAxis_Y);
// Render resize grips (after their input handling so we don't have a frame of latency)
- if (handle_borders_and_resize_grips && !(flags & ImGuiWindowFlags_NoResize))
+ if (!(flags & ImGuiWindowFlags_NoResize))
{
for (int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++)
{
@@ -5542,14 +5290,12 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
}
}
- // Borders (for dock node host they will be rendered over after the tab bar)
- if (handle_borders_and_resize_grips && !window->DockNodeAsHost)
- RenderWindowOuterBorders(window);
+ // Borders
+ RenderWindowOuterBorders(window);
}
}
// Render title text, collapse button, close button
-// When inside a dock node, this is handled in DockNodeUpdateTabBar() instead.
void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open)
{
ImGuiContext& g = *GImGui;
@@ -5590,7 +5336,7 @@ void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& titl
// Collapse button (submitting first so it gets priority when choosing a navigation init fallback)
if (has_collapse_button)
- if (CollapseButton(window->GetID("#COLLAPSE"), collapse_button_pos, NULL))
+ if (CollapseButton(window->GetID("#COLLAPSE"), collapse_button_pos))
window->WantCollapseToggle = true; // Defer actual collapsing to next frame as we are too far in the Begin() function
// Close button
@@ -5637,13 +5383,9 @@ void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& titl
void ImGui::UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window)
{
window->ParentWindow = parent_window;
- window->RootWindow = window->RootWindowDockStop = window->RootWindowForTitleBarHighlight = window->RootWindowForNav = window;
+ window->RootWindow = window->RootWindowForTitleBarHighlight = window->RootWindowForNav = window;
if (parent_window && (flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Tooltip))
- {
window->RootWindow = parent_window->RootWindow;
- if (!window->DockIsActive && !(parent_window->Flags & ImGuiWindowFlags_DockNodeHost))
- window->RootWindowDockStop = parent_window->RootWindowDockStop;
- }
if (parent_window && !(flags & ImGuiWindowFlags_Modal) && (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)))
window->RootWindowForTitleBarHighlight = parent_window->RootWindowForTitleBarHighlight;
while (window->RootWindowForNav->Flags & ImGuiWindowFlags_NavFlattened)
@@ -5665,7 +5407,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
IM_ASSERT(name != NULL && name[0] != '\0'); // Window name required
- IM_ASSERT(g.FrameScopeActive); // Forgot to call ImGui::NewFrame()
+ IM_ASSERT(g.WithinFrameScope); // Forgot to call ImGui::NewFrame()
IM_ASSERT(g.FrameCountEnded != g.FrameCount); // Called ImGui::Render() or ImGui::EndFrame() and haven't called ImGui::NewFrame() again yet
// Find or create
@@ -5686,7 +5428,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
const int current_frame = g.FrameCount;
const bool first_begin_of_the_frame = (window->LastFrameActive != current_frame);
- window->IsFallbackWindow = (g.CurrentWindowStack.Size == 0 && g.FrameScopePushedFallbackWindow);
+ window->IsFallbackWindow = (g.CurrentWindowStack.Size == 0 && g.WithinFrameScopeWithImplicitWindow);
// Update the Appearing flag
bool window_just_activated_by_user = (window->LastFrameActive < current_frame - 1); // Not using !WasActive because the implicit "Debug" window would always toggle off->on
@@ -5704,7 +5446,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// Update Flags, LastFrameActive, BeginOrderXXX fields
if (first_begin_of_the_frame)
{
- window->FlagsPreviousFrame = window->Flags;
window->Flags = (ImGuiWindowFlags)flags;
window->LastFrameActive = current_frame;
window->LastTimeActive = (float)g.Time;
@@ -5716,27 +5457,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
flags = window->Flags;
}
- // Docking
- // (NB: during the frame dock nodes are created, it is possible that (window->DockIsActive == false) even though (window->DockNode->Windows.Size > 1)
- IM_ASSERT(window->DockNode == NULL || window->DockNodeAsHost == NULL); // Cannot be both
- if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasDock)
- SetWindowDock(window, g.NextWindowData.DockId, g.NextWindowData.DockCond);
- if (first_begin_of_the_frame)
- {
- bool has_dock_node = (window->DockId != 0 || window->DockNode != NULL);
- bool new_auto_dock_node = !has_dock_node && GetWindowAlwaysWantOwnTabBar(window);
- if (has_dock_node || new_auto_dock_node)
- {
- BeginDocked(window, p_open);
- flags = window->Flags;
-
- // Docking currently override constraints
- g.NextWindowData.Flags &= ~ImGuiNextWindowDataFlags_HasSizeConstraint;
- }
- }
-
// Parent window is latched only on the first call to Begin() of the frame, so further append-calls can be done from a different window stack
- ImGuiWindow* parent_window_in_stack = window->DockIsActive ? window->DockNode->HostWindow : g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back();
+ ImGuiWindow* parent_window_in_stack = g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back();
ImGuiWindow* parent_window = first_begin_of_the_frame ? ((flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)) ? parent_window_in_stack : NULL) : window->ParentWindow;
IM_ASSERT(parent_window != NULL || !(flags & ImGuiWindowFlags_ChildWindow));
@@ -5748,7 +5470,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// We intentionally set g.CurrentWindow to NULL to prevent usage until when the viewport is set, then will call SetCurrentWindow()
g.CurrentWindowStack.push_back(window);
g.CurrentWindow = NULL;
- CheckStacksSize(window, true);
+ ErrorCheckBeginEndCompareStacksSize(window, true);
if (flags & ImGuiWindowFlags_Popup)
{
ImGuiPopupData& popup_ref = g.OpenPopupStack[g.BeginPopupStack.Size];
@@ -5760,6 +5482,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
if (window_just_appearing_after_hidden_for_resize && !(flags & ImGuiWindowFlags_ChildWindow))
window->NavLastIds[0] = 0;
+ // Update ->RootWindow and others pointers (before any possible call to FocusWindow)
+ if (first_begin_of_the_frame)
+ UpdateWindowParentAndRootLinks(window, flags, parent_window);
+
// Process SetNextWindow***() calls
bool window_pos_set_by_api = false;
bool window_size_x_set_by_api = false, window_size_y_set_by_api = false;
@@ -5789,8 +5515,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window->ContentSizeExplicit = g.NextWindowData.ContentSizeVal;
else if (first_begin_of_the_frame)
window->ContentSizeExplicit = ImVec2(0.0f, 0.0f);
- if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasWindowClass)
- window->WindowClass = g.NextWindowData.WindowClass;
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasCollapsed)
SetWindowCollapsed(window, g.NextWindowData.CollapsedVal, g.NextWindowData.CollapsedCond);
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasFocus)
@@ -5803,8 +5527,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
{
// Initialize
const bool window_is_child_tooltip = (flags & ImGuiWindowFlags_ChildWindow) && (flags & ImGuiWindowFlags_Tooltip); // FIXME-WIP: Undocumented behavior of Child+Tooltip for pinned tooltip (#1345)
- UpdateWindowParentAndRootLinks(window, flags, parent_window);
-
window->Active = true;
window->HasCloseButton = (p_open != NULL);
window->ClipRect = ImVec4(-FLT_MAX,-FLT_MAX,+FLT_MAX,+FLT_MAX);
@@ -5817,9 +5539,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// Update stored window name when it changes (which can _only_ happen with the "###" operator, so the ID would stay unchanged).
// The title bar always display the 'name' parameter, so we only update the string storage if it needs to be visible to the end-user elsewhere.
bool window_title_visible_elsewhere = false;
- if ((window->Viewport && window->Viewport->Window == window) || (window->DockIsActive))
- window_title_visible_elsewhere = true;
- else if (g.NavWindowingList != NULL && (window->Flags & ImGuiWindowFlags_NoNavFocus) == 0) // Window titles visible when using CTRL+TAB
+ if (g.NavWindowingList != NULL && (window->Flags & ImGuiWindowFlags_NoNavFocus) == 0) // Window titles visible when using CTRL+TAB
window_title_visible_elsewhere = true;
if (window_title_visible_elsewhere && !window_just_created && strcmp(name, window->Name) != 0)
{
@@ -5857,31 +5577,22 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
}
// SELECT VIEWPORT
- // We need to do this before using any style/font sizes, as viewport with a different DPI may affect font sizes.
-
- UpdateSelectWindowViewport(window);
- SetCurrentViewport(window, window->Viewport);
- window->FontDpiScale = (g.IO.ConfigFlags & ImGuiConfigFlags_DpiEnableScaleFonts) ? window->Viewport->DpiScale : 1.0f;
+ // FIXME-VIEWPORT: In the docking/viewport branch, this is the point where we select the current viewport (which may affect the style)
SetCurrentWindow(window);
- flags = window->Flags;
// LOCK BORDER SIZE AND PADDING FOR THE FRAME (so that altering them doesn't cause inconsistencies)
- // We read Style data after the call to UpdateSelectWindowViewport() which might be swapping the style.
if (flags & ImGuiWindowFlags_ChildWindow)
window->WindowBorderSize = style.ChildBorderSize;
else
window->WindowBorderSize = ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupBorderSize : style.WindowBorderSize;
- if (!window->DockIsActive && (flags & ImGuiWindowFlags_ChildWindow) && !(flags & (ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_Popup)) && window->WindowBorderSize == 0.0f)
+ window->WindowPadding = style.WindowPadding;
+ if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & (ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_Popup)) && window->WindowBorderSize == 0.0f)
window->WindowPadding = ImVec2(0.0f, (flags & ImGuiWindowFlags_MenuBar) ? style.WindowPadding.y : 0.0f);
- else
- window->WindowPadding = style.WindowPadding;
- window->DC.MenuBarOffset.x = ImMax(ImMax(window->WindowPadding.x, style.ItemSpacing.x), g.NextWindowData.MenuBarOffsetMinVal.x);
- window->DC.MenuBarOffset.y = g.NextWindowData.MenuBarOffsetMinVal.y;
// Collapse window by double-clicking on title bar
// At this point we don't have a clipping rectangle setup yet, so we can use the title bar area for hit detection and drawing
- if (!(flags & ImGuiWindowFlags_NoTitleBar) && !(flags & ImGuiWindowFlags_NoCollapse) && !window->DockIsActive)
+ if (!(flags & ImGuiWindowFlags_NoTitleBar) && !(flags & ImGuiWindowFlags_NoCollapse))
{
// We don't use a regular button+id to test for double-click on title bar (mostly due to legacy reason, could be fixed), so verify that we don't have items over the title bar.
ImRect title_bar_rect = window->TitleBarRect();
@@ -5975,116 +5686,21 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip)
window->Pos = FindBestWindowPosForPopup(window);
- // Late create viewport if we don't fit within our current host viewport.
- if (window->ViewportAllowPlatformMonitorExtend >= 0 && !window->ViewportOwned && !(window->Viewport->Flags & ImGuiViewportFlags_Minimized))
- if (!window->Viewport->GetRect().Contains(window->Rect()))
- {
- // This is based on the assumption that the DPI will be known ahead (same as the DPI of the selection done in UpdateSelectWindowViewport)
- //ImGuiViewport* old_viewport = window->Viewport;
- window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_NoFocusOnAppearing);
-
- // FIXME-DPI
- //IM_ASSERT(old_viewport->DpiScale == window->Viewport->DpiScale); // FIXME-DPI: Something went wrong
- SetCurrentViewport(window, window->Viewport);
- window->FontDpiScale = (g.IO.ConfigFlags & ImGuiConfigFlags_DpiEnableScaleFonts) ? window->Viewport->DpiScale : 1.0f;
- SetCurrentWindow(window);
- }
-
- bool viewport_rect_changed = false;
- if (window->ViewportOwned)
- {
- // Synchronize window --> viewport in most situations
- // Synchronize viewport -> window in case the platform window has been moved or resized from the OS/WM
- if (window->Viewport->PlatformRequestMove)
- {
- window->Pos = window->Viewport->Pos;
- MarkIniSettingsDirty(window);
- }
- else if (memcmp(&window->Viewport->Pos, &window->Pos, sizeof(window->Pos)) != 0)
- {
- viewport_rect_changed = true;
- window->Viewport->Pos = window->Pos;
- }
-
- if (window->Viewport->PlatformRequestResize)
- {
- window->Size = window->SizeFull = window->Viewport->Size;
- MarkIniSettingsDirty(window);
- }
- else if (memcmp(&window->Viewport->Size, &window->Size, sizeof(window->Size)) != 0)
- {
- viewport_rect_changed = true;
- window->Viewport->Size = window->Size;
- }
-
- // The viewport may have changed monitor since the global update in UpdateViewportsNewFrame()
- // Either a SetNextWindowPos() call in the current frame or a SetWindowPos() call in the previous frame may have this effect.
- if (viewport_rect_changed)
- UpdateViewportPlatformMonitor(window->Viewport);
-
- // Update common viewport flags
- ImGuiViewportFlags viewport_flags = (window->Viewport->Flags) & ~(ImGuiViewportFlags_TopMost | ImGuiViewportFlags_NoTaskBarIcon | ImGuiViewportFlags_NoDecoration);
- const bool is_short_lived_floating_window = (flags & (ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup)) != 0;
- if (flags & ImGuiWindowFlags_Tooltip)
- viewport_flags |= ImGuiViewportFlags_TopMost;
- if (g.IO.ConfigViewportsNoTaskBarIcon || is_short_lived_floating_window)
- viewport_flags |= ImGuiViewportFlags_NoTaskBarIcon;
- if (g.IO.ConfigViewportsNoDecoration || is_short_lived_floating_window)
- viewport_flags |= ImGuiViewportFlags_NoDecoration;
-
- // For popups and menus that may be protruding out of their parent viewport, we enable _NoFocusOnClick so that clicking on them
- // won't steal the OS focus away from their parent window (which may be reflected in OS the title bar decoration).
- // Setting _NoFocusOnClick would technically prevent us from bringing back to front in case they are being covered by an OS window from a different app,
- // but it shouldn't be much of a problem considering those are already popups that are closed when clicking elsewhere.
- if (is_short_lived_floating_window && (flags & ImGuiWindowFlags_Modal) == 0)
- viewport_flags |= ImGuiViewportFlags_NoFocusOnAppearing | ImGuiViewportFlags_NoFocusOnClick;
-
- // We can overwrite viewport flags using ImGuiWindowClass (advanced users)
- // We don't default to the main viewport because.
- if (window->WindowClass.ParentViewportId)
- window->Viewport->ParentViewportId = window->WindowClass.ParentViewportId;
- else if ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) && parent_window_in_stack)
- window->Viewport->ParentViewportId = parent_window_in_stack->Viewport->ID;
- else
- window->Viewport->ParentViewportId = g.IO.ConfigViewportsNoDefaultParent ? 0 : IMGUI_VIEWPORT_DEFAULT_ID;
- if (window->WindowClass.ViewportFlagsOverrideSet)
- viewport_flags |= window->WindowClass.ViewportFlagsOverrideSet;
- if (window->WindowClass.ViewportFlagsOverrideClear)
- viewport_flags &= ~window->WindowClass.ViewportFlagsOverrideClear;
-
- // We also tell the back-end that clearing the platform window won't be necessary, as our window is filling the viewport and we have disabled BgAlpha
- viewport_flags |= ImGuiViewportFlags_NoRendererClear;
- window->Viewport->Flags = viewport_flags;
- }
-
// Clamp position/size so window stays visible within its viewport or monitor
// Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing.
- ImRect viewport_rect = window->Viewport->GetRect();
+ ImRect viewport_rect(GetViewportRect());
if (!window_pos_set_by_api && !(flags & ImGuiWindowFlags_ChildWindow) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0)
{
ImVec2 clamp_padding = ImMax(style.DisplayWindowPadding, style.DisplaySafeAreaPadding);
- if (!window->ViewportOwned && viewport_rect.GetWidth() > 0 && viewport_rect.GetHeight() > 0.0f)
- ClampWindowRect(window, viewport_rect, clamp_padding);
- else if (window->ViewportOwned && g.PlatformIO.Monitors.Size > 0)
+ if (viewport_rect.GetWidth() > 0 && viewport_rect.GetHeight() > 0.0f)
{
- if (window->Viewport->PlatformMonitor == -1)
- {
- // Fallback for "lost" window (e.g. a monitor disconnected): we move the window back over the main viewport
- SetWindowPos(window, g.Viewports[0]->Pos + style.DisplayWindowPadding, ImGuiCond_Always);
- }
- else
- {
- ImGuiPlatformMonitor& monitor = g.PlatformIO.Monitors[window->Viewport->PlatformMonitor];
- ClampWindowRect(window, ImRect(monitor.WorkPos, monitor.WorkPos + monitor.WorkSize), clamp_padding);
- }
+ ClampWindowRect(window, viewport_rect, clamp_padding);
}
}
window->Pos = ImFloor(window->Pos);
// Lock window rounding for the frame (so that altering them doesn't cause inconsistencies)
window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding : style.WindowRounding;
- if (window->ViewportOwned)
- window->WindowRounding = 0.0f;
// Apply window focus (new and reactivated windows are moved to front)
bool want_focus = false;
@@ -6092,36 +5708,20 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
{
if (flags & ImGuiWindowFlags_Popup)
want_focus = true;
- else if ((window->DockIsActive || (flags & ImGuiWindowFlags_ChildWindow) == 0) && !(flags & ImGuiWindowFlags_Tooltip))
+ else if ((flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Tooltip)) == 0)
want_focus = true;
}
- // Decide if we are going to handle borders and resize grips
- const bool handle_borders_and_resize_grips = (window->DockNodeAsHost || !window->DockIsActive);
-
// Handle manual resize: Resize Grips, Borders, Gamepad
int border_held = -1;
ImU32 resize_grip_col[4] = {};
- const int resize_grip_count = g.IO.ConfigWindowsResizeFromEdges ? 2 : 1; // 4
+ const int resize_grip_count = g.IO.ConfigWindowsResizeFromEdges ? 2 : 1; // Allow resize from lower-left if we have the mouse cursor feedback for it.
const float resize_grip_draw_size = IM_FLOOR(ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f));
- if (handle_borders_and_resize_grips && !window->Collapsed)
- if (UpdateManualResize(window, size_auto_fit, &border_held, resize_grip_count, &resize_grip_col[0]))
+ if (!window->Collapsed)
+ if (UpdateWindowManualResize(window, size_auto_fit, &border_held, resize_grip_count, &resize_grip_col[0]))
use_current_size_for_scrollbar_x = use_current_size_for_scrollbar_y = true;
window->ResizeBorderHeld = (signed char)border_held;
- // Synchronize window --> viewport again and one last time (clamping and manual resize may have affected either)
- if (window->ViewportOwned)
- {
- if (!window->Viewport->PlatformRequestMove)
- window->Viewport->Pos = window->Pos;
- if (!window->Viewport->PlatformRequestResize)
- window->Viewport->Size = window->Size;
- viewport_rect = window->Viewport->GetRect();
- }
-
- // Save last known viewport position within the window itself (so it can be saved in .ini file and restored)
- window->ViewportPos = window->Viewport->Pos;
-
// SCROLLBAR VISIBILITY
// Update scrollbar visibility (based on the Size that was effective during last frame or the auto-resized Size).
@@ -6155,8 +5755,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
const ImRect outer_rect = window->Rect();
const ImRect title_bar_rect = window->TitleBarRect();
window->OuterRectClipped = outer_rect;
- if (window->DockIsActive)
- window->OuterRectClipped.Min.y += window->TitleBarHeight();
window->OuterRectClipped.ClipWith(host_rect);
// Inner rectangle
@@ -6209,9 +5807,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window->DrawList->PushTextureID(g.Font->ContainerAtlas->TexID);
PushClipRect(host_rect.Min, host_rect.Max, false);
- // Draw modal or window list full viewport dimming background (for other viewports we'll render them in EndFrame)
+ // Draw modal window background (darkens what is behind them, all viewports)
const bool dim_bg_for_modal = (flags & ImGuiWindowFlags_Modal) && window == GetTopMostPopupModal() && window->HiddenFramesCannotSkipItems <= 0;
- const bool dim_bg_for_window_list = g.NavWindowingTargetAnim && ((window == g.NavWindowingTargetAnim->RootWindow) || (g.NavWindowingList && (window == g.NavWindowingList) && g.NavWindowingList->Viewport != g.NavWindowingTargetAnim->Viewport));
+ const bool dim_bg_for_window_list = g.NavWindowingTargetAnim && (window == g.NavWindowingTargetAnim->RootWindow);
if (dim_bg_for_modal || dim_bg_for_window_list)
{
const ImU32 dim_bg_col = GetColorU32(dim_bg_for_modal ? ImGuiCol_ModalWindowDimBg : ImGuiCol_NavWindowingDimBg, g.DimBgRatio);
@@ -6227,14 +5825,11 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha * 0.25f), g.Style.WindowRounding);
}
- const bool is_undocked_or_docked_visible = !window->DockIsActive || window->DockTabIsVisible;
-
// Since 1.71, child window can render their decoration (bg color, border, scrollbars, etc.) within their parent to save a draw call.
// When using overlapping child windows, this will break the assumption that child z-order is mapped to submission order.
// We disable this when the parent window has zero vertices, which is a common pattern leading to laying out multiple overlapping child.
// We also disabled this when we have dimming overlay behind this specific one child.
// FIXME: More code may rely on explicit sorting of overlapping child window and would need to disable this somehow. Please get in contact if you are affected.
- if (is_undocked_or_docked_visible)
{
bool render_decorations_in_parent = false;
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !window_is_child_tooltip)
@@ -6245,8 +5840,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// Handle title bar, scrollbar, resize grips and resize borders
const ImGuiWindow* window_to_highlight = g.NavWindowingTarget ? g.NavWindowingTarget : g.NavWindow;
- const bool title_bar_is_highlight = want_focus || (window_to_highlight && (window->RootWindowForTitleBarHighlight == window_to_highlight->RootWindowForTitleBarHighlight || (window->DockNode && window->DockNode == window_to_highlight->DockNode)));
- RenderWindowDecorations(window, title_bar_rect, title_bar_is_highlight, handle_borders_and_resize_grips, resize_grip_count, resize_grip_col, resize_grip_draw_size);
+ const bool title_bar_is_highlight = want_focus || (window_to_highlight && window->RootWindowForTitleBarHighlight == window_to_highlight->RootWindowForTitleBarHighlight);
+ RenderWindowDecorations(window, title_bar_rect, title_bar_is_highlight, resize_grip_count, resize_grip_col, resize_grip_draw_size);
if (render_decorations_in_parent)
window->DrawList = &window->DrawListInst;
@@ -6282,14 +5877,14 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window->WorkRect.Max.x = window->WorkRect.Min.x + work_rect_size_x;
window->WorkRect.Max.y = window->WorkRect.Min.y + work_rect_size_y;
- // [LEGACY] Contents Region
- // FIXME-OBSOLETE: window->ContentsRegionRect.Max is currently very misleading / partly faulty, but some BeginChild() patterns relies on it.
+ // [LEGACY] Content Region
+ // FIXME-OBSOLETE: window->ContentRegionRect.Max is currently very misleading / partly faulty, but some BeginChild() patterns relies on it.
// Used by:
// - Mouse wheel scrolling + many other things
- window->ContentsRegionRect.Min.x = window->Pos.x - window->Scroll.x + window->WindowPadding.x;
- window->ContentsRegionRect.Min.y = window->Pos.y - window->Scroll.y + window->WindowPadding.y + decoration_up_height;
- window->ContentsRegionRect.Max.x = window->ContentsRegionRect.Min.x + (window->ContentSizeExplicit.x != 0.0f ? window->ContentSizeExplicit.x : (window->Size.x - window->WindowPadding.x * 2.0f - window->ScrollbarSizes.x));
- window->ContentsRegionRect.Max.y = window->ContentsRegionRect.Min.y + (window->ContentSizeExplicit.y != 0.0f ? window->ContentSizeExplicit.y : (window->Size.y - window->WindowPadding.y * 2.0f - decoration_up_height - window->ScrollbarSizes.y));
+ window->ContentRegionRect.Min.x = window->Pos.x - window->Scroll.x + window->WindowPadding.x;
+ window->ContentRegionRect.Min.y = window->Pos.y - window->Scroll.y + window->WindowPadding.y + decoration_up_height;
+ window->ContentRegionRect.Max.x = window->ContentRegionRect.Min.x + (window->ContentSizeExplicit.x != 0.0f ? window->ContentSizeExplicit.x : (window->Size.x - window->WindowPadding.x * 2.0f - window->ScrollbarSizes.x));
+ window->ContentRegionRect.Max.y = window->ContentRegionRect.Min.y + (window->ContentSizeExplicit.y != 0.0f ? window->ContentSizeExplicit.y : (window->Size.y - window->WindowPadding.y * 2.0f - decoration_up_height - window->ScrollbarSizes.y));
// Setup drawing context
// (NB: That term "drawing context / DC" lost its meaning a long time ago. Initially was meant to hold transient data only. Nowadays difference between window-> and window->DC-> is dubious.)
@@ -6302,33 +5897,37 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window->DC.CursorMaxPos = window->DC.CursorStartPos;
window->DC.CurrLineSize = window->DC.PrevLineSize = ImVec2(0.0f, 0.0f);
window->DC.CurrLineTextBaseOffset = window->DC.PrevLineTextBaseOffset = 0.0f;
- window->DC.NavHideHighlightOneFrame = false;
- window->DC.NavHasScroll = (window->ScrollMax.y > 0.0f);
+
+ window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
+ window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
window->DC.NavLayerActiveMask = window->DC.NavLayerActiveMaskNext;
window->DC.NavLayerActiveMaskNext = 0x00;
+ window->DC.NavFocusScopeIdCurrent = (flags & ImGuiWindowFlags_ChildWindow) ? parent_window->DC.NavFocusScopeIdCurrent : 0; // -V595
+ window->DC.NavHideHighlightOneFrame = false;
+ window->DC.NavHasScroll = (window->ScrollMax.y > 0.0f);
+
window->DC.MenuBarAppending = false;
+ window->DC.MenuBarOffset.x = ImMax(ImMax(window->WindowPadding.x, style.ItemSpacing.x), g.NextWindowData.MenuBarOffsetMinVal.x);
+ window->DC.MenuBarOffset.y = g.NextWindowData.MenuBarOffsetMinVal.y;
+ window->DC.MenuColumns.Update(3, style.ItemSpacing.x, window_just_activated_by_user);
+ window->DC.TreeDepth = 0;
+ window->DC.TreeJumpToParentOnPopMask = 0x00;
window->DC.ChildWindows.resize(0);
+ window->DC.StateStorage = &window->StateStorage;
+ window->DC.CurrentColumns = NULL;
window->DC.LayoutType = ImGuiLayoutType_Vertical;
window->DC.ParentLayoutType = parent_window ? parent_window->DC.LayoutType : ImGuiLayoutType_Vertical;
- window->DC.FocusCounterAll = window->DC.FocusCounterTab = -1;
- window->DC.ItemFlags = parent_window ? parent_window->DC.ItemFlags : ImGuiItemFlags_Default_;
+ window->DC.FocusCounterRegular = window->DC.FocusCounterTabStop = -1;
+
window->DC.ItemWidth = window->ItemWidthDefault;
window->DC.TextWrapPos = -1.0f; // disabled
window->DC.ItemFlagsStack.resize(0);
window->DC.ItemWidthStack.resize(0);
window->DC.TextWrapPosStack.resize(0);
- window->DC.CurrentColumns = NULL;
- window->DC.TreeDepth = 0;
- window->DC.TreeMayJumpToParentOnPopMask = 0x00;
- window->DC.StateStorage = &window->StateStorage;
window->DC.GroupStack.resize(0);
- window->MenuColumns.Update(3, style.ItemSpacing.x, window_just_activated_by_user);
-
- if ((flags & ImGuiWindowFlags_ChildWindow) && (window->DC.ItemFlags != parent_window->DC.ItemFlags))
- {
- window->DC.ItemFlags = parent_window->DC.ItemFlags;
+ window->DC.ItemFlags = parent_window ? parent_window->DC.ItemFlags : ImGuiItemFlags_Default_;
+ if (parent_window)
window->DC.ItemFlagsStack.push_back(window->DC.ItemFlags);
- }
if (window->AutoFitFramesX > 0)
window->AutoFitFramesX--;
@@ -6342,25 +5941,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
NavInitWindow(window, false);
}
- // Close from platform window
- if (p_open != NULL && window->Viewport->PlatformRequestClose && window->Viewport != GetMainViewport())
- {
- if (!window->DockIsActive || window->DockTabIsVisible)
- {
- window->Viewport->PlatformRequestClose = false;
- g.NavWindowingToggleLayer = false; // Assume user mapped PlatformRequestClose on ALT-F4 so we disable ALT for menu toggle. False positive not an issue.
- IMGUI_DEBUG_LOG_VIEWPORT("Window '%s' PlatformRequestClose\n", window->Name);
- *p_open = false;
- }
- }
-
// Title bar
- if (!(flags & ImGuiWindowFlags_NoTitleBar) && !window->DockIsActive)
+ if (!(flags & ImGuiWindowFlags_NoTitleBar))
RenderWindowTitleBarContents(window, title_bar_rect, name, p_open);
- // Clear hit test shape every frame
- window->HitTestHoleSize.x = window->HitTestHoleSize.y = 0;
-
// Pressing CTRL+C while holding on a window copy its content to the clipboard
// This works but 1. doesn't handle multiple Begin/End pairs, 2. recursing into another Begin/End pair - so we need to work that out and add better logging scope.
// Maybe we can support CTRL+C on every element?
@@ -6370,37 +5954,11 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
LogToClipboard();
*/
- if (g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable)
- {
- // Docking: Dragging a dockable window (or any of its child) turns it into a drag and drop source.
- // We need to do this _before_ we overwrite window->DC.LastItemId below because BeginAsDockableDragDropSource() also overwrites it.
- if ((g.ActiveId == window->MoveId) && (g.IO.ConfigDockingWithShift == g.IO.KeyShift))
- if ((window->Flags & ImGuiWindowFlags_NoMove) == 0)
- if ((window->RootWindow->Flags & (ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDocking)) == 0)
- BeginAsDockableDragDropSource(window);
-
- // Docking: Any dockable window can act as a target. For dock node hosts we call BeginAsDockableDragDropTarget() in DockNodeUpdate() instead.
- if (g.DragDropActive && !(flags & ImGuiWindowFlags_NoDocking))
- if (g.MovingWindow == NULL || g.MovingWindow->RootWindow != window)
- if ((window == window->RootWindow) && !(window->Flags & ImGuiWindowFlags_DockNodeHost))
- BeginAsDockableDragDropTarget(window);
- }
-
// We fill last item data based on Title Bar/Tab, in order for IsItemHovered() and IsItemActive() to be usable after Begin().
// This is useful to allow creating context menus on title bar only, etc.
- if (window->DockIsActive)
- {
- window->DC.LastItemId = window->ID;
- window->DC.LastItemStatusFlags = window->DockTabItemStatusFlags;
- window->DC.LastItemRect = window->DockTabItemRect;
- }
- else
- {
- window->DC.LastItemId = window->MoveId;
- window->DC.LastItemStatusFlags = IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false) ? ImGuiItemStatusFlags_HoveredRect : 0;
- window->DC.LastItemRect = title_bar_rect;
- }
-
+ window->DC.LastItemId = window->MoveId;
+ window->DC.LastItemStatusFlags = IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false) ? ImGuiItemStatusFlags_HoveredRect : 0;
+ window->DC.LastItemRect = title_bar_rect;
#ifdef IMGUI_ENABLE_TEST_ENGINE
if (!(window->Flags & ImGuiWindowFlags_NoTitleBar))
IMGUI_TEST_ENGINE_ITEM_ADD(window->DC.LastItemRect, window->DC.LastItemId);
@@ -6409,12 +5967,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
else
{
// Append
- SetCurrentViewport(window, window->Viewport);
SetCurrentWindow(window);
}
- if (!(flags & ImGuiWindowFlags_DockNodeHost))
- PushClipRect(window->InnerClipRect.Min, window->InnerClipRect.Max, true);
+ PushClipRect(window->InnerClipRect.Min, window->InnerClipRect.Max, true);
// Clear 'accessed' flag last thing (After PushClipRect which will set the flag. We want the flag to stay false when the default "Debug" window is unused)
if (first_begin_of_the_frame)
@@ -6423,23 +5979,11 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window->BeginCount++;
g.NextWindowData.ClearFlags();
- // When we are about to select this tab (which will only be visible on the _next frame_), flag it with a non-zero HiddenFramesCannotSkipItems.
- // This will have the important effect of actually returning true in Begin() and not setting SkipItems, allowing an earlier submission of the window contents.
- // This is analogous to regular windows being hidden from one frame.
- // It is especially important as e.g. nested TabBars would otherwise generate flicker in the form of one empty frame, or focus requests won't be processed.
- if (window->DockIsActive && !window->DockTabIsVisible)
- {
- if (window->LastFrameJustFocused == g.FrameCount)
- window->HiddenFramesCannotSkipItems = 1;
- else
- window->HiddenFramesCanSkipItems = 1;
- }
-
if (flags & ImGuiWindowFlags_ChildWindow)
{
// Child window can be out of sight and have "negative" clip windows.
// Mark them as collapsed so commands are skipped earlier (we can't manually collapse them because they have no title bar).
- IM_ASSERT((flags & ImGuiWindowFlags_NoTitleBar) != 0 || (window->DockIsActive));
+ IM_ASSERT((flags & ImGuiWindowFlags_NoTitleBar) != 0);
if (!(flags & ImGuiWindowFlags_AlwaysAutoResize) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0)
if (window->OuterRectClipped.Min.x >= window->OuterRectClipped.Max.x || window->OuterRectClipped.Min.y >= window->OuterRectClipped.Max.y)
window->HiddenFramesCanSkipItems = 1;
@@ -6468,57 +6012,38 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
return !skip_items;
}
-// Old Begin() API with 5 parameters, avoid calling this version directly! Use SetNextWindowSize()/SetNextWindowBgAlpha() + Begin() instead.
-#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
-bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_first_use, float bg_alpha_override, ImGuiWindowFlags flags)
-{
- // Old API feature: we could pass the initial window size as a parameter. This was misleading because it only had an effect if the window didn't have data in the .ini file.
- if (size_first_use.x != 0.0f || size_first_use.y != 0.0f)
- SetNextWindowSize(size_first_use, ImGuiCond_FirstUseEver);
-
- // Old API feature: override the window background alpha with a parameter.
- if (bg_alpha_override >= 0.0f)
- SetNextWindowBgAlpha(bg_alpha_override);
-
- return Begin(name, p_open, flags);
-}
-#endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS
-
void ImGui::End()
{
ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
- if (g.CurrentWindowStack.Size <= 1 && g.FrameScopePushedFallbackWindow)
+ // Error checking: verify that user hasn't called End() too many times!
+ if (g.CurrentWindowStack.Size <= 1 && g.WithinFrameScopeWithImplicitWindow)
{
- IM_ASSERT(g.CurrentWindowStack.Size > 1 && "Calling End() too many times!");
- return; // FIXME-ERRORHANDLING
+ IM_ASSERT_USER_ERROR(g.CurrentWindowStack.Size > 1, "Calling End() too many times!");
+ return;
}
IM_ASSERT(g.CurrentWindowStack.Size > 0);
- ImGuiWindow* window = g.CurrentWindow;
+ // Error checking: verify that user doesn't directly call End() on a child window.
+ if (window->Flags & ImGuiWindowFlags_ChildWindow)
+ IM_ASSERT_USER_ERROR(g.WithinEndChild, "Must call EndChild() and not End()!");
+ // Close anything that is open
if (window->DC.CurrentColumns)
EndColumns();
- if (!(window->Flags & ImGuiWindowFlags_DockNodeHost)) // Pop inner window clip rectangle
- PopClipRect();
+ PopClipRect(); // Inner window clip rectangle
// Stop logging
if (!(window->Flags & ImGuiWindowFlags_ChildWindow)) // FIXME: add more options for scope of logging
LogFinish();
- // Docking: report contents sizes to parent to allow for auto-resize
- if (window->DockNode && window->DockTabIsVisible)
- if (ImGuiWindow* host_window = window->DockNode->HostWindow) // FIXME-DOCK
- host_window->DC.CursorMaxPos = window->DC.CursorMaxPos + window->WindowPadding - host_window->WindowPadding;
-
// Pop from window stack
g.CurrentWindowStack.pop_back();
if (window->Flags & ImGuiWindowFlags_Popup)
g.BeginPopupStack.pop_back();
- CheckStacksSize(window, false);
+ ErrorCheckBeginEndCompareStacksSize(window, false);
SetCurrentWindow(g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back());
- if (g.CurrentWindow)
- SetCurrentViewport(g.CurrentWindow, g.CurrentWindow->Viewport);
}
void ImGui::BringWindowToFocusFront(ImGuiWindow* window)
@@ -6576,6 +6101,7 @@ void ImGui::FocusWindow(ImGuiWindow* window)
g.NavMousePosDirty = true;
g.NavInitRequest = false;
g.NavId = window ? window->NavLastIds[0] : 0; // Restore NavId
+ g.NavFocusScopeId = 0;
g.NavIdIsAlive = false;
g.NavLayer = ImGuiNavLayer_Main;
//IMGUI_DEBUG_LOG("FocusWindow(\"%s\")\n", window ? window->Name : NULL);
@@ -6587,25 +6113,21 @@ void ImGui::FocusWindow(ImGuiWindow* window)
// Passing NULL allow to disable keyboard focus
if (!window)
return;
- window->LastFrameJustFocused = g.FrameCount;
-
- // Select in dock node
- if (window->DockNode && window->DockNode->TabBar)
- window->DockNode->TabBar->SelectedTabId = window->DockNode->TabBar->NextSelectedTabId = window->ID;
// Move the root window to the top of the pile
- if (window->RootWindow)
- window = window->RootWindow;
+ IM_ASSERT(window->RootWindow != NULL);
+ ImGuiWindow* focus_front_window = window->RootWindow; // NB: In docking branch this is window->RootWindowDockStop
+ ImGuiWindow* display_front_window = window->RootWindow;
// Steal focus on active widgets
- if (window->Flags & ImGuiWindowFlags_Popup) // FIXME: This statement should be unnecessary. Need further testing before removing it..
- if (g.ActiveId != 0 && g.ActiveIdWindow && g.ActiveIdWindow->RootWindow != window)
+ if (focus_front_window->Flags & ImGuiWindowFlags_Popup) // FIXME: This statement may be unnecessary? Need further testing before removing it..
+ if (g.ActiveId != 0 && g.ActiveIdWindow && g.ActiveIdWindow->RootWindow != focus_front_window)
ClearActiveID();
// Bring to front
- BringWindowToFocusFront(window);
- if (!(window->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus))
- BringWindowToDisplayFront(window);
+ BringWindowToFocusFront(focus_front_window);
+ if (((window->Flags | display_front_window->Flags) & ImGuiWindowFlags_NoBringToFrontOnFocus) == 0)
+ BringWindowToDisplayFront(display_front_window);
}
void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window)
@@ -6626,10 +6148,6 @@ void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWind
if (window != ignore_window && window->WasActive && !(window->Flags & ImGuiWindowFlags_ChildWindow))
if ((window->Flags & (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs)) != (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs))
{
- // FIXME-DOCKING: This is failing (lagging by one frame) for docked windows.
- // If A and B are docked into window and B disappear, at the NewFrame() call site window->NavLastChildNavWindow will still point to B.
- // We might leverage the tab order implicitly stored in window->DockNodeAsHost->TabBar (essentially the 'most_recently_selected_tab' code in tab bar will do that but on next update)
- // to tell which is the "previous" window. Or we may leverage 'LastFrameFocused/LastFrameJustFocused' and have this function handle child window itself?
ImGuiWindow* focus_window = NavRestoreLastChildNavWindow(window);
FocusWindow(focus_window);
return;
@@ -6638,88 +6156,6 @@ void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWind
FocusWindow(NULL);
}
-void ImGui::SetNextItemWidth(float item_width)
-{
- ImGuiContext& g = *GImGui;
- g.NextItemData.Flags |= ImGuiNextItemDataFlags_HasWidth;
- g.NextItemData.Width = item_width;
-}
-
-void ImGui::PushItemWidth(float item_width)
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
- window->DC.ItemWidth = (item_width == 0.0f ? window->ItemWidthDefault : item_width);
- window->DC.ItemWidthStack.push_back(window->DC.ItemWidth);
- g.NextItemData.Flags &= ~ImGuiNextItemDataFlags_HasWidth;
-}
-
-void ImGui::PushMultiItemsWidths(int components, float w_full)
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
- const ImGuiStyle& style = g.Style;
- const float w_item_one = ImMax(1.0f, IM_FLOOR((w_full - (style.ItemInnerSpacing.x) * (components-1)) / (float)components));
- const float w_item_last = ImMax(1.0f, IM_FLOOR(w_full - (w_item_one + style.ItemInnerSpacing.x) * (components-1)));
- window->DC.ItemWidthStack.push_back(w_item_last);
- for (int i = 0; i < components-1; i++)
- window->DC.ItemWidthStack.push_back(w_item_one);
- window->DC.ItemWidth = window->DC.ItemWidthStack.back();
- g.NextItemData.Flags &= ~ImGuiNextItemDataFlags_HasWidth;
-}
-
-void ImGui::PopItemWidth()
-{
- ImGuiWindow* window = GetCurrentWindow();
- window->DC.ItemWidthStack.pop_back();
- window->DC.ItemWidth = window->DC.ItemWidthStack.empty() ? window->ItemWidthDefault : window->DC.ItemWidthStack.back();
-}
-
-// Calculate default item width given value passed to PushItemWidth() or SetNextItemWidth().
-// The SetNextItemWidth() data is generally cleared/consumed by ItemAdd() or NextItemData.ClearFlags()
-float ImGui::CalcItemWidth()
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
- float w;
- if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasWidth)
- w = g.NextItemData.Width;
- else
- w = window->DC.ItemWidth;
- if (w < 0.0f)
- {
- float region_max_x = GetContentRegionMaxAbs().x;
- w = ImMax(1.0f, region_max_x - window->DC.CursorPos.x + w);
- }
- w = IM_FLOOR(w);
- return w;
-}
-
-// [Internal] Calculate full item size given user provided 'size' parameter and default width/height. Default width is often == CalcItemWidth().
-// 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 CalcItemWidth() 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 = GetContentRegionMaxAbs();
-
- 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)
{
ImGuiContext& g = *GImGui;
@@ -6805,300 +6241,109 @@ void ImGui::PopTextWrapPos()
window->DC.TextWrapPos = window->DC.TextWrapPosStack.empty() ? -1.0f : window->DC.TextWrapPosStack.back();
}
-// FIXME: This may incur a round-trip (if the end user got their data from a float4) but eventually we aim to store the in-flight colors as ImU32
-void ImGui::PushStyleColor(ImGuiCol idx, ImU32 col)
+bool ImGui::IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent)
{
- ImGuiContext& g = *GImGui;
- ImGuiColorMod backup;
- backup.Col = idx;
- backup.BackupValue = g.Style.Colors[idx];
- g.ColorModifiers.push_back(backup);
- g.Style.Colors[idx] = ColorConvertU32ToFloat4(col);
+ if (window->RootWindow == potential_parent)
+ return true;
+ while (window != NULL)
+ {
+ if (window == potential_parent)
+ return true;
+ window = window->ParentWindow;
+ }
+ return false;
}
-void ImGui::PushStyleColor(ImGuiCol idx, const ImVec4& col)
+bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags)
{
+ IM_ASSERT((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0); // Flags not supported by this function
ImGuiContext& g = *GImGui;
- ImGuiColorMod backup;
- backup.Col = idx;
- backup.BackupValue = g.Style.Colors[idx];
- g.ColorModifiers.push_back(backup);
- g.Style.Colors[idx] = col;
+
+ if (flags & ImGuiHoveredFlags_AnyWindow)
+ {
+ if (g.HoveredWindow == NULL)
+ return false;
+ }
+ else
+ {
+ switch (flags & (ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows))
+ {
+ case ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows:
+ if (g.HoveredRootWindow != g.CurrentWindow->RootWindow)
+ return false;
+ break;
+ case ImGuiHoveredFlags_RootWindow:
+ if (g.HoveredWindow != g.CurrentWindow->RootWindow)
+ return false;
+ break;
+ case ImGuiHoveredFlags_ChildWindows:
+ if (g.HoveredWindow == NULL || !IsWindowChildOf(g.HoveredWindow, g.CurrentWindow))
+ return false;
+ break;
+ default:
+ if (g.HoveredWindow != g.CurrentWindow)
+ return false;
+ break;
+ }
+ }
+
+ if (!IsWindowContentHoverable(g.HoveredWindow, flags))
+ return false;
+ if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
+ if (g.ActiveId != 0 && !g.ActiveIdAllowOverlap && g.ActiveId != g.HoveredWindow->MoveId)
+ return false;
+ return true;
}
-void ImGui::PopStyleColor(int count)
+bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags)
{
ImGuiContext& g = *GImGui;
- while (count > 0)
+
+ if (flags & ImGuiFocusedFlags_AnyWindow)
+ return g.NavWindow != NULL;
+
+ IM_ASSERT(g.CurrentWindow); // Not inside a Begin()/End()
+ switch (flags & (ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows))
{
- ImGuiColorMod& backup = g.ColorModifiers.back();
- g.Style.Colors[backup.Col] = backup.BackupValue;
- g.ColorModifiers.pop_back();
- count--;
+ case ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows:
+ return g.NavWindow && g.NavWindow->RootWindow == g.CurrentWindow->RootWindow;
+ case ImGuiFocusedFlags_RootWindow:
+ return g.NavWindow == g.CurrentWindow->RootWindow;
+ case ImGuiFocusedFlags_ChildWindows:
+ return g.NavWindow && IsWindowChildOf(g.NavWindow, g.CurrentWindow);
+ default:
+ return g.NavWindow == g.CurrentWindow;
}
}
-struct ImGuiStyleVarInfo
+// Can we focus this window with CTRL+TAB (or PadMenu + PadFocusPrev/PadFocusNext)
+// Note that NoNavFocus makes the window not reachable with CTRL+TAB but it can still be focused with mouse or programmaticaly.
+// If you want a window to never be focused, you may use the e.g. NoInputs flag.
+bool ImGui::IsWindowNavFocusable(ImGuiWindow* window)
{
- ImGuiDataType Type;
- ImU32 Count;
- ImU32 Offset;
- void* GetVarPtr(ImGuiStyle* style) const { return (void*)((unsigned char*)style + Offset); }
-};
+ return window->Active && window == window->RootWindow && !(window->Flags & ImGuiWindowFlags_NoNavFocus);
+}
-static const ImGuiStyleVarInfo GStyleVarInfo[] =
+float ImGui::GetWindowWidth()
{
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, Alpha) }, // ImGuiStyleVar_Alpha
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowRounding) }, // ImGuiStyleVar_WindowRounding
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowBorderSize) }, // ImGuiStyleVar_WindowBorderSize
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowMinSize) }, // ImGuiStyleVar_WindowMinSize
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowTitleAlign) }, // ImGuiStyleVar_WindowTitleAlign
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildRounding) }, // ImGuiStyleVar_ChildRounding
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildBorderSize) }, // ImGuiStyleVar_ChildBorderSize
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupRounding) }, // ImGuiStyleVar_PopupRounding
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupBorderSize) }, // ImGuiStyleVar_PopupBorderSize
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, FramePadding) }, // ImGuiStyleVar_FramePadding
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameRounding) }, // ImGuiStyleVar_FrameRounding
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameBorderSize) }, // ImGuiStyleVar_FrameBorderSize
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing) }, // ImGuiStyleVar_IndentSpacing
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarSize) }, // ImGuiStyleVar_ScrollbarSize
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarRounding) }, // ImGuiStyleVar_ScrollbarRounding
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SelectableTextAlign) }, // ImGuiStyleVar_SelectableTextAlign
-};
+ ImGuiWindow* window = GImGui->CurrentWindow;
+ return window->Size.x;
+}
-static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx)
+float ImGui::GetWindowHeight()
{
- IM_ASSERT(idx >= 0 && idx < ImGuiStyleVar_COUNT);
- IM_ASSERT(IM_ARRAYSIZE(GStyleVarInfo) == ImGuiStyleVar_COUNT);
- return &GStyleVarInfo[idx];
+ ImGuiWindow* window = GImGui->CurrentWindow;
+ return window->Size.y;
}
-void ImGui::PushStyleVar(ImGuiStyleVar idx, float val)
+ImVec2 ImGui::GetWindowPos()
{
- const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx);
- if (var_info->Type == ImGuiDataType_Float && var_info->Count == 1)
- {
- ImGuiContext& g = *GImGui;
- float* pvar = (float*)var_info->GetVarPtr(&g.Style);
- g.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar));
- *pvar = val;
- return;
- }
- IM_ASSERT(0 && "Called PushStyleVar() float variant but variable is not a float!");
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ return window->Pos;
}
-void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val)
-{
- const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx);
- if (var_info->Type == ImGuiDataType_Float && var_info->Count == 2)
- {
- ImGuiContext& g = *GImGui;
- ImVec2* pvar = (ImVec2*)var_info->GetVarPtr(&g.Style);
- g.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar));
- *pvar = val;
- return;
- }
- IM_ASSERT(0 && "Called PushStyleVar() ImVec2 variant but variable is not a ImVec2!");
-}
-
-void ImGui::PopStyleVar(int count)
-{
- ImGuiContext& g = *GImGui;
- while (count > 0)
- {
- // We avoid a generic memcpy(data, &backup.Backup.., GDataTypeSize[info->Type] * info->Count), the overhead in Debug is not worth it.
- ImGuiStyleMod& backup = g.StyleModifiers.back();
- const ImGuiStyleVarInfo* info = GetStyleVarInfo(backup.VarIdx);
- void* data = info->GetVarPtr(&g.Style);
- if (info->Type == ImGuiDataType_Float && info->Count == 1) { ((float*)data)[0] = backup.BackupFloat[0]; }
- else if (info->Type == ImGuiDataType_Float && info->Count == 2) { ((float*)data)[0] = backup.BackupFloat[0]; ((float*)data)[1] = backup.BackupFloat[1]; }
- g.StyleModifiers.pop_back();
- count--;
- }
-}
-
-const char* ImGui::GetStyleColorName(ImGuiCol idx)
-{
- // Create switch-case from enum with regexp: ImGuiCol_{.*}, --> case ImGuiCol_\1: return "\1";
- switch (idx)
- {
- case ImGuiCol_Text: return "Text";
- case ImGuiCol_TextDisabled: return "TextDisabled";
- case ImGuiCol_WindowBg: return "WindowBg";
- case ImGuiCol_ChildBg: return "ChildBg";
- case ImGuiCol_PopupBg: return "PopupBg";
- case ImGuiCol_Border: return "Border";
- case ImGuiCol_BorderShadow: return "BorderShadow";
- case ImGuiCol_FrameBg: return "FrameBg";
- case ImGuiCol_FrameBgHovered: return "FrameBgHovered";
- case ImGuiCol_FrameBgActive: return "FrameBgActive";
- case ImGuiCol_TitleBg: return "TitleBg";
- case ImGuiCol_TitleBgActive: return "TitleBgActive";
- case ImGuiCol_TitleBgCollapsed: return "TitleBgCollapsed";
- case ImGuiCol_MenuBarBg: return "MenuBarBg";
- case ImGuiCol_ScrollbarBg: return "ScrollbarBg";
- case ImGuiCol_ScrollbarGrab: return "ScrollbarGrab";
- case ImGuiCol_ScrollbarGrabHovered: return "ScrollbarGrabHovered";
- case ImGuiCol_ScrollbarGrabActive: return "ScrollbarGrabActive";
- case ImGuiCol_CheckMark: return "CheckMark";
- case ImGuiCol_SliderGrab: return "SliderGrab";
- case ImGuiCol_SliderGrabActive: return "SliderGrabActive";
- case ImGuiCol_Button: return "Button";
- case ImGuiCol_ButtonHovered: return "ButtonHovered";
- case ImGuiCol_ButtonActive: return "ButtonActive";
- case ImGuiCol_Header: return "Header";
- case ImGuiCol_HeaderHovered: return "HeaderHovered";
- case ImGuiCol_HeaderActive: return "HeaderActive";
- case ImGuiCol_Separator: return "Separator";
- case ImGuiCol_SeparatorHovered: return "SeparatorHovered";
- case ImGuiCol_SeparatorActive: return "SeparatorActive";
- case ImGuiCol_ResizeGrip: return "ResizeGrip";
- case ImGuiCol_ResizeGripHovered: return "ResizeGripHovered";
- case ImGuiCol_ResizeGripActive: return "ResizeGripActive";
- case ImGuiCol_Tab: return "Tab";
- case ImGuiCol_TabHovered: return "TabHovered";
- case ImGuiCol_TabActive: return "TabActive";
- case ImGuiCol_TabUnfocused: return "TabUnfocused";
- case ImGuiCol_TabUnfocusedActive: return "TabUnfocusedActive";
- case ImGuiCol_DockingPreview: return "DockingPreview";
- case ImGuiCol_DockingEmptyBg: return "DockingEmptyBg";
- case ImGuiCol_PlotLines: return "PlotLines";
- case ImGuiCol_PlotLinesHovered: return "PlotLinesHovered";
- case ImGuiCol_PlotHistogram: return "PlotHistogram";
- case ImGuiCol_PlotHistogramHovered: return "PlotHistogramHovered";
- case ImGuiCol_TextSelectedBg: return "TextSelectedBg";
- case ImGuiCol_DragDropTarget: return "DragDropTarget";
- case ImGuiCol_NavHighlight: return "NavHighlight";
- case ImGuiCol_NavWindowingHighlight: return "NavWindowingHighlight";
- case ImGuiCol_NavWindowingDimBg: return "NavWindowingDimBg";
- case ImGuiCol_ModalWindowDimBg: return "ModalWindowDimBg";
- }
- IM_ASSERT(0);
- return "Unknown";
-}
-
-bool ImGui::IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent)
-{
- if (window->RootWindow == potential_parent)
- return true;
- while (window != NULL)
- {
- if (window == potential_parent)
- return true;
- window = window->ParentWindow;
- }
- return false;
-}
-
-bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags)
-{
- IM_ASSERT((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0); // Flags not supported by this function
- ImGuiContext& g = *GImGui;
-
- if (flags & ImGuiHoveredFlags_AnyWindow)
- {
- if (g.HoveredWindow == NULL)
- return false;
- }
- else
- {
- switch (flags & (ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows))
- {
- case ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows:
- if (g.HoveredWindow == NULL || g.HoveredWindow->RootWindowDockStop != g.CurrentWindow->RootWindowDockStop)
- return false;
- break;
- case ImGuiHoveredFlags_RootWindow:
- if (g.HoveredWindow != g.CurrentWindow->RootWindowDockStop)
- return false;
- break;
- case ImGuiHoveredFlags_ChildWindows:
- if (g.HoveredWindow == NULL || !IsWindowChildOf(g.HoveredWindow, g.CurrentWindow))
- return false;
- break;
- default:
- if (g.HoveredWindow != g.CurrentWindow)
- return false;
- break;
- }
- }
-
- if (!IsWindowContentHoverable(g.HoveredWindow, flags))
- return false;
- if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
- if (g.ActiveId != 0 && !g.ActiveIdAllowOverlap && g.ActiveId != g.HoveredWindow->MoveId)
- return false;
- return true;
-}
-
-bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags)
-{
- ImGuiContext& g = *GImGui;
-
- if (flags & ImGuiFocusedFlags_AnyWindow)
- return g.NavWindow != NULL;
-
- IM_ASSERT(g.CurrentWindow); // Not inside a Begin()/End()
- switch (flags & (ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows))
- {
- case ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows:
- return g.NavWindow && g.NavWindow->RootWindowDockStop == g.CurrentWindow->RootWindowDockStop;
- case ImGuiFocusedFlags_RootWindow:
- return g.NavWindow == g.CurrentWindow->RootWindowDockStop;
- case ImGuiFocusedFlags_ChildWindows:
- return g.NavWindow && IsWindowChildOf(g.NavWindow, g.CurrentWindow);
- default:
- return g.NavWindow == g.CurrentWindow;
- }
-}
-
-ImGuiID ImGui::GetWindowDockID()
-{
- ImGuiContext& g = *GImGui;
- return g.CurrentWindow->DockId;
-}
-
-bool ImGui::IsWindowDocked()
-{
- ImGuiContext& g = *GImGui;
- return g.CurrentWindow->DockIsActive;
-}
-
-// Can we focus this window with CTRL+TAB (or PadMenu + PadFocusPrev/PadFocusNext)
-// Note that NoNavFocus makes the window not reachable with CTRL+TAB but it can still be focused with mouse or programmaticaly.
-// If you want a window to never be focused, you may use the e.g. NoInputs flag.
-bool ImGui::IsWindowNavFocusable(ImGuiWindow* window)
-{
- return window->Active && window == window->RootWindowDockStop && !(window->Flags & ImGuiWindowFlags_NoNavFocus);
-}
-
-float ImGui::GetWindowWidth()
-{
- ImGuiWindow* window = GImGui->CurrentWindow;
- return window->Size.x;
-}
-
-float ImGui::GetWindowHeight()
-{
- ImGuiWindow* window = GImGui->CurrentWindow;
- return window->Size.y;
-}
-
-ImVec2 ImGui::GetWindowPos()
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
- return window->Pos;
-}
-
-void ImGui::SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond)
+void ImGui::SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond)
{
// Test condition (NB: bit 0 is always true) and clear flags for next time
if (cond && (window->SetWindowPosAllowFlags & cond) == 0)
@@ -7148,7 +6393,7 @@ void ImGui::SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond con
if (size.x > 0.0f)
{
window->AutoFitFramesX = 0;
- window->SizeFull.x = ImFloor(size.x);
+ window->SizeFull.x = IM_FLOOR(size.x);
}
else
{
@@ -7158,7 +6403,7 @@ void ImGui::SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond con
if (size.y > 0.0f)
{
window->AutoFitFramesY = 0;
- window->SizeFull.y = ImFloor(size.y);
+ window->SizeFull.y = IM_FLOOR(size.y);
}
else
{
@@ -7189,13 +6434,6 @@ void ImGui::SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond co
window->Collapsed = collapsed;
}
-static void SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size)
-{
- IM_ASSERT(window->HitTestHoleSize.x == 0); // We don't support multiple holes/hit test filters
- window->HitTestHoleSize = ImVec2ih(size);
- window->HitTestHoleOffset = ImVec2ih(pos - window->Pos);
-}
-
void ImGui::SetWindowCollapsed(bool collapsed, ImGuiCond cond)
{
SetWindowCollapsed(GImGui->CurrentWindow, collapsed, cond);
@@ -7245,18 +6483,8 @@ void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond, const ImVec2& pi
g.NextWindowData.PosVal = pos;
g.NextWindowData.PosPivotVal = pivot;
g.NextWindowData.PosCond = cond ? cond : ImGuiCond_Always;
- g.NextWindowData.PosUndock = true;
}
-#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
-void ImGui::SetNextWindowPosCenter(ImGuiCond cond)
-{
- ImGuiViewport* viewport = ImGui::GetMainViewport();
- SetNextWindowPos(viewport->Pos + viewport->Size * 0.5f, cond, ImVec2(0.5f, 0.5f));
- SetNextWindowViewport(viewport->ID);
-}
-#endif
-
void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond)
{
ImGuiContext& g = *GImGui;
@@ -7306,220 +6534,68 @@ void ImGui::SetNextWindowBgAlpha(float alpha)
g.NextWindowData.BgAlphaVal = alpha;
}
-void ImGui::SetNextWindowViewport(ImGuiID id)
+ImDrawList* ImGui::GetWindowDrawList()
{
- ImGuiContext& g = *GImGui;
- g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasViewport;
- g.NextWindowData.ViewportId = id;
+ ImGuiWindow* window = GetCurrentWindow();
+ return window->DrawList;
}
-void ImGui::SetNextWindowDockID(ImGuiID id, ImGuiCond cond)
+ImFont* ImGui::GetFont()
{
- ImGuiContext& g = *GImGui;
- g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasDock;
- g.NextWindowData.DockCond = cond ? cond : ImGuiCond_Always;
- g.NextWindowData.DockId = id;
+ return GImGui->Font;
}
-void ImGui::SetNextWindowClass(const ImGuiWindowClass* window_class)
+float ImGui::GetFontSize()
{
- ImGuiContext& g = *GImGui;
- IM_ASSERT((window_class->ViewportFlagsOverrideSet & window_class->ViewportFlagsOverrideClear) == 0); // Cannot set both set and clear for the same bit
- g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasWindowClass;
- g.NextWindowData.WindowClass = *window_class;
+ return GImGui->FontSize;
}
-// FIXME: This is in window space (not screen space!). We should try to obsolete all those functions.
-ImVec2 ImGui::GetContentRegionMax()
+ImVec2 ImGui::GetFontTexUvWhitePixel()
{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
- ImVec2 mx = window->ContentsRegionRect.Max - window->Pos;
- if (window->DC.CurrentColumns)
- mx.x = window->WorkRect.Max.x - window->Pos.x;
- return mx;
+ return GImGui->DrawListSharedData.TexUvWhitePixel;
}
-// [Internal] Absolute coordinate. Saner. This is not exposed until we finishing refactoring work rect features.
-ImVec2 ImGui::GetContentRegionMaxAbs()
+void ImGui::SetWindowFontScale(float scale)
{
ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
- ImVec2 mx = window->ContentsRegionRect.Max;
- if (window->DC.CurrentColumns)
- mx.x = window->WorkRect.Max.x;
- return mx;
-}
-
-ImVec2 ImGui::GetContentRegionAvail()
-{
- ImGuiWindow* window = GImGui->CurrentWindow;
- return GetContentRegionMaxAbs() - window->DC.CursorPos;
+ ImGuiWindow* window = GetCurrentWindow();
+ window->FontWindowScale = scale;
+ g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize();
}
-// In window space (not screen space!)
-ImVec2 ImGui::GetWindowContentRegionMin()
+void ImGui::ActivateItem(ImGuiID id)
{
- ImGuiWindow* window = GImGui->CurrentWindow;
- return window->ContentsRegionRect.Min - window->Pos;
+ ImGuiContext& g = *GImGui;
+ g.NavNextActivateId = id;
}
-ImVec2 ImGui::GetWindowContentRegionMax()
+void ImGui::PushFocusScope(ImGuiID id)
{
- ImGuiWindow* window = GImGui->CurrentWindow;
- return window->ContentsRegionRect.Max - window->Pos;
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ window->IDStack.push_back(window->DC.NavFocusScopeIdCurrent);
+ window->DC.NavFocusScopeIdCurrent = id;
}
-float ImGui::GetWindowContentRegionWidth()
+void ImGui::PopFocusScope()
{
- ImGuiWindow* window = GImGui->CurrentWindow;
- return window->ContentsRegionRect.GetWidth();
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ window->DC.NavFocusScopeIdCurrent = window->IDStack.back();
+ window->IDStack.pop_back();
}
-float ImGui::GetTextLineHeight()
+void ImGui::SetKeyboardFocusHere(int offset)
{
+ IM_ASSERT(offset >= -1); // -1 is allowed but not below
ImGuiContext& g = *GImGui;
- return g.FontSize;
+ ImGuiWindow* window = g.CurrentWindow;
+ g.FocusRequestNextWindow = window;
+ g.FocusRequestNextCounterRegular = window->DC.FocusCounterRegular + 1 + offset;
+ g.FocusRequestNextCounterTabStop = INT_MAX;
}
-float ImGui::GetTextLineHeightWithSpacing()
-{
- ImGuiContext& g = *GImGui;
- return g.FontSize + g.Style.ItemSpacing.y;
-}
-
-float ImGui::GetFrameHeight()
-{
- ImGuiContext& g = *GImGui;
- return g.FontSize + g.Style.FramePadding.y * 2.0f;
-}
-
-float ImGui::GetFrameHeightWithSpacing()
-{
- ImGuiContext& g = *GImGui;
- return g.FontSize + g.Style.FramePadding.y * 2.0f + g.Style.ItemSpacing.y;
-}
-
-ImDrawList* ImGui::GetWindowDrawList()
-{
- ImGuiWindow* window = GetCurrentWindow();
- return window->DrawList;
-}
-
-float ImGui::GetWindowDpiScale()
-{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(g.CurrentViewport != NULL);
- return g.CurrentViewport->DpiScale;
-}
-
-ImGuiViewport* ImGui::GetWindowViewport()
-{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(g.CurrentViewport != NULL && g.CurrentViewport == g.CurrentWindow->Viewport);
- return g.CurrentViewport;
-}
-
-ImFont* ImGui::GetFont()
-{
- return GImGui->Font;
-}
-
-float ImGui::GetFontSize()
-{
- return GImGui->FontSize;
-}
-
-ImVec2 ImGui::GetFontTexUvWhitePixel()
-{
- return GImGui->DrawListSharedData.TexUvWhitePixel;
-}
-
-void ImGui::SetWindowFontScale(float scale)
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = GetCurrentWindow();
- window->FontWindowScale = scale;
- g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize();
-}
-
-// User generally sees positions in window coordinates. Internally we store CursorPos in absolute screen coordinates because it is more convenient.
-// Conversion happens as we pass the value to user, but it makes our naming convention confusing because GetCursorPos() == (DC.CursorPos - window.Pos). May want to rename 'DC.CursorPos'.
-ImVec2 ImGui::GetCursorPos()
-{
- ImGuiWindow* window = GetCurrentWindowRead();
- return window->DC.CursorPos - window->Pos + window->Scroll;
-}
-
-float ImGui::GetCursorPosX()
-{
- ImGuiWindow* window = GetCurrentWindowRead();
- return window->DC.CursorPos.x - window->Pos.x + window->Scroll.x;
-}
-
-float ImGui::GetCursorPosY()
-{
- ImGuiWindow* window = GetCurrentWindowRead();
- return window->DC.CursorPos.y - window->Pos.y + window->Scroll.y;
-}
-
-void ImGui::SetCursorPos(const ImVec2& local_pos)
-{
- ImGuiWindow* window = GetCurrentWindow();
- window->DC.CursorPos = window->Pos - window->Scroll + local_pos;
- window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
-}
-
-void ImGui::SetCursorPosX(float x)
-{
- ImGuiWindow* window = GetCurrentWindow();
- window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + x;
- window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPos.x);
-}
-
-void ImGui::SetCursorPosY(float y)
-{
- ImGuiWindow* window = GetCurrentWindow();
- window->DC.CursorPos.y = window->Pos.y - window->Scroll.y + y;
- window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y);
-}
-
-ImVec2 ImGui::GetCursorStartPos()
-{
- ImGuiWindow* window = GetCurrentWindowRead();
- return window->DC.CursorStartPos - window->Pos;
-}
-
-ImVec2 ImGui::GetCursorScreenPos()
-{
- ImGuiWindow* window = GetCurrentWindowRead();
- return window->DC.CursorPos;
-}
-
-void ImGui::SetCursorScreenPos(const ImVec2& pos)
-{
- ImGuiWindow* window = GetCurrentWindow();
- window->DC.CursorPos = pos;
- window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
-}
-
-void ImGui::ActivateItem(ImGuiID id)
-{
- ImGuiContext& g = *GImGui;
- g.NavNextActivateId = id;
-}
-
-void ImGui::SetKeyboardFocusHere(int offset)
-{
- IM_ASSERT(offset >= -1); // -1 is allowed but not below
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
- g.FocusRequestNextWindow = window;
- g.FocusRequestNextCounterAll = window->DC.FocusCounterAll + 1 + offset;
- g.FocusRequestNextCounterTab = INT_MAX;
-}
-
-void ImGui::SetItemDefaultFocus()
+void ImGui::SetItemDefaultFocus()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
@@ -7615,94 +6691,254 @@ bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max)
return window->ClipRect.Overlaps(ImRect(rect_min, rect_max));
}
-// Lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)
-void ImGui::BeginGroup()
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = GetCurrentWindow();
- window->DC.GroupStack.resize(window->DC.GroupStack.Size + 1);
- ImGuiGroupData& group_data = window->DC.GroupStack.back();
- group_data.BackupCursorPos = window->DC.CursorPos;
- group_data.BackupCursorMaxPos = window->DC.CursorMaxPos;
- group_data.BackupIndent = window->DC.Indent;
- group_data.BackupGroupOffset = window->DC.GroupOffset;
- group_data.BackupCurrLineSize = window->DC.CurrLineSize;
- group_data.BackupCurrLineTextBaseOffset = window->DC.CurrLineTextBaseOffset;
- group_data.BackupActiveIdIsAlive = g.ActiveIdIsAlive;
- group_data.BackupActiveIdPreviousFrameIsAlive = g.ActiveIdPreviousFrameIsAlive;
- group_data.EmitItem = true;
+//-----------------------------------------------------------------------------
+// [SECTION] ERROR CHECKING
+//-----------------------------------------------------------------------------
- window->DC.GroupOffset.x = window->DC.CursorPos.x - window->Pos.x - window->DC.ColumnsOffset.x;
- window->DC.Indent = window->DC.GroupOffset;
- window->DC.CursorMaxPos = window->DC.CursorPos;
- window->DC.CurrLineSize = ImVec2(0.0f, 0.0f);
- if (g.LogEnabled)
- g.LogLinePosY = -FLT_MAX; // To enforce Log carriage return
+// Helper function to verify ABI compatibility between caller code and compiled version of Dear ImGui.
+// Verify that the type sizes are matching between the calling file's compilation unit and imgui.cpp's compilation unit
+// If the user has inconsistent compilation settings, imgui configuration #define, packing pragma, etc. your user code
+// may see different structures than what imgui.cpp sees, which is problematic.
+// We usually require settings to be in imconfig.h to make sure that they are accessible to all compilation units involved with Dear ImGui.
+bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_vert, size_t sz_idx)
+{
+ bool error = false;
+ if (strcmp(version, IMGUI_VERSION) != 0) { error = true; IM_ASSERT(strcmp(version, IMGUI_VERSION) == 0 && "Mismatched version string!"); }
+ if (sz_io != sizeof(ImGuiIO)) { error = true; IM_ASSERT(sz_io == sizeof(ImGuiIO) && "Mismatched struct layout!"); }
+ if (sz_style != sizeof(ImGuiStyle)) { error = true; IM_ASSERT(sz_style == sizeof(ImGuiStyle) && "Mismatched struct layout!"); }
+ if (sz_vec2 != sizeof(ImVec2)) { error = true; IM_ASSERT(sz_vec2 == sizeof(ImVec2) && "Mismatched struct layout!"); }
+ if (sz_vec4 != sizeof(ImVec4)) { error = true; IM_ASSERT(sz_vec4 == sizeof(ImVec4) && "Mismatched struct layout!"); }
+ if (sz_vert != sizeof(ImDrawVert)) { error = true; IM_ASSERT(sz_vert == sizeof(ImDrawVert) && "Mismatched struct layout!"); }
+ if (sz_idx != sizeof(ImDrawIdx)) { error = true; IM_ASSERT(sz_idx == sizeof(ImDrawIdx) && "Mismatched struct layout!"); }
+ return !error;
}
-void ImGui::EndGroup()
+static void ImGui::ErrorCheckNewFrameSanityChecks()
{
ImGuiContext& g = *GImGui;
- ImGuiWindow* window = GetCurrentWindow();
- IM_ASSERT(!window->DC.GroupStack.empty()); // Mismatched BeginGroup()/EndGroup() calls
- ImGuiGroupData& group_data = window->DC.GroupStack.back();
+ // Check user IM_ASSERT macro
+ // (IF YOU GET A WARNING OR COMPILE ERROR HERE: it means you assert macro is incorrectly defined!
+ // If your macro uses multiple statements, it NEEDS to be surrounded by a 'do { ... } while (0)' block.
+ // This is a common C/C++ idiom to allow multiple statements macros to be used in control flow blocks.)
+ // #define IM_ASSERT(EXPR) SomeCode(EXPR); SomeMoreCode(); // Wrong!
+ // #define IM_ASSERT(EXPR) do { SomeCode(EXPR); SomeMoreCode(); } while (0) // Correct!
+ if (true) IM_ASSERT(1); else IM_ASSERT(0);
- ImRect group_bb(group_data.BackupCursorPos, ImMax(window->DC.CursorMaxPos, group_data.BackupCursorPos));
+ // Check user data
+ // (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument)
+ IM_ASSERT(g.Initialized);
+ IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!");
+ IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?");
+ IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!");
+ IM_ASSERT(g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
+ IM_ASSERT(g.IO.Fonts->Fonts[0]->IsLoaded() && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
+ IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!");
+ IM_ASSERT(g.Style.CircleSegmentMaxError > 0.0f && "Invalid style setting!");
+ IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)!");
+ IM_ASSERT(g.Style.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting.");
+ IM_ASSERT(g.Style.WindowMenuButtonPosition == ImGuiDir_None || g.Style.WindowMenuButtonPosition == ImGuiDir_Left || g.Style.WindowMenuButtonPosition == ImGuiDir_Right);
+ for (int n = 0; n < ImGuiKey_COUNT; n++)
+ IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
- window->DC.CursorPos = group_data.BackupCursorPos;
- window->DC.CursorMaxPos = ImMax(group_data.BackupCursorMaxPos, window->DC.CursorMaxPos);
- window->DC.Indent = group_data.BackupIndent;
- window->DC.GroupOffset = group_data.BackupGroupOffset;
- window->DC.CurrLineSize = group_data.BackupCurrLineSize;
- window->DC.CurrLineTextBaseOffset = group_data.BackupCurrLineTextBaseOffset;
- if (g.LogEnabled)
- g.LogLinePosY = -FLT_MAX; // To enforce Log carriage return
+ // Perform simple check: required key mapping (we intentionally do NOT check all keys to not pressure user into setting up everything, but Space is required and was only recently added in 1.60 WIP)
+ if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard)
+ IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation.");
- if (!group_data.EmitItem)
+ // Perform simple check: the beta io.ConfigWindowsResizeFromEdges option requires back-end to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly.
+ if (g.IO.ConfigWindowsResizeFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors))
+ g.IO.ConfigWindowsResizeFromEdges = false;
+}
+
+static void ImGui::ErrorCheckEndFrameSanityChecks()
+{
+ ImGuiContext& g = *GImGui;
+
+ // Verify that io.KeyXXX fields haven't been tampered with. Key mods shoudl not be modified between NewFrame() and EndFrame()
+ const ImGuiKeyModFlags expected_key_mod_flags = GetMergedKeyModFlags();
+ IM_ASSERT(g.IO.KeyMods == expected_key_mod_flags && "Mismatching io.KeyCtrl/io.KeyShift/io.KeyAlt/io.KeySuper vs io.KeyMods");
+ IM_UNUSED(expected_key_mod_flags);
+
+ // Report when there is a mismatch of Begin/BeginChild vs End/EndChild calls. Important: Remember that the Begin/BeginChild API requires you
+ // to always call End/EndChild even if Begin/BeginChild returns false! (this is unfortunately inconsistent with most other Begin* API).
+ if (g.CurrentWindowStack.Size != 1)
{
- window->DC.GroupStack.pop_back();
- return;
+ if (g.CurrentWindowStack.Size > 1)
+ {
+ IM_ASSERT_USER_ERROR(g.CurrentWindowStack.Size == 1, "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?");
+ while (g.CurrentWindowStack.Size > 1)
+ End();
+ }
+ else
+ {
+ IM_ASSERT_USER_ERROR(g.CurrentWindowStack.Size == 1, "Mismatched Begin/BeginChild vs End/EndChild calls: did you call End/EndChild too much?");
+ }
}
+}
- window->DC.CurrLineTextBaseOffset = ImMax(window->DC.PrevLineTextBaseOffset, group_data.BackupCurrLineTextBaseOffset); // FIXME: Incorrect, we should grab the base offset from the *first line* of the group but it is hard to obtain now.
- ItemSize(group_bb.GetSize(), 0.0f);
- ItemAdd(group_bb, 0);
+// Save and compare stack sizes on Begin()/End() to detect usage errors
+// Begin() calls this with write=true
+// End() calls this with write=false
+static void ImGui::ErrorCheckBeginEndCompareStacksSize(ImGuiWindow* window, bool write)
+{
+ ImGuiContext& g = *GImGui;
+ short* p = &window->DC.StackSizesBackup[0];
- // If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive(), IsItemDeactivated() etc. will be functional on the entire group.
- // It would be be neater if we replaced window.DC.LastItemId by e.g. 'bool LastItemIsActive', but would put a little more burden on individual widgets.
- // Also if you grep for LastItemId you'll notice it is only used in that context.
- // (The tests not symmetrical because ActiveIdIsAlive is an ID itself, in order to be able to handle ActiveId being overwritten during the frame.)
- const bool group_contains_curr_active_id = (group_data.BackupActiveIdIsAlive != g.ActiveId) && (g.ActiveIdIsAlive == g.ActiveId) && g.ActiveId;
- const bool group_contains_prev_active_id = !group_data.BackupActiveIdPreviousFrameIsAlive && g.ActiveIdPreviousFrameIsAlive;
- if (group_contains_curr_active_id)
- window->DC.LastItemId = g.ActiveId;
- else if (group_contains_prev_active_id)
- window->DC.LastItemId = g.ActiveIdPreviousFrame;
- window->DC.LastItemRect = group_bb;
+ // Window stacks
+ // NOT checking: DC.ItemWidth, DC.AllowKeyboardFocus, DC.ButtonRepeat, DC.TextWrapPos (per window) to allow user to conveniently push once and not pop (they are cleared on Begin)
+ { int n = window->IDStack.Size; if (write) *p = (short)n; else IM_ASSERT(*p == n && "PushID/PopID or TreeNode/TreePop Mismatch!"); p++; } // Too few or too many PopID()/TreePop()
+ { int n = window->DC.GroupStack.Size; if (write) *p = (short)n; else IM_ASSERT(*p == n && "BeginGroup/EndGroup Mismatch!"); p++; } // Too few or too many EndGroup()
- // Forward Edited flag
- if (group_contains_curr_active_id && g.ActiveIdHasBeenEditedThisFrame)
- window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Edited;
+ // Global stacks
+ // For color, style and font stacks there is an incentive to use Push/Begin/Pop/.../End patterns, so we relax our checks a little to allow them.
+ { int n = g.BeginPopupStack.Size; if (write) *p = (short)n; else IM_ASSERT(*p == n && "BeginMenu/EndMenu or BeginPopup/EndPopup Mismatch!"); p++; }// Too few or too many EndMenu()/EndPopup()
+ { int n = g.ColorModifiers.Size; if (write) *p = (short)n; else IM_ASSERT(*p >= n && "PushStyleColor/PopStyleColor Mismatch!"); p++; } // Too few or too many PopStyleColor()
+ { int n = g.StyleModifiers.Size; if (write) *p = (short)n; else IM_ASSERT(*p >= n && "PushStyleVar/PopStyleVar Mismatch!"); p++; } // Too few or too many PopStyleVar()
+ { int n = g.FontStack.Size; if (write) *p = (short)n; else IM_ASSERT(*p >= n && "PushFont/PopFont Mismatch!"); p++; } // Too few or too many PopFont()
+ IM_ASSERT(p == window->DC.StackSizesBackup + IM_ARRAYSIZE(window->DC.StackSizesBackup));
+}
- // Forward Deactivated flag
- window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HasDeactivated;
- if (group_contains_prev_active_id && g.ActiveId != g.ActiveIdPreviousFrame)
- window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Deactivated;
- window->DC.GroupStack.pop_back();
- //window->DrawList->AddRect(group_bb.Min, group_bb.Max, IM_COL32(255,0,255,255)); // [Debug]
-}
+//-----------------------------------------------------------------------------
+// [SECTION] LAYOUT
+//-----------------------------------------------------------------------------
+// - ItemSize()
+// - ItemAdd()
+// - SameLine()
+// - GetCursorScreenPos()
+// - SetCursorScreenPos()
+// - GetCursorPos(), GetCursorPosX(), GetCursorPosY()
+// - SetCursorPos(), SetCursorPosX(), SetCursorPosY()
+// - GetCursorStartPos()
+// - Indent()
+// - Unindent()
+// - SetNextItemWidth()
+// - PushItemWidth()
+// - PushMultiItemsWidths()
+// - PopItemWidth()
+// - CalcItemWidth()
+// - CalcItemSize()
+// - GetTextLineHeight()
+// - GetTextLineHeightWithSpacing()
+// - GetFrameHeight()
+// - GetFrameHeightWithSpacing()
+// - GetContentRegionMax()
+// - GetContentRegionMaxAbs() [Internal]
+// - GetContentRegionAvail(),
+// - GetWindowContentRegionMin(), GetWindowContentRegionMax()
+// - GetWindowContentRegionWidth()
+// - BeginGroup()
+// - EndGroup()
+// Also see in imgui_widgets: tab bars, columns.
+//-----------------------------------------------------------------------------
-// Gets back to previous line and continue with horizontal layout
-// offset_from_start_x == 0 : follow right after previous item
-// 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 : enforce spacing amount
-void ImGui::SameLine(float offset_from_start_x, float spacing_w)
+// Advance cursor given item size for layout.
+// Register minimum needed size so it can extend the bounding box used for auto-fit calculation.
+// See comments in ItemAdd() about how/why the size provided to ItemSize() vs ItemAdd() may often different.
+void ImGui::ItemSize(const ImVec2& size, float text_baseline_y)
{
- ImGuiWindow* window = GetCurrentWindow();
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ if (window->SkipItems)
+ return;
+
+ // We increase the height in this function to accommodate for baseline offset.
+ // In theory we should be offsetting the starting position (window->DC.CursorPos), that will be the topic of a larger refactor,
+ // but since ItemSize() is not yet an API that moves the cursor (to handle e.g. wrapping) enlarging the height has the same effect.
+ const float offset_to_match_baseline_y = (text_baseline_y >= 0) ? ImMax(0.0f, window->DC.CurrLineTextBaseOffset - text_baseline_y) : 0.0f;
+ const float line_height = ImMax(window->DC.CurrLineSize.y, size.y + offset_to_match_baseline_y);
+
+ // Always align ourselves on pixel boundaries
+ //if (g.IO.KeyAlt) window->DrawList->AddRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(size.x, line_height), IM_COL32(255,0,0,200)); // [DEBUG]
+ window->DC.CursorPosPrevLine.x = window->DC.CursorPos.x + size.x;
+ window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y;
+ window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); // Next line
+ window->DC.CursorPos.y = IM_FLOOR(window->DC.CursorPos.y + line_height + g.Style.ItemSpacing.y); // Next line
+ window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPosPrevLine.x);
+ window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y - g.Style.ItemSpacing.y);
+ //if (g.IO.KeyAlt) window->DrawList->AddCircle(window->DC.CursorMaxPos, 3.0f, IM_COL32(255,0,0,255), 4); // [DEBUG]
+
+ window->DC.PrevLineSize.y = line_height;
+ window->DC.CurrLineSize.y = 0.0f;
+ window->DC.PrevLineTextBaseOffset = ImMax(window->DC.CurrLineTextBaseOffset, text_baseline_y);
+ window->DC.CurrLineTextBaseOffset = 0.0f;
+
+ // Horizontal layout mode
+ if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
+ SameLine();
+}
+
+void ImGui::ItemSize(const ImRect& bb, float text_baseline_y)
+{
+ ItemSize(bb.GetSize(), text_baseline_y);
+}
+
+// Declare item bounding box for clipping and interaction.
+// Note that the size can be different than the one provided to ItemSize(). Typically, widgets that spread over available surface
+// declare their minimum size requirement to ItemSize() and provide a larger region to ItemAdd() which is used drawing/interaction.
+bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ if (id != 0)
+ {
+ // Navigation processing runs prior to clipping early-out
+ // (a) So that NavInitRequest can be honored, for newly opened windows to select a default widget
+ // (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests
+ // unfortunately, but it is still limited to one window. It may not scale very well for windows with ten of
+ // thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame.
+ // We could early out with "if (is_clipped && !g.NavInitRequest) return false;" but when we wouldn't be able
+ // to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick).
+ // We intentionally don't check if g.NavWindow != NULL because g.NavAnyRequest should only be set when it is non null.
+ // If we crash on a NULL g.NavWindow we need to fix the bug elsewhere.
+ window->DC.NavLayerActiveMaskNext |= window->DC.NavLayerCurrentMask;
+ if (g.NavId == id || g.NavAnyRequest)
+ if (g.NavWindow->RootWindowForNav == window->RootWindowForNav)
+ if (window == g.NavWindow || ((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened))
+ NavProcessItem(window, nav_bb_arg ? *nav_bb_arg : bb, id);
+
+ // [DEBUG] Item Picker tool, when enabling the "extended" version we perform the check in ItemAdd()
+#ifdef IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
+ if (id == g.DebugItemPickerBreakId)
+ {
+ IM_DEBUG_BREAK();
+ g.DebugItemPickerBreakId = 0;
+ }
+#endif
+ }
+
+ window->DC.LastItemId = id;
+ window->DC.LastItemRect = bb;
+ window->DC.LastItemStatusFlags = ImGuiItemStatusFlags_None;
+ g.NextItemData.Flags = ImGuiNextItemDataFlags_None;
+
+#ifdef IMGUI_ENABLE_TEST_ENGINE
+ if (id != 0)
+ IMGUI_TEST_ENGINE_ITEM_ADD(nav_bb_arg ? *nav_bb_arg : bb, id);
+#endif
+
+ // Clipping test
+ const bool is_clipped = IsClippedEx(bb, id, false);
+ if (is_clipped)
+ return false;
+ //if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG]
+
+ // We need to calculate this now to take account of the current clipping rectangle (as items like Selectable may change them)
+ if (IsMouseHoveringRect(bb.Min, bb.Max))
+ window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HoveredRect;
+ return true;
+}
+
+// Gets back to previous line and continue with horizontal layout
+// offset_from_start_x == 0 : follow right after previous item
+// 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 : enforce spacing amount
+void ImGui::SameLine(float offset_from_start_x, float spacing_w)
+{
+ ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
return;
@@ -7723,6791 +6959,2857 @@ void ImGui::SameLine(float offset_from_start_x, float spacing_w)
window->DC.CurrLineTextBaseOffset = window->DC.PrevLineTextBaseOffset;
}
-void ImGui::Indent(float indent_w)
+ImVec2 ImGui::GetCursorScreenPos()
{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = GetCurrentWindow();
- window->DC.Indent.x += (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing;
- window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x;
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->DC.CursorPos;
}
-void ImGui::Unindent(float indent_w)
+void ImGui::SetCursorScreenPos(const ImVec2& pos)
{
- ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
- window->DC.Indent.x -= (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing;
- window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x;
+ window->DC.CursorPos = pos;
+ window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
}
-
-//-----------------------------------------------------------------------------
-// [SECTION] SCROLLING
-//-----------------------------------------------------------------------------
-
-static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window, bool snap_on_edges)
+// User generally sees positions in window coordinates. Internally we store CursorPos in absolute screen coordinates because it is more convenient.
+// Conversion happens as we pass the value to user, but it makes our naming convention confusing because GetCursorPos() == (DC.CursorPos - window.Pos). May want to rename 'DC.CursorPos'.
+ImVec2 ImGui::GetCursorPos()
{
- ImGuiContext& g = *GImGui;
- ImVec2 scroll = window->Scroll;
- if (window->ScrollTarget.x < FLT_MAX)
- {
- float cr_x = window->ScrollTargetCenterRatio.x;
- float target_x = window->ScrollTarget.x;
- if (snap_on_edges && cr_x <= 0.0f && target_x <= window->WindowPadding.x)
- target_x = 0.0f;
- else if (snap_on_edges && cr_x >= 1.0f && target_x >= window->ContentSize.x + window->WindowPadding.x + g.Style.ItemSpacing.x)
- target_x = window->ContentSize.x + window->WindowPadding.x * 2.0f;
- scroll.x = target_x - cr_x * (window->SizeFull.x - window->ScrollbarSizes.x);
- }
- if (window->ScrollTarget.y < FLT_MAX)
- {
- // 'snap_on_edges' allows for a discontinuity at the edge of scrolling limits to take account of WindowPadding so that scrolling to make the last item visible scroll far enough to see the padding.
- float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight();
- float cr_y = window->ScrollTargetCenterRatio.y;
- float target_y = window->ScrollTarget.y;
- if (snap_on_edges && cr_y <= 0.0f && target_y <= window->WindowPadding.y)
- target_y = 0.0f;
- if (snap_on_edges && cr_y >= 1.0f && target_y >= window->ContentSize.y + window->WindowPadding.y + g.Style.ItemSpacing.y)
- target_y = window->ContentSize.y + window->WindowPadding.y * 2.0f;
- scroll.y = target_y - cr_y * (window->SizeFull.y - window->ScrollbarSizes.y - decoration_up_height);
- }
- scroll = ImMax(scroll, ImVec2(0.0f, 0.0f));
- if (!window->Collapsed && !window->SkipItems)
- {
- scroll.x = ImMin(scroll.x, window->ScrollMax.x);
- scroll.y = ImMin(scroll.y, window->ScrollMax.y);
- }
- return scroll;
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->DC.CursorPos - window->Pos + window->Scroll;
}
-// Scroll to keep newly navigated item fully into view
-ImVec2 ImGui::ScrollToBringRectIntoView(ImGuiWindow* window, const ImRect& item_rect)
+float ImGui::GetCursorPosX()
{
- ImGuiContext& g = *GImGui;
- ImRect window_rect(window->InnerRect.Min - ImVec2(1, 1), window->InnerRect.Max + ImVec2(1, 1));
- //GetForegroundDrawList(window)->AddRect(window_rect.Min, window_rect.Max, IM_COL32_WHITE); // [DEBUG]
-
- ImVec2 delta_scroll;
- if (!window_rect.Contains(item_rect))
- {
- if (window->ScrollbarX && item_rect.Min.x < window_rect.Min.x)
- SetScrollFromPosX(window, item_rect.Min.x - window->Pos.x + g.Style.ItemSpacing.x, 0.0f);
- else if (window->ScrollbarX && item_rect.Max.x >= window_rect.Max.x)
- SetScrollFromPosX(window, item_rect.Max.x - window->Pos.x + g.Style.ItemSpacing.x, 1.0f);
- if (item_rect.Min.y < window_rect.Min.y)
- SetScrollFromPosY(window, item_rect.Min.y - window->Pos.y - g.Style.ItemSpacing.y, 0.0f);
- else if (item_rect.Max.y >= window_rect.Max.y)
- SetScrollFromPosY(window, item_rect.Max.y - window->Pos.y + g.Style.ItemSpacing.y, 1.0f);
-
- ImVec2 next_scroll = CalcNextScrollFromScrollTargetAndClamp(window, false);
- delta_scroll = next_scroll - window->Scroll;
- }
-
- // Also scroll parent window to keep us into view if necessary
- if (window->Flags & ImGuiWindowFlags_ChildWindow)
- delta_scroll += ScrollToBringRectIntoView(window->ParentWindow, ImRect(item_rect.Min - delta_scroll, item_rect.Max - delta_scroll));
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->DC.CursorPos.x - window->Pos.x + window->Scroll.x;
+}
- return delta_scroll;
+float ImGui::GetCursorPosY()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->DC.CursorPos.y - window->Pos.y + window->Scroll.y;
}
-float ImGui::GetScrollX()
+void ImGui::SetCursorPos(const ImVec2& local_pos)
{
- ImGuiWindow* window = GImGui->CurrentWindow;
- return window->Scroll.x;
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DC.CursorPos = window->Pos - window->Scroll + local_pos;
+ window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
}
-float ImGui::GetScrollY()
+void ImGui::SetCursorPosX(float x)
{
- ImGuiWindow* window = GImGui->CurrentWindow;
- return window->Scroll.y;
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + x;
+ window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPos.x);
}
-float ImGui::GetScrollMaxX()
+void ImGui::SetCursorPosY(float y)
{
- ImGuiWindow* window = GImGui->CurrentWindow;
- return window->ScrollMax.x;
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DC.CursorPos.y = window->Pos.y - window->Scroll.y + y;
+ window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y);
}
-float ImGui::GetScrollMaxY()
+ImVec2 ImGui::GetCursorStartPos()
{
- ImGuiWindow* window = GImGui->CurrentWindow;
- return window->ScrollMax.y;
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->DC.CursorStartPos - window->Pos;
}
-void ImGui::SetScrollX(float scroll_x)
+void ImGui::Indent(float indent_w)
{
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
- window->ScrollTarget.x = scroll_x;
- window->ScrollTargetCenterRatio.x = 0.0f;
+ window->DC.Indent.x += (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing;
+ window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x;
}
-void ImGui::SetScrollY(float scroll_y)
+void ImGui::Unindent(float indent_w)
{
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
- window->ScrollTarget.y = scroll_y;
- window->ScrollTargetCenterRatio.y = 0.0f;
+ window->DC.Indent.x -= (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing;
+ window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x;
}
-void ImGui::SetScrollX(ImGuiWindow* window, float new_scroll_x)
+// Affect large frame+labels widgets only.
+void ImGui::SetNextItemWidth(float item_width)
{
- window->ScrollTarget.x = new_scroll_x;
- window->ScrollTargetCenterRatio.x = 0.0f;
+ ImGuiContext& g = *GImGui;
+ g.NextItemData.Flags |= ImGuiNextItemDataFlags_HasWidth;
+ g.NextItemData.Width = item_width;
}
-void ImGui::SetScrollY(ImGuiWindow* window, float new_scroll_y)
+void ImGui::PushItemWidth(float item_width)
{
- window->ScrollTarget.y = new_scroll_y;
- window->ScrollTargetCenterRatio.y = 0.0f;
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ window->DC.ItemWidth = (item_width == 0.0f ? window->ItemWidthDefault : item_width);
+ window->DC.ItemWidthStack.push_back(window->DC.ItemWidth);
+ g.NextItemData.Flags &= ~ImGuiNextItemDataFlags_HasWidth;
}
-
-void ImGui::SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio)
+void ImGui::PushMultiItemsWidths(int components, float w_full)
{
- // We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size
- IM_ASSERT(center_x_ratio >= 0.0f && center_x_ratio <= 1.0f);
- window->ScrollTarget.x = IM_FLOOR(local_x + window->Scroll.x);
- window->ScrollTargetCenterRatio.x = center_x_ratio;
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ const ImGuiStyle& style = g.Style;
+ const float w_item_one = ImMax(1.0f, IM_FLOOR((w_full - (style.ItemInnerSpacing.x) * (components-1)) / (float)components));
+ const float w_item_last = ImMax(1.0f, IM_FLOOR(w_full - (w_item_one + style.ItemInnerSpacing.x) * (components-1)));
+ window->DC.ItemWidthStack.push_back(w_item_last);
+ for (int i = 0; i < components-1; i++)
+ window->DC.ItemWidthStack.push_back(w_item_one);
+ window->DC.ItemWidth = window->DC.ItemWidthStack.back();
+ g.NextItemData.Flags &= ~ImGuiNextItemDataFlags_HasWidth;
}
-void ImGui::SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y_ratio)
+void ImGui::PopItemWidth()
{
- // We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size
- IM_ASSERT(center_y_ratio >= 0.0f && center_y_ratio <= 1.0f);
- const float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight();
- local_y -= decoration_up_height;
- window->ScrollTarget.y = IM_FLOOR(local_y + window->Scroll.y);
- window->ScrollTargetCenterRatio.y = center_y_ratio;
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DC.ItemWidthStack.pop_back();
+ window->DC.ItemWidth = window->DC.ItemWidthStack.empty() ? window->ItemWidthDefault : window->DC.ItemWidthStack.back();
}
-void ImGui::SetScrollFromPosX(float local_x, float center_x_ratio)
+// Calculate default item width given value passed to PushItemWidth() or SetNextItemWidth().
+// The SetNextItemWidth() data is generally cleared/consumed by ItemAdd() or NextItemData.ClearFlags()
+float ImGui::CalcItemWidth()
{
ImGuiContext& g = *GImGui;
- SetScrollFromPosX(g.CurrentWindow, local_x, center_x_ratio);
+ ImGuiWindow* window = g.CurrentWindow;
+ float w;
+ if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasWidth)
+ w = g.NextItemData.Width;
+ else
+ w = window->DC.ItemWidth;
+ if (w < 0.0f)
+ {
+ float region_max_x = GetContentRegionMaxAbs().x;
+ w = ImMax(1.0f, region_max_x - window->DC.CursorPos.x + w);
+ }
+ w = IM_FLOOR(w);
+ return w;
}
-void ImGui::SetScrollFromPosY(float local_y, float center_y_ratio)
+// [Internal] Calculate full item size given user provided 'size' parameter and default width/height. Default width is often == CalcItemWidth().
+// 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 CalcItemWidth() 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)
{
- ImGuiContext& g = *GImGui;
- SetScrollFromPosY(g.CurrentWindow, local_y, center_y_ratio);
+ ImGuiWindow* window = GImGui->CurrentWindow;
+
+ ImVec2 region_max;
+ if (size.x < 0.0f || size.y < 0.0f)
+ region_max = GetContentRegionMaxAbs();
+
+ 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;
}
-// center_x_ratio: 0.0f left of last item, 0.5f horizontal center of last item, 1.0f right of last item.
-void ImGui::SetScrollHereX(float center_x_ratio)
+float ImGui::GetTextLineHeight()
{
ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
- float target_x = window->DC.LastItemRect.Min.x - window->Pos.x; // Left of last item, in window space
- float last_item_width = window->DC.LastItemRect.GetWidth();
- target_x += (last_item_width * center_x_ratio) + (g.Style.ItemSpacing.x * (center_x_ratio - 0.5f) * 2.0f); // Precisely aim before, in the middle or after the last item.
- SetScrollFromPosX(target_x, center_x_ratio);
+ return g.FontSize;
}
-// center_y_ratio: 0.0f top of last item, 0.5f vertical center of last item, 1.0f bottom of last item.
-void ImGui::SetScrollHereY(float center_y_ratio)
+float ImGui::GetTextLineHeightWithSpacing()
{
ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
- float target_y = window->DC.CursorPosPrevLine.y - window->Pos.y; // Top of last item, in window space
- target_y += (window->DC.PrevLineSize.y * center_y_ratio) + (g.Style.ItemSpacing.y * (center_y_ratio - 0.5f) * 2.0f); // Precisely aim above, in the middle or below the last line.
- SetScrollFromPosY(target_y, center_y_ratio);
+ return g.FontSize + g.Style.ItemSpacing.y;
}
-//-----------------------------------------------------------------------------
-// [SECTION] TOOLTIPS
-//-----------------------------------------------------------------------------
-
-void ImGui::BeginTooltip()
+float ImGui::GetFrameHeight()
{
ImGuiContext& g = *GImGui;
- if (g.DragDropWithinSourceOrTarget)
- {
- // The default tooltip position is a little offset to give space to see the context menu (it's also clamped within the current viewport/monitor)
- // In the context of a dragging tooltip we try to reduce that offset and we enforce following the cursor.
- // Whatever we do we want to call SetNextWindowPos() to enforce a tooltip position and disable clipping the tooltip without our display area, like regular tooltip do.
- //ImVec2 tooltip_pos = g.IO.MousePos - g.ActiveIdClickOffset - g.Style.WindowPadding;
- ImVec2 tooltip_pos = g.IO.MousePos + ImVec2(16 * g.Style.MouseCursorScale, 8 * g.Style.MouseCursorScale);
- SetNextWindowPos(tooltip_pos);
- SetNextWindowBgAlpha(g.Style.Colors[ImGuiCol_PopupBg].w * 0.60f);
- //PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * 0.60f); // This would be nice but e.g ColorButton with checkboard has issue with transparent colors :(
- BeginTooltipEx(0, true);
- }
- else
- {
- BeginTooltipEx(0, false);
- }
+ return g.FontSize + g.Style.FramePadding.y * 2.0f;
}
-// Not exposed publicly as BeginTooltip() because bool parameters are evil. Let's see if other needs arise first.
-void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip)
+float ImGui::GetFrameHeightWithSpacing()
{
ImGuiContext& g = *GImGui;
- char window_name[16];
- ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", g.TooltipOverrideCount);
- if (override_previous_tooltip)
- if (ImGuiWindow* window = FindWindowByName(window_name))
- if (window->Active)
- {
- // Hide previous tooltip from being displayed. We can't easily "reset" the content of a window so we create a new one.
- window->Hidden = true;
- window->HiddenFramesCanSkipItems = 1;
- ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", ++g.TooltipOverrideCount);
- }
- ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip|ImGuiWindowFlags_NoInputs|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoDocking;
- Begin(window_name, NULL, flags | extra_flags);
+ return g.FontSize + g.Style.FramePadding.y * 2.0f + g.Style.ItemSpacing.y;
}
-void ImGui::EndTooltip()
-{
- IM_ASSERT(GetCurrentWindowRead()->Flags & ImGuiWindowFlags_Tooltip); // Mismatched BeginTooltip()/EndTooltip() calls
- End();
-}
+// FIXME: All the Contents Region function are messy or misleading. WE WILL AIM TO OBSOLETE ALL OF THEM WITH A NEW "WORK RECT" API. Thanks for your patience!
-void ImGui::SetTooltipV(const char* fmt, va_list args)
+// FIXME: This is in window space (not screen space!).
+ImVec2 ImGui::GetContentRegionMax()
{
ImGuiContext& g = *GImGui;
- if (g.DragDropWithinSourceOrTarget)
- BeginTooltip();
- else
- BeginTooltipEx(0, true);
- TextV(fmt, args);
- EndTooltip();
+ ImGuiWindow* window = g.CurrentWindow;
+ ImVec2 mx = window->ContentRegionRect.Max - window->Pos;
+ if (window->DC.CurrentColumns)
+ mx.x = window->WorkRect.Max.x - window->Pos.x;
+ return mx;
}
-void ImGui::SetTooltip(const char* fmt, ...)
+// [Internal] Absolute coordinate. Saner. This is not exposed until we finishing refactoring work rect features.
+ImVec2 ImGui::GetContentRegionMaxAbs()
{
- va_list args;
- va_start(args, fmt);
- SetTooltipV(fmt, args);
- va_end(args);
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ ImVec2 mx = window->ContentRegionRect.Max;
+ if (window->DC.CurrentColumns)
+ mx.x = window->WorkRect.Max.x;
+ return mx;
}
-//-----------------------------------------------------------------------------
-// [SECTION] POPUPS
-//-----------------------------------------------------------------------------
-
-bool ImGui::IsPopupOpen(ImGuiID id)
+ImVec2 ImGui::GetContentRegionAvail()
{
- ImGuiContext& g = *GImGui;
- return g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].PopupId == id;
+ ImGuiWindow* window = GImGui->CurrentWindow;
+ return GetContentRegionMaxAbs() - window->DC.CursorPos;
}
-bool ImGui::IsPopupOpen(const char* str_id)
+// In window space (not screen space!)
+ImVec2 ImGui::GetWindowContentRegionMin()
{
- ImGuiContext& g = *GImGui;
- return g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].PopupId == g.CurrentWindow->GetID(str_id);
+ ImGuiWindow* window = GImGui->CurrentWindow;
+ return window->ContentRegionRect.Min - window->Pos;
}
-ImGuiWindow* ImGui::GetTopMostPopupModal()
+ImVec2 ImGui::GetWindowContentRegionMax()
{
- ImGuiContext& g = *GImGui;
- for (int n = g.OpenPopupStack.Size-1; n >= 0; n--)
- if (ImGuiWindow* popup = g.OpenPopupStack.Data[n].Window)
- if (popup->Flags & ImGuiWindowFlags_Modal)
- return popup;
- return NULL;
+ ImGuiWindow* window = GImGui->CurrentWindow;
+ return window->ContentRegionRect.Max - window->Pos;
}
-void ImGui::OpenPopup(const char* str_id)
+float ImGui::GetWindowContentRegionWidth()
{
- ImGuiContext& g = *GImGui;
- OpenPopupEx(g.CurrentWindow->GetID(str_id));
+ ImGuiWindow* window = GImGui->CurrentWindow;
+ return window->ContentRegionRect.GetWidth();
}
-// Mark popup as open (toggle toward open state).
-// Popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block.
-// Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
-// One open popup per level of the popup hierarchy (NB: when assigning we reset the Window member of ImGuiPopupRef to NULL)
-void ImGui::OpenPopupEx(ImGuiID id)
+// Lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)
+void ImGui::BeginGroup()
{
ImGuiContext& g = *GImGui;
- ImGuiWindow* parent_window = g.CurrentWindow;
- int current_stack_size = g.BeginPopupStack.Size;
- ImGuiPopupData popup_ref; // Tagged as new ref as Window will be set back to NULL if we write this into OpenPopupStack.
- popup_ref.PopupId = id;
- popup_ref.Window = NULL;
- popup_ref.SourceWindow = g.NavWindow;
- popup_ref.OpenFrameCount = g.FrameCount;
- popup_ref.OpenParentId = parent_window->IDStack.back();
- popup_ref.OpenPopupPos = NavCalcPreferredRefPos();
- popup_ref.OpenMousePos = IsMousePosValid(&g.IO.MousePos) ? g.IO.MousePos : popup_ref.OpenPopupPos;
+ ImGuiWindow* window = GetCurrentWindow();
- //IMGUI_DEBUG_LOG("OpenPopupEx(0x%08X)\n", g.FrameCount, id);
- if (g.OpenPopupStack.Size < current_stack_size + 1)
- {
- g.OpenPopupStack.push_back(popup_ref);
- }
- else
- {
- // Gently handle the user mistakenly calling OpenPopup() every frame. It is a programming mistake! However, if we were to run the regular code path, the ui
- // would become completely unusable because the popup will always be in hidden-while-calculating-size state _while_ claiming focus. Which would be a very confusing
- // situation for the programmer. Instead, we silently allow the popup to proceed, it will keep reappearing and the programming error will be more obvious to understand.
- if (g.OpenPopupStack[current_stack_size].PopupId == id && g.OpenPopupStack[current_stack_size].OpenFrameCount == g.FrameCount - 1)
- {
- g.OpenPopupStack[current_stack_size].OpenFrameCount = popup_ref.OpenFrameCount;
- }
- else
- {
- // Close child popups if any, then flag popup for open/reopen
- g.OpenPopupStack.resize(current_stack_size + 1);
- g.OpenPopupStack[current_stack_size] = popup_ref;
- }
+ window->DC.GroupStack.resize(window->DC.GroupStack.Size + 1);
+ ImGuiGroupData& group_data = window->DC.GroupStack.back();
+ group_data.BackupCursorPos = window->DC.CursorPos;
+ group_data.BackupCursorMaxPos = window->DC.CursorMaxPos;
+ group_data.BackupIndent = window->DC.Indent;
+ group_data.BackupGroupOffset = window->DC.GroupOffset;
+ group_data.BackupCurrLineSize = window->DC.CurrLineSize;
+ group_data.BackupCurrLineTextBaseOffset = window->DC.CurrLineTextBaseOffset;
+ group_data.BackupActiveIdIsAlive = g.ActiveIdIsAlive;
+ group_data.BackupActiveIdPreviousFrameIsAlive = g.ActiveIdPreviousFrameIsAlive;
+ group_data.EmitItem = true;
- // When reopening a popup we first refocus its parent, otherwise if its parent is itself a popup it would get closed by ClosePopupsOverWindow().
- // This is equivalent to what ClosePopupToLevel() does.
- //if (g.OpenPopupStack[current_stack_size].PopupId == id)
- // FocusWindow(parent_window);
- }
+ window->DC.GroupOffset.x = window->DC.CursorPos.x - window->Pos.x - window->DC.ColumnsOffset.x;
+ window->DC.Indent = window->DC.GroupOffset;
+ window->DC.CursorMaxPos = window->DC.CursorPos;
+ window->DC.CurrLineSize = ImVec2(0.0f, 0.0f);
+ if (g.LogEnabled)
+ g.LogLinePosY = -FLT_MAX; // To enforce Log carriage return
}
-void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup)
+void ImGui::EndGroup()
{
ImGuiContext& g = *GImGui;
- if (g.OpenPopupStack.empty())
- return;
+ ImGuiWindow* window = GetCurrentWindow();
+ IM_ASSERT(!window->DC.GroupStack.empty()); // Mismatched BeginGroup()/EndGroup() calls
- // When popups are stacked, clicking on a lower level popups puts focus back to it and close popups above it.
- // Don't close our own child popup windows.
- int popup_count_to_keep = 0;
- if (ref_window)
+ ImGuiGroupData& group_data = window->DC.GroupStack.back();
+
+ ImRect group_bb(group_data.BackupCursorPos, ImMax(window->DC.CursorMaxPos, group_data.BackupCursorPos));
+
+ window->DC.CursorPos = group_data.BackupCursorPos;
+ window->DC.CursorMaxPos = ImMax(group_data.BackupCursorMaxPos, window->DC.CursorMaxPos);
+ window->DC.Indent = group_data.BackupIndent;
+ window->DC.GroupOffset = group_data.BackupGroupOffset;
+ window->DC.CurrLineSize = group_data.BackupCurrLineSize;
+ window->DC.CurrLineTextBaseOffset = group_data.BackupCurrLineTextBaseOffset;
+ if (g.LogEnabled)
+ g.LogLinePosY = -FLT_MAX; // To enforce Log carriage return
+
+ if (!group_data.EmitItem)
{
- // Find the highest popup which is a descendant of the reference window (generally reference window = NavWindow)
- for (; popup_count_to_keep < g.OpenPopupStack.Size; popup_count_to_keep++)
- {
- ImGuiPopupData& popup = g.OpenPopupStack[popup_count_to_keep];
- if (!popup.Window)
- continue;
- IM_ASSERT((popup.Window->Flags & ImGuiWindowFlags_Popup) != 0);
- if (popup.Window->Flags & ImGuiWindowFlags_ChildWindow)
- continue;
+ window->DC.GroupStack.pop_back();
+ return;
+ }
- // Trim the stack when popups are not direct descendant of the reference window (the reference window is often the NavWindow)
- bool popup_or_descendent_is_ref_window = false;
- for (int m = popup_count_to_keep; m < g.OpenPopupStack.Size && !popup_or_descendent_is_ref_window; m++)
- if (ImGuiWindow* popup_window = g.OpenPopupStack[m].Window)
- if (popup_window->RootWindow == ref_window->RootWindow)
- popup_or_descendent_is_ref_window = true;
- if (!popup_or_descendent_is_ref_window)
- break;
- }
- }
- if (popup_count_to_keep < g.OpenPopupStack.Size) // This test is not required but it allows to set a convenient breakpoint on the statement below
- {
- //IMGUI_DEBUG_LOG("ClosePopupsOverWindow(%s) -> ClosePopupToLevel(%d)\n", ref_window->Name, popup_count_to_keep);
- ClosePopupToLevel(popup_count_to_keep, restore_focus_to_window_under_popup);
- }
-}
-
-void ImGui::ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup)
-{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(remaining >= 0 && remaining < g.OpenPopupStack.Size);
- ImGuiWindow* focus_window = g.OpenPopupStack[remaining].SourceWindow;
- ImGuiWindow* popup_window = g.OpenPopupStack[remaining].Window;
- g.OpenPopupStack.resize(remaining);
-
- if (restore_focus_to_window_under_popup)
- {
- if (focus_window && !focus_window->WasActive && popup_window)
- {
- // Fallback
- FocusTopMostWindowUnderOne(popup_window, NULL);
- }
- else
- {
- if (g.NavLayer == 0 && focus_window)
- focus_window = NavRestoreLastChildNavWindow(focus_window);
- FocusWindow(focus_window);
- }
- }
-}
-
-// Close the popup we have begin-ed into.
-void ImGui::CloseCurrentPopup()
-{
- ImGuiContext& g = *GImGui;
- int popup_idx = g.BeginPopupStack.Size - 1;
- if (popup_idx < 0 || popup_idx >= g.OpenPopupStack.Size || g.BeginPopupStack[popup_idx].PopupId != g.OpenPopupStack[popup_idx].PopupId)
- return;
-
- // Closing a menu closes its top-most parent popup (unless a modal)
- while (popup_idx > 0)
- {
- ImGuiWindow* popup_window = g.OpenPopupStack[popup_idx].Window;
- ImGuiWindow* parent_popup_window = g.OpenPopupStack[popup_idx - 1].Window;
- bool close_parent = false;
- if (popup_window && (popup_window->Flags & ImGuiWindowFlags_ChildMenu))
- if (parent_popup_window == NULL || !(parent_popup_window->Flags & ImGuiWindowFlags_Modal))
- close_parent = true;
- if (!close_parent)
- break;
- popup_idx--;
- }
- //IMGUI_DEBUG_LOG("CloseCurrentPopup %d -> %d\n", g.BeginPopupStack.Size - 1, popup_idx);
- ClosePopupToLevel(popup_idx, true);
-
- // A common pattern is to close a popup when selecting a menu item/selectable that will open another window.
- // To improve this usage pattern, we avoid nav highlight for a single frame in the parent window.
- // Similarly, we could avoid mouse hover highlight in this window but it is less visually problematic.
- if (ImGuiWindow* window = g.NavWindow)
- window->DC.NavHideHighlightOneFrame = true;
-}
-
-bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags flags)
-{
- ImGuiContext& g = *GImGui;
- if (!IsPopupOpen(id))
- {
- g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
- return false;
- }
-
- char name[20];
- if (flags & ImGuiWindowFlags_ChildMenu)
- ImFormatString(name, IM_ARRAYSIZE(name), "##Menu_%02d", g.BeginPopupStack.Size); // Recycle windows based on depth
- else
- ImFormatString(name, IM_ARRAYSIZE(name), "##Popup_%08x", id); // Not recycling, so we can close/open during the same frame
-
- flags |= ImGuiWindowFlags_Popup | ImGuiWindowFlags_NoDocking;
- bool is_open = Begin(name, NULL, flags);
- if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display)
- EndPopup();
-
- return is_open;
-}
-
-bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags)
-{
- ImGuiContext& g = *GImGui;
- if (g.OpenPopupStack.Size <= g.BeginPopupStack.Size) // Early out for performance
- {
- g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
- return false;
- }
- flags |= ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings;
- return BeginPopupEx(g.CurrentWindow->GetID(str_id), flags);
-}
-
-// If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup.
-// Note that popup visibility status is owned by Dear ImGui (and manipulated with e.g. OpenPopup) so the actual value of *p_open is meaningless here.
-bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags flags)
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
- const ImGuiID id = window->GetID(name);
- if (!IsPopupOpen(id))
- {
- g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
- return false;
- }
-
- // Center modal windows by default
- // FIXME: Should test for (PosCond & window->SetWindowPosAllowFlags) with the upcoming window.
- if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) == 0)
- {
- ImGuiViewportP* viewport = window->WasActive ? window->Viewport : (ImGuiViewportP*)GetMainViewport(); // FIXME-VIEWPORT: What may be our reference viewport?
- SetNextWindowPos(viewport->GetCenter(), ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
- }
-
- flags |= ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoDocking;
- const bool is_open = Begin(name, p_open, flags);
- if (!is_open || (p_open && !*p_open)) // NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
- {
- EndPopup();
- if (is_open)
- ClosePopupToLevel(g.BeginPopupStack.Size, true);
- return false;
- }
- return is_open;
-}
-
-void ImGui::EndPopup()
-{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(g.CurrentWindow->Flags & ImGuiWindowFlags_Popup); // Mismatched BeginPopup()/EndPopup() calls
- IM_ASSERT(g.BeginPopupStack.Size > 0);
-
- // Make all menus and popups wrap around for now, may need to expose that policy.
- NavMoveRequestTryWrapping(g.CurrentWindow, ImGuiNavMoveFlags_LoopY);
-
- End();
-}
-
-bool ImGui::OpenPopupOnItemClick(const char* str_id, int mouse_button)
-{
- ImGuiWindow* window = GImGui->CurrentWindow;
- if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
- {
- ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
- IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
- OpenPopupEx(id);
- return true;
- }
- return false;
-}
-
-// This is a helper to handle the simplest case of associating one named popup to one given widget.
-// You may want to handle this on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters).
-// You can pass a NULL str_id to use the identifier of the last item.
-bool ImGui::BeginPopupContextItem(const char* str_id, int mouse_button)
-{
- ImGuiWindow* window = GImGui->CurrentWindow;
- if (window->SkipItems)
- return false;
- ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
- IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
- if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
- OpenPopupEx(id);
- return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
-}
-
-bool ImGui::BeginPopupContextWindow(const char* str_id, int mouse_button, bool also_over_items)
-{
- if (!str_id)
- str_id = "window_context";
- ImGuiID id = GImGui->CurrentWindow->GetID(str_id);
- if (IsMouseReleased(mouse_button) && IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
- if (also_over_items || !IsAnyItemHovered())
- OpenPopupEx(id);
- return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
-}
-
-bool ImGui::BeginPopupContextVoid(const char* str_id, int mouse_button)
-{
- if (!str_id)
- str_id = "void_context";
- ImGuiID id = GImGui->CurrentWindow->GetID(str_id);
- if (IsMouseReleased(mouse_button) && !IsWindowHovered(ImGuiHoveredFlags_AnyWindow))
- OpenPopupEx(id);
- return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
-}
-
-// r_avoid = the rectangle to avoid (e.g. for tooltip it is a rectangle around the mouse cursor which we want to avoid. for popups it's a small point around the cursor.)
-// r_outer = the visible area rectangle, minus safe area padding. If our popup size won't fit because of safe area padding we ignore it.
-// (r_outer is usually equivalent to the viewport rectangle minus padding, but when multi-viewports are enabled and monitor
-// information are available, it may represent the entire platform monitor from the frame of reference of the current viewport.
-// this allows us to have tooltips/popups displayed out of the parent viewport.)
-ImVec2 ImGui::FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy)
-{
- ImVec2 base_pos_clamped = ImClamp(ref_pos, r_outer.Min, r_outer.Max - size);
- //GetForegroundDrawList()->AddRect(r_avoid.Min, r_avoid.Max, IM_COL32(255,0,0,255));
- //GetForegroundDrawList()->AddRect(r_outer.Min, r_outer.Max, IM_COL32(0,255,0,255));
-
- // Combo Box policy (we want a connecting edge)
- if (policy == ImGuiPopupPositionPolicy_ComboBox)
- {
- const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Down, ImGuiDir_Right, ImGuiDir_Left, ImGuiDir_Up };
- for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++)
- {
- const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n];
- if (n != -1 && dir == *last_dir) // Already tried this direction?
- continue;
- ImVec2 pos;
- if (dir == ImGuiDir_Down) pos = ImVec2(r_avoid.Min.x, r_avoid.Max.y); // Below, Toward Right (default)
- if (dir == ImGuiDir_Right) pos = ImVec2(r_avoid.Min.x, r_avoid.Min.y - size.y); // Above, Toward Right
- if (dir == ImGuiDir_Left) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Max.y); // Below, Toward Left
- if (dir == ImGuiDir_Up) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Min.y - size.y); // Above, Toward Left
- if (!r_outer.Contains(ImRect(pos, pos + size)))
- continue;
- *last_dir = dir;
- return pos;
- }
- }
-
- // Default popup policy
- const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Right, ImGuiDir_Down, ImGuiDir_Up, ImGuiDir_Left };
- for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++)
- {
- const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n];
- if (n != -1 && dir == *last_dir) // Already tried this direction?
- continue;
- float avail_w = (dir == ImGuiDir_Left ? r_avoid.Min.x : r_outer.Max.x) - (dir == ImGuiDir_Right ? r_avoid.Max.x : r_outer.Min.x);
- float avail_h = (dir == ImGuiDir_Up ? r_avoid.Min.y : r_outer.Max.y) - (dir == ImGuiDir_Down ? r_avoid.Max.y : r_outer.Min.y);
- if (avail_w < size.x || avail_h < size.y)
- continue;
- ImVec2 pos;
- pos.x = (dir == ImGuiDir_Left) ? r_avoid.Min.x - size.x : (dir == ImGuiDir_Right) ? r_avoid.Max.x : base_pos_clamped.x;
- pos.y = (dir == ImGuiDir_Up) ? r_avoid.Min.y - size.y : (dir == ImGuiDir_Down) ? r_avoid.Max.y : base_pos_clamped.y;
- *last_dir = dir;
- return pos;
- }
-
- // Fallback, try to keep within display
- *last_dir = ImGuiDir_None;
- ImVec2 pos = ref_pos;
- pos.x = ImMax(ImMin(pos.x + size.x, r_outer.Max.x) - size.x, r_outer.Min.x);
- pos.y = ImMax(ImMin(pos.y + size.y, r_outer.Max.y) - size.y, r_outer.Min.y);
- return pos;
-}
-
-ImRect ImGui::GetWindowAllowedExtentRect(ImGuiWindow* window)
-{
- ImGuiContext& g = *GImGui;
- ImRect r_screen;
- if (window->ViewportAllowPlatformMonitorExtend >= 0)
- {
- // Extent with be in the frame of reference of the given viewport (so Min is likely to be negative here)
- const ImGuiPlatformMonitor& monitor = g.PlatformIO.Monitors[window->ViewportAllowPlatformMonitorExtend];
- r_screen.Min = monitor.WorkPos;
- r_screen.Max = monitor.WorkPos + monitor.WorkSize;
- }
- else
- {
- r_screen.Min = window->Viewport->Pos;
- r_screen.Max = window->Viewport->Pos + window->Viewport->Size;
- }
- ImVec2 padding = g.Style.DisplaySafeAreaPadding;
- r_screen.Expand(ImVec2((r_screen.GetWidth() > padding.x * 2) ? -padding.x : 0.0f, (r_screen.GetHeight() > padding.y * 2) ? -padding.y : 0.0f));
- return r_screen;
-}
-
-ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window)
-{
- ImGuiContext& g = *GImGui;
- if (window->Flags & ImGuiWindowFlags_ChildMenu)
- {
- // Child menus typically request _any_ position within the parent menu item, and then we move the new menu outside the parent bounds.
- // This is how we end up with child menus appearing (most-commonly) on the right of the parent menu.
- ImGuiWindow* parent_window = window->ParentWindow;
- float horizontal_overlap = g.Style.ItemInnerSpacing.x; // We want some overlap to convey the relative depth of each menu (currently the amount of overlap is hard-coded to style.ItemSpacing.x).
- ImRect r_outer = GetWindowAllowedExtentRect(window);
- ImRect r_avoid;
- if (parent_window->DC.MenuBarAppending)
- r_avoid = ImRect(-FLT_MAX, parent_window->Pos.y + parent_window->TitleBarHeight(), FLT_MAX, parent_window->Pos.y + parent_window->TitleBarHeight() + parent_window->MenuBarHeight());
- else
- r_avoid = ImRect(parent_window->Pos.x + horizontal_overlap, -FLT_MAX, parent_window->Pos.x + parent_window->Size.x - horizontal_overlap - parent_window->ScrollbarSizes.x, FLT_MAX);
- return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
- }
- if (window->Flags & ImGuiWindowFlags_Popup)
- {
- ImRect r_outer = GetWindowAllowedExtentRect(window);
- ImRect r_avoid = ImRect(window->Pos.x - 1, window->Pos.y - 1, window->Pos.x + 1, window->Pos.y + 1);
- return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
- }
- if (window->Flags & ImGuiWindowFlags_Tooltip)
- {
- // Position tooltip (always follows mouse)
- float sc = g.Style.MouseCursorScale;
- ImVec2 ref_pos = NavCalcPreferredRefPos();
- ImRect r_outer = GetWindowAllowedExtentRect(window);
- ImRect r_avoid;
- if (!g.NavDisableHighlight && g.NavDisableMouseHover && !(g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos))
- r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 16, ref_pos.y + 8);
- else
- r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 24 * sc, ref_pos.y + 24 * sc); // FIXME: Hard-coded based on mouse cursor shape expectation. Exact dimension not very important.
- ImVec2 pos = FindBestWindowPosForPopupEx(ref_pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
- if (window->AutoPosLastDirection == ImGuiDir_None)
- pos = ref_pos + ImVec2(2, 2); // If there's not enough room, for tooltip we prefer avoiding the cursor at all cost even if it means that part of the tooltip won't be visible.
- return pos;
- }
- IM_ASSERT(0);
- return window->Pos;
-}
-
-
-//-----------------------------------------------------------------------------
-// [SECTION] KEYBOARD/GAMEPAD NAVIGATION
-//-----------------------------------------------------------------------------
-
-ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy)
-{
- if (ImFabs(dx) > ImFabs(dy))
- return (dx > 0.0f) ? ImGuiDir_Right : ImGuiDir_Left;
- return (dy > 0.0f) ? ImGuiDir_Down : ImGuiDir_Up;
-}
-
-static float inline NavScoreItemDistInterval(float a0, float a1, float b0, float b1)
-{
- if (a1 < b0)
- return a1 - b0;
- if (b1 < a0)
- return a0 - b1;
- return 0.0f;
-}
-
-static void inline NavClampRectToVisibleAreaForMoveDir(ImGuiDir move_dir, ImRect& r, const ImRect& clip_rect)
-{
- if (move_dir == ImGuiDir_Left || move_dir == ImGuiDir_Right)
- {
- r.Min.y = ImClamp(r.Min.y, clip_rect.Min.y, clip_rect.Max.y);
- r.Max.y = ImClamp(r.Max.y, clip_rect.Min.y, clip_rect.Max.y);
- }
- else
- {
- r.Min.x = ImClamp(r.Min.x, clip_rect.Min.x, clip_rect.Max.x);
- r.Max.x = ImClamp(r.Max.x, clip_rect.Min.x, clip_rect.Max.x);
- }
-}
-
-// Scoring function for directional navigation. Based on https://gist.github.com/rygorous/6981057
-static bool ImGui::NavScoreItem(ImGuiNavMoveResult* result, ImRect cand)
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
- if (g.NavLayer != window->DC.NavLayerCurrent)
- return false;
-
- const ImRect& curr = g.NavScoringRectScreen; // Current modified source rect (NB: we've applied Max.x = Min.x in NavUpdate() to inhibit the effect of having varied item width)
- g.NavScoringCount++;
-
- // When entering through a NavFlattened border, we consider child window items as fully clipped for scoring
- if (window->ParentWindow == g.NavWindow)
- {
- IM_ASSERT((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened);
- if (!window->ClipRect.Overlaps(cand))
- return false;
- cand.ClipWithFull(window->ClipRect); // This allows the scored item to not overlap other candidates in the parent window
- }
-
- // We perform scoring on items bounding box clipped by the current clipping rectangle on the other axis (clipping on our movement axis would give us equal scores for all clipped items)
- // For example, this ensure that items in one column are not reached when moving vertically from items in another column.
- NavClampRectToVisibleAreaForMoveDir(g.NavMoveClipDir, cand, window->ClipRect);
-
- // Compute distance between boxes
- // FIXME-NAV: Introducing biases for vertical navigation, needs to be removed.
- float dbx = NavScoreItemDistInterval(cand.Min.x, cand.Max.x, curr.Min.x, curr.Max.x);
- float dby = NavScoreItemDistInterval(ImLerp(cand.Min.y, cand.Max.y, 0.2f), ImLerp(cand.Min.y, cand.Max.y, 0.8f), ImLerp(curr.Min.y, curr.Max.y, 0.2f), ImLerp(curr.Min.y, curr.Max.y, 0.8f)); // Scale down on Y to keep using box-distance for vertically touching items
- if (dby != 0.0f && dbx != 0.0f)
- dbx = (dbx/1000.0f) + ((dbx > 0.0f) ? +1.0f : -1.0f);
- float dist_box = ImFabs(dbx) + ImFabs(dby);
-
- // Compute distance between centers (this is off by a factor of 2, but we only compare center distances with each other so it doesn't matter)
- float dcx = (cand.Min.x + cand.Max.x) - (curr.Min.x + curr.Max.x);
- float dcy = (cand.Min.y + cand.Max.y) - (curr.Min.y + curr.Max.y);
- float dist_center = ImFabs(dcx) + ImFabs(dcy); // L1 metric (need this for our connectedness guarantee)
-
- // Determine which quadrant of 'curr' our candidate item 'cand' lies in based on distance
- ImGuiDir quadrant;
- float dax = 0.0f, day = 0.0f, dist_axial = 0.0f;
- if (dbx != 0.0f || dby != 0.0f)
- {
- // For non-overlapping boxes, use distance between boxes
- dax = dbx;
- day = dby;
- dist_axial = dist_box;
- quadrant = ImGetDirQuadrantFromDelta(dbx, dby);
- }
- else if (dcx != 0.0f || dcy != 0.0f)
- {
- // For overlapping boxes with different centers, use distance between centers
- dax = dcx;
- day = dcy;
- dist_axial = dist_center;
- quadrant = ImGetDirQuadrantFromDelta(dcx, dcy);
- }
- else
- {
- // Degenerate case: two overlapping buttons with same center, break ties arbitrarily (note that LastItemId here is really the _previous_ item order, but it doesn't matter)
- quadrant = (window->DC.LastItemId < g.NavId) ? ImGuiDir_Left : ImGuiDir_Right;
- }
-
-#if IMGUI_DEBUG_NAV_SCORING
- char buf[128];
- if (IsMouseHoveringRect(cand.Min, cand.Max))
- {
- ImFormatString(buf, IM_ARRAYSIZE(buf), "dbox (%.2f,%.2f->%.4f)\ndcen (%.2f,%.2f->%.4f)\nd (%.2f,%.2f->%.4f)\nnav %c, quadrant %c", dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial, "WENS"[g.NavMoveDir], "WENS"[quadrant]);
- ImDrawList* draw_list = GetForegroundDrawList(window);
- draw_list->AddRect(curr.Min, curr.Max, IM_COL32(255,200,0,100));
- draw_list->AddRect(cand.Min, cand.Max, IM_COL32(255,255,0,200));
- draw_list->AddRectFilled(cand.Max - ImVec2(4,4), cand.Max + CalcTextSize(buf) + ImVec2(4,4), IM_COL32(40,0,0,150));
- draw_list->AddText(g.IO.FontDefault, 13.0f, cand.Max, ~0U, buf);
- }
- else if (g.IO.KeyCtrl) // Hold to preview score in matching quadrant. Press C to rotate.
- {
- if (IsKeyPressedMap(ImGuiKey_C)) { g.NavMoveDirLast = (ImGuiDir)((g.NavMoveDirLast + 1) & 3); g.IO.KeysDownDuration[g.IO.KeyMap[ImGuiKey_C]] = 0.01f; }
- if (quadrant == g.NavMoveDir)
- {
- ImFormatString(buf, IM_ARRAYSIZE(buf), "%.0f/%.0f", dist_box, dist_center);
- ImDrawList* draw_list = GetForegroundDrawList(window);
- draw_list->AddRectFilled(cand.Min, cand.Max, IM_COL32(255, 0, 0, 200));
- draw_list->AddText(g.IO.FontDefault, 13.0f, cand.Min, IM_COL32(255, 255, 255, 255), buf);
- }
- }
- #endif
-
- // Is it in the quadrant we're interesting in moving to?
- bool new_best = false;
- if (quadrant == g.NavMoveDir)
- {
- // Does it beat the current best candidate?
- if (dist_box < result->DistBox)
- {
- result->DistBox = dist_box;
- result->DistCenter = dist_center;
- return true;
- }
- if (dist_box == result->DistBox)
- {
- // Try using distance between center points to break ties
- if (dist_center < result->DistCenter)
- {
- result->DistCenter = dist_center;
- new_best = true;
- }
- else if (dist_center == result->DistCenter)
- {
- // Still tied! we need to be extra-careful to make sure everything gets linked properly. We consistently break ties by symbolically moving "later" items
- // (with higher index) to the right/downwards by an infinitesimal amount since we the current "best" button already (so it must have a lower index),
- // this is fairly easy. This rule ensures that all buttons with dx==dy==0 will end up being linked in order of appearance along the x axis.
- if (((g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? dby : dbx) < 0.0f) // moving bj to the right/down decreases distance
- new_best = true;
- }
- }
- }
-
- // Axial check: if 'curr' has no link at all in some direction and 'cand' lies roughly in that direction, add a tentative link. This will only be kept if no "real" matches
- // are found, so it only augments the graph produced by the above method using extra links. (important, since it doesn't guarantee strong connectedness)
- // This is just to avoid buttons having no links in a particular direction when there's a suitable neighbor. you get good graphs without this too.
- // 2017/09/29: FIXME: This now currently only enabled inside menu bars, ideally we'd disable it everywhere. Menus in particular need to catch failure. For general navigation it feels awkward.
- // Disabling it may lead to disconnected graphs when nodes are very spaced out on different axis. Perhaps consider offering this as an option?
- if (result->DistBox == FLT_MAX && dist_axial < result->DistAxial) // Check axial match
- if (g.NavLayer == 1 && !(g.NavWindow->Flags & ImGuiWindowFlags_ChildMenu))
- if ((g.NavMoveDir == ImGuiDir_Left && dax < 0.0f) || (g.NavMoveDir == ImGuiDir_Right && dax > 0.0f) || (g.NavMoveDir == ImGuiDir_Up && day < 0.0f) || (g.NavMoveDir == ImGuiDir_Down && day > 0.0f))
- {
- result->DistAxial = dist_axial;
- new_best = true;
- }
-
- return new_best;
-}
-
-// We get there when either NavId == id, or when g.NavAnyRequest is set (which is updated by NavUpdateAnyRequestFlag above)
-static void ImGui::NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, const ImGuiID id)
-{
- ImGuiContext& g = *GImGui;
- //if (!g.IO.NavActive) // [2017/10/06] Removed this possibly redundant test but I am not sure of all the side-effects yet. Some of the feature here will need to work regardless of using a _NoNavInputs flag.
- // return;
-
- const ImGuiItemFlags item_flags = window->DC.ItemFlags;
- const ImRect nav_bb_rel(nav_bb.Min - window->Pos, nav_bb.Max - window->Pos);
-
- // Process Init Request
- if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent)
- {
- // Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback
- if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus) || g.NavInitResultId == 0)
- {
- g.NavInitResultId = id;
- g.NavInitResultRectRel = nav_bb_rel;
- }
- if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus))
- {
- g.NavInitRequest = false; // Found a match, clear request
- NavUpdateAnyRequestFlag();
- }
- }
-
- // Process Move Request (scoring for navigation)
- // FIXME-NAV: Consider policy for double scoring (scoring from NavScoringRectScreen + scoring from a rect wrapped according to current wrapping policy)
- if ((g.NavId != id || (g.NavMoveRequestFlags & ImGuiNavMoveFlags_AllowCurrentNavId)) && !(item_flags & (ImGuiItemFlags_Disabled|ImGuiItemFlags_NoNav)))
- {
- ImGuiNavMoveResult* result = (window == g.NavWindow) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;
-#if IMGUI_DEBUG_NAV_SCORING
- // [DEBUG] Score all items in NavWindow at all times
- if (!g.NavMoveRequest)
- g.NavMoveDir = g.NavMoveDirLast;
- bool new_best = NavScoreItem(result, nav_bb) && g.NavMoveRequest;
-#else
- bool new_best = g.NavMoveRequest && NavScoreItem(result, nav_bb);
-#endif
- if (new_best)
- {
- result->ID = id;
- result->SelectScopeId = g.MultiSelectScopeId;
- result->Window = window;
- result->RectRel = nav_bb_rel;
- }
-
- const float VISIBLE_RATIO = 0.70f;
- if ((g.NavMoveRequestFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb))
- if (ImClamp(nav_bb.Max.y, window->ClipRect.Min.y, window->ClipRect.Max.y) - ImClamp(nav_bb.Min.y, window->ClipRect.Min.y, window->ClipRect.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO)
- if (NavScoreItem(&g.NavMoveResultLocalVisibleSet, nav_bb))
- {
- result = &g.NavMoveResultLocalVisibleSet;
- result->ID = id;
- result->SelectScopeId = g.MultiSelectScopeId;
- result->Window = window;
- result->RectRel = nav_bb_rel;
- }
- }
-
- // Update window-relative bounding box of navigated item
- if (g.NavId == id)
- {
- g.NavWindow = window; // Always refresh g.NavWindow, because some operations such as FocusItem() don't have a window.
- g.NavLayer = window->DC.NavLayerCurrent;
- g.NavIdIsAlive = true;
- g.NavIdTabCounter = window->DC.FocusCounterTab;
- window->NavRectRel[window->DC.NavLayerCurrent] = nav_bb_rel; // Store item bounding box (relative to window position)
- }
-}
-
-bool ImGui::NavMoveRequestButNoResultYet()
-{
- ImGuiContext& g = *GImGui;
- return g.NavMoveRequest && g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0;
-}
-
-void ImGui::NavMoveRequestCancel()
-{
- ImGuiContext& g = *GImGui;
- g.NavMoveRequest = false;
- NavUpdateAnyRequestFlag();
-}
-
-void ImGui::NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, const ImRect& bb_rel, ImGuiNavMoveFlags move_flags)
-{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(g.NavMoveRequestForward == ImGuiNavForward_None);
- NavMoveRequestCancel();
- g.NavMoveDir = move_dir;
- g.NavMoveClipDir = clip_dir;
- g.NavMoveRequestForward = ImGuiNavForward_ForwardQueued;
- g.NavMoveRequestFlags = move_flags;
- g.NavWindow->NavRectRel[g.NavLayer] = bb_rel;
-}
-
-void ImGui::NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags)
-{
- ImGuiContext& g = *GImGui;
- if (g.NavWindow != window || !NavMoveRequestButNoResultYet() || g.NavMoveRequestForward != ImGuiNavForward_None || g.NavLayer != 0)
- return;
- IM_ASSERT(move_flags != 0); // No points calling this with no wrapping
- ImRect bb_rel = window->NavRectRel[0];
-
- ImGuiDir clip_dir = g.NavMoveDir;
- if (g.NavMoveDir == ImGuiDir_Left && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX)))
- {
- bb_rel.Min.x = bb_rel.Max.x = ImMax(window->SizeFull.x, window->ContentSize.x + window->WindowPadding.x * 2.0f) - window->Scroll.x;
- if (move_flags & ImGuiNavMoveFlags_WrapX) { bb_rel.TranslateY(-bb_rel.GetHeight()); clip_dir = ImGuiDir_Up; }
- NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags);
- }
- if (g.NavMoveDir == ImGuiDir_Right && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX)))
- {
- bb_rel.Min.x = bb_rel.Max.x = -window->Scroll.x;
- if (move_flags & ImGuiNavMoveFlags_WrapX) { bb_rel.TranslateY(+bb_rel.GetHeight()); clip_dir = ImGuiDir_Down; }
- NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags);
- }
- if (g.NavMoveDir == ImGuiDir_Up && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY)))
- {
- bb_rel.Min.y = bb_rel.Max.y = ImMax(window->SizeFull.y, window->ContentSize.y + window->WindowPadding.y * 2.0f) - window->Scroll.y;
- if (move_flags & ImGuiNavMoveFlags_WrapY) { bb_rel.TranslateX(-bb_rel.GetWidth()); clip_dir = ImGuiDir_Left; }
- NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags);
- }
- if (g.NavMoveDir == ImGuiDir_Down && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY)))
- {
- bb_rel.Min.y = bb_rel.Max.y = -window->Scroll.y;
- if (move_flags & ImGuiNavMoveFlags_WrapY) { bb_rel.TranslateX(+bb_rel.GetWidth()); clip_dir = ImGuiDir_Right; }
- NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags);
- }
-}
-
-// FIXME: This could be replaced by updating a frame number in each window when (window == NavWindow) and (NavLayer == 0).
-// This way we could find the last focused window among our children. It would be much less confusing this way?
-static void ImGui::NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_window)
-{
- ImGuiWindow* parent_window = nav_window;
- while (parent_window && (parent_window->Flags & ImGuiWindowFlags_ChildWindow) != 0 && (parent_window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0)
- parent_window = parent_window->ParentWindow;
- if (parent_window && parent_window != nav_window)
- parent_window->NavLastChildNavWindow = nav_window;
-}
-
-// Restore the last focused child.
-// Call when we are expected to land on the Main Layer (0) after FocusWindow()
-static ImGuiWindow* ImGui::NavRestoreLastChildNavWindow(ImGuiWindow* window)
-{
- if (window->NavLastChildNavWindow && window->NavLastChildNavWindow->WasActive)
- return window->NavLastChildNavWindow;
- if (window->DockNodeAsHost && window->DockNodeAsHost->TabBar)
- if (ImGuiTabItem* tab = TabBarFindMostRecentlySelectedTabForActiveWindow(window->DockNodeAsHost->TabBar))
- return tab->Window;
- return window;
-}
-
-static void NavRestoreLayer(ImGuiNavLayer layer)
-{
- ImGuiContext& g = *GImGui;
- g.NavLayer = layer;
- if (layer == 0)
- g.NavWindow = ImGui::NavRestoreLastChildNavWindow(g.NavWindow);
- if (g.NavWindow->NavLastIds[layer] != 0)
- ImGui::SetNavIDWithRectRel(g.NavWindow->NavLastIds[layer], layer, g.NavWindow->NavRectRel[layer]);
- else
- ImGui::NavInitWindow(g.NavWindow, true);
-}
-
-static inline void ImGui::NavUpdateAnyRequestFlag()
-{
- ImGuiContext& g = *GImGui;
- g.NavAnyRequest = g.NavMoveRequest || g.NavInitRequest || (IMGUI_DEBUG_NAV_SCORING && g.NavWindow != NULL);
- if (g.NavAnyRequest)
- IM_ASSERT(g.NavWindow != NULL);
-}
-
-// This needs to be called before we submit any widget (aka in or before Begin)
-void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit)
-{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(window == g.NavWindow);
- bool init_for_nav = false;
- if (!(window->Flags & ImGuiWindowFlags_NoNavInputs))
- if (!(window->Flags & ImGuiWindowFlags_ChildWindow) || (window->Flags & ImGuiWindowFlags_Popup) || (window->NavLastIds[0] == 0) || force_reinit)
- init_for_nav = true;
- //IMGUI_DEBUG_LOG("[Nav] NavInitWindow() init_for_nav=%d, window=\"%s\", layer=%d\n", init_for_nav, window->Name, g.NavLayer);
- if (init_for_nav)
- {
- SetNavID(0, g.NavLayer);
- g.NavInitRequest = true;
- g.NavInitRequestFromMove = false;
- g.NavInitResultId = 0;
- g.NavInitResultRectRel = ImRect();
- NavUpdateAnyRequestFlag();
- }
- else
- {
- g.NavId = window->NavLastIds[0];
- }
-}
-
-static ImVec2 ImGui::NavCalcPreferredRefPos()
-{
- ImGuiContext& g = *GImGui;
- if (g.NavDisableHighlight || !g.NavDisableMouseHover || !g.NavWindow)
- {
- // Mouse (we need a fallback in case the mouse becomes invalid after being used)
- if (IsMousePosValid(&g.IO.MousePos))
- return g.IO.MousePos;
- return g.LastValidMousePos;
- }
- else
- {
- // When navigation is active and mouse is disabled, decide on an arbitrary position around the bottom left of the currently navigated item.
- const ImRect& rect_rel = g.NavWindow->NavRectRel[g.NavLayer];
- ImVec2 pos = g.NavWindow->Pos + ImVec2(rect_rel.Min.x + ImMin(g.Style.FramePadding.x * 4, rect_rel.GetWidth()), rect_rel.Max.y - ImMin(g.Style.FramePadding.y, rect_rel.GetHeight()));
- ImRect visible_rect = g.NavWindow->Viewport->GetRect();
- return ImFloor(ImClamp(pos, visible_rect.Min, visible_rect.Max)); // ImFloor() is important because non-integer mouse position application in back-end might be lossy and result in undesirable non-zero delta.
- }
-}
-
-float ImGui::GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode)
-{
- ImGuiContext& g = *GImGui;
- if (mode == ImGuiInputReadMode_Down)
- return g.IO.NavInputs[n]; // Instant, read analog input (0.0f..1.0f, as provided by user)
-
- const float t = g.IO.NavInputsDownDuration[n];
- if (t < 0.0f && mode == ImGuiInputReadMode_Released) // Return 1.0f when just released, no repeat, ignore analog input.
- return (g.IO.NavInputsDownDurationPrev[n] >= 0.0f ? 1.0f : 0.0f);
- if (t < 0.0f)
- return 0.0f;
- if (mode == ImGuiInputReadMode_Pressed) // Return 1.0f when just pressed, no repeat, ignore analog input.
- return (t == 0.0f) ? 1.0f : 0.0f;
- if (mode == ImGuiInputReadMode_Repeat)
- return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 0.72f, g.IO.KeyRepeatRate * 0.80f);
- if (mode == ImGuiInputReadMode_RepeatSlow)
- return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 1.25f, g.IO.KeyRepeatRate * 2.00f);
- if (mode == ImGuiInputReadMode_RepeatFast)
- return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 0.72f, g.IO.KeyRepeatRate * 0.30f);
- return 0.0f;
-}
-
-ImVec2 ImGui::GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor, float fast_factor)
-{
- ImVec2 delta(0.0f, 0.0f);
- if (dir_sources & ImGuiNavDirSourceFlags_Keyboard)
- delta += ImVec2(GetNavInputAmount(ImGuiNavInput_KeyRight_, mode) - GetNavInputAmount(ImGuiNavInput_KeyLeft_, mode), GetNavInputAmount(ImGuiNavInput_KeyDown_, mode) - GetNavInputAmount(ImGuiNavInput_KeyUp_, mode));
- if (dir_sources & ImGuiNavDirSourceFlags_PadDPad)
- delta += ImVec2(GetNavInputAmount(ImGuiNavInput_DpadRight, mode) - GetNavInputAmount(ImGuiNavInput_DpadLeft, mode), GetNavInputAmount(ImGuiNavInput_DpadDown, mode) - GetNavInputAmount(ImGuiNavInput_DpadUp, mode));
- if (dir_sources & ImGuiNavDirSourceFlags_PadLStick)
- delta += ImVec2(GetNavInputAmount(ImGuiNavInput_LStickRight, mode) - GetNavInputAmount(ImGuiNavInput_LStickLeft, mode), GetNavInputAmount(ImGuiNavInput_LStickDown, mode) - GetNavInputAmount(ImGuiNavInput_LStickUp, mode));
- if (slow_factor != 0.0f && IsNavInputDown(ImGuiNavInput_TweakSlow))
- delta *= slow_factor;
- if (fast_factor != 0.0f && IsNavInputDown(ImGuiNavInput_TweakFast))
- delta *= fast_factor;
- return delta;
-}
-
-static void ImGui::NavUpdate()
-{
- ImGuiContext& g = *GImGui;
- g.IO.WantSetMousePos = false;
-#if 0
- if (g.NavScoringCount > 0) IMGUI_DEBUG_LOG("NavScoringCount %d for '%s' layer %d (Init:%d, Move:%d)\n", g.FrameCount, g.NavScoringCount, g.NavWindow ? g.NavWindow->Name : "NULL", g.NavLayer, g.NavInitRequest || g.NavInitResultId != 0, g.NavMoveRequest);
-#endif
-
- // Set input source as Gamepad when buttons are pressed before we map Keyboard (some features differs when used with Gamepad vs Keyboard)
- bool nav_keyboard_active = (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
- bool nav_gamepad_active = (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (g.IO.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
- if (nav_gamepad_active)
- if (g.IO.NavInputs[ImGuiNavInput_Activate] > 0.0f || g.IO.NavInputs[ImGuiNavInput_Input] > 0.0f || g.IO.NavInputs[ImGuiNavInput_Cancel] > 0.0f || g.IO.NavInputs[ImGuiNavInput_Menu] > 0.0f)
- g.NavInputSource = ImGuiInputSource_NavGamepad;
-
- // Update Keyboard->Nav inputs mapping
- if (nav_keyboard_active)
- {
- #define NAV_MAP_KEY(_KEY, _NAV_INPUT) do { if (IsKeyDown(g.IO.KeyMap[_KEY])) { g.IO.NavInputs[_NAV_INPUT] = 1.0f; g.NavInputSource = ImGuiInputSource_NavKeyboard; } } while (0)
- NAV_MAP_KEY(ImGuiKey_Space, ImGuiNavInput_Activate );
- NAV_MAP_KEY(ImGuiKey_Enter, ImGuiNavInput_Input );
- NAV_MAP_KEY(ImGuiKey_Escape, ImGuiNavInput_Cancel );
- NAV_MAP_KEY(ImGuiKey_LeftArrow, ImGuiNavInput_KeyLeft_ );
- NAV_MAP_KEY(ImGuiKey_RightArrow,ImGuiNavInput_KeyRight_);
- NAV_MAP_KEY(ImGuiKey_UpArrow, ImGuiNavInput_KeyUp_ );
- NAV_MAP_KEY(ImGuiKey_DownArrow, ImGuiNavInput_KeyDown_ );
- if (g.IO.KeyCtrl)
- g.IO.NavInputs[ImGuiNavInput_TweakSlow] = 1.0f;
- if (g.IO.KeyShift)
- g.IO.NavInputs[ImGuiNavInput_TweakFast] = 1.0f;
- if (g.IO.KeyAlt && !g.IO.KeyCtrl) // AltGR is Alt+Ctrl, also even on keyboards without AltGR we don't want Alt+Ctrl to open menu.
- g.IO.NavInputs[ImGuiNavInput_KeyMenu_] = 1.0f;
- #undef NAV_MAP_KEY
- }
- memcpy(g.IO.NavInputsDownDurationPrev, g.IO.NavInputsDownDuration, sizeof(g.IO.NavInputsDownDuration));
- for (int i = 0; i < IM_ARRAYSIZE(g.IO.NavInputs); i++)
- g.IO.NavInputsDownDuration[i] = (g.IO.NavInputs[i] > 0.0f) ? (g.IO.NavInputsDownDuration[i] < 0.0f ? 0.0f : g.IO.NavInputsDownDuration[i] + g.IO.DeltaTime) : -1.0f;
-
- // Process navigation init request (select first/default focus)
- // In very rare cases g.NavWindow may be null (e.g. clearing focus after requesting an init request, which does happen when releasing Alt while clicking on void)
- if (g.NavInitResultId != 0 && (!g.NavDisableHighlight || g.NavInitRequestFromMove) && g.NavWindow)
- {
- // Apply result from previous navigation init request (will typically select the first item, unless SetItemDefaultFocus() has been called)
- //IMGUI_DEBUG_LOG("[Nav] Apply NavInitRequest result: 0x%08X Layer %d in \"%s\"\n", g.NavInitResultId, g.NavLayer, g.NavWindow->Name);
- if (g.NavInitRequestFromMove)
- SetNavIDWithRectRel(g.NavInitResultId, g.NavLayer, g.NavInitResultRectRel);
- else
- SetNavID(g.NavInitResultId, g.NavLayer);
- g.NavWindow->NavRectRel[g.NavLayer] = g.NavInitResultRectRel;
- }
- g.NavInitRequest = false;
- g.NavInitRequestFromMove = false;
- g.NavInitResultId = 0;
- g.NavJustMovedToId = 0;
-
- // Process navigation move request
- if (g.NavMoveRequest)
- NavUpdateMoveResult();
-
- // When a forwarded move request failed, we restore the highlight that we disabled during the forward frame
- if (g.NavMoveRequestForward == ImGuiNavForward_ForwardActive)
- {
- IM_ASSERT(g.NavMoveRequest);
- if (g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0)
- g.NavDisableHighlight = false;
- g.NavMoveRequestForward = ImGuiNavForward_None;
- }
-
- // Apply application mouse position movement, after we had a chance to process move request result.
- if (g.NavMousePosDirty && g.NavIdIsAlive)
- {
- // Set mouse position given our knowledge of the navigated item position from last frame
- if ((g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) && (g.IO.BackendFlags & ImGuiBackendFlags_HasSetMousePos))
- {
- if (!g.NavDisableHighlight && g.NavDisableMouseHover && g.NavWindow)
- {
- g.IO.MousePos = g.IO.MousePosPrev = NavCalcPreferredRefPos();
- g.IO.WantSetMousePos = true;
- }
- }
- g.NavMousePosDirty = false;
- }
- g.NavIdIsAlive = false;
- g.NavJustTabbedId = 0;
- IM_ASSERT(g.NavLayer == 0 || g.NavLayer == 1);
-
- // Store our return window (for returning from Layer 1 to Layer 0) and clear it as soon as we step back in our own Layer 0
- if (g.NavWindow)
- NavSaveLastChildNavWindowIntoParent(g.NavWindow);
- if (g.NavWindow && g.NavWindow->NavLastChildNavWindow != NULL && g.NavLayer == 0)
- g.NavWindow->NavLastChildNavWindow = NULL;
-
- // Update CTRL+TAB and Windowing features (hold Square to move/resize/etc.)
- NavUpdateWindowing();
-
- // Set output flags for user application
- g.IO.NavActive = (nav_keyboard_active || nav_gamepad_active) && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs);
- g.IO.NavVisible = (g.IO.NavActive && g.NavId != 0 && !g.NavDisableHighlight) || (g.NavWindowingTarget != NULL);
-
- // Process NavCancel input (to close a popup, get back to parent, clear focus)
- if (IsNavInputPressed(ImGuiNavInput_Cancel, ImGuiInputReadMode_Pressed))
- {
- if (g.ActiveId != 0)
- {
- if (!IsActiveIdUsingNavInput(ImGuiNavInput_Cancel))
- ClearActiveID();
- }
- else if (g.NavWindow && (g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow) && !(g.NavWindow->Flags & ImGuiWindowFlags_Popup) && g.NavWindow->ParentWindow && g.NavWindow != g.NavWindow->RootWindowDockStop)
- {
- // Exit child window
- ImGuiWindow* child_window = g.NavWindow;
- ImGuiWindow* parent_window = g.NavWindow->ParentWindow;
- IM_ASSERT(child_window->ChildId != 0);
- FocusWindow(parent_window);
- SetNavID(child_window->ChildId, 0);
- g.NavIdIsAlive = false;
- if (g.NavDisableMouseHover)
- g.NavMousePosDirty = true;
- }
- else if (g.OpenPopupStack.Size > 0)
- {
- // Close open popup/menu
- if (!(g.OpenPopupStack.back().Window->Flags & ImGuiWindowFlags_Modal))
- ClosePopupToLevel(g.OpenPopupStack.Size - 1, true);
- }
- else if (g.NavLayer != 0)
- {
- // Leave the "menu" layer
- NavRestoreLayer(ImGuiNavLayer_Main);
- }
- else
- {
- // Clear NavLastId for popups but keep it for regular child window so we can leave one and come back where we were
- if (g.NavWindow && ((g.NavWindow->Flags & ImGuiWindowFlags_Popup) || !(g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow)))
- g.NavWindow->NavLastIds[0] = 0;
- g.NavId = 0;
- }
- }
-
- // Process manual activation request
- g.NavActivateId = g.NavActivateDownId = g.NavActivatePressedId = g.NavInputId = 0;
- if (g.NavId != 0 && !g.NavDisableHighlight && !g.NavWindowingTarget && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs))
- {
- bool activate_down = IsNavInputDown(ImGuiNavInput_Activate);
- bool activate_pressed = activate_down && IsNavInputPressed(ImGuiNavInput_Activate, ImGuiInputReadMode_Pressed);
- if (g.ActiveId == 0 && activate_pressed)
- g.NavActivateId = g.NavId;
- if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && activate_down)
- g.NavActivateDownId = g.NavId;
- if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && activate_pressed)
- g.NavActivatePressedId = g.NavId;
- if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && IsNavInputPressed(ImGuiNavInput_Input, ImGuiInputReadMode_Pressed))
- g.NavInputId = g.NavId;
- }
- if (g.NavWindow && (g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs))
- g.NavDisableHighlight = true;
- if (g.NavActivateId != 0)
- IM_ASSERT(g.NavActivateDownId == g.NavActivateId);
- g.NavMoveRequest = false;
-
- // Process programmatic activation request
- if (g.NavNextActivateId != 0)
- g.NavActivateId = g.NavActivateDownId = g.NavActivatePressedId = g.NavInputId = g.NavNextActivateId;
- g.NavNextActivateId = 0;
-
- // Initiate directional inputs request
- if (g.NavMoveRequestForward == ImGuiNavForward_None)
- {
- g.NavMoveDir = ImGuiDir_None;
- g.NavMoveRequestFlags = ImGuiNavMoveFlags_None;
- if (g.NavWindow && !g.NavWindowingTarget && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs))
- {
- if (!IsActiveIdUsingNavDir(ImGuiDir_Left) && IsNavInputPressedAnyOfTwo(ImGuiNavInput_DpadLeft, ImGuiNavInput_KeyLeft_, ImGuiInputReadMode_Repeat)) { g.NavMoveDir = ImGuiDir_Left; }
- if (!IsActiveIdUsingNavDir(ImGuiDir_Right) && IsNavInputPressedAnyOfTwo(ImGuiNavInput_DpadRight,ImGuiNavInput_KeyRight_,ImGuiInputReadMode_Repeat)) { g.NavMoveDir = ImGuiDir_Right; }
- if (!IsActiveIdUsingNavDir(ImGuiDir_Up) && IsNavInputPressedAnyOfTwo(ImGuiNavInput_DpadUp, ImGuiNavInput_KeyUp_, ImGuiInputReadMode_Repeat)) { g.NavMoveDir = ImGuiDir_Up; }
- if (!IsActiveIdUsingNavDir(ImGuiDir_Down) && IsNavInputPressedAnyOfTwo(ImGuiNavInput_DpadDown, ImGuiNavInput_KeyDown_, ImGuiInputReadMode_Repeat)) { g.NavMoveDir = ImGuiDir_Down; }
- }
- g.NavMoveClipDir = g.NavMoveDir;
- }
- else
- {
- // Forwarding previous request (which has been modified, e.g. wrap around menus rewrite the requests with a starting rectangle at the other side of the window)
- // (Preserve g.NavMoveRequestFlags, g.NavMoveClipDir which were set by the NavMoveRequestForward() function)
- IM_ASSERT(g.NavMoveDir != ImGuiDir_None && g.NavMoveClipDir != ImGuiDir_None);
- IM_ASSERT(g.NavMoveRequestForward == ImGuiNavForward_ForwardQueued);
- g.NavMoveRequestForward = ImGuiNavForward_ForwardActive;
- }
-
- // Update PageUp/PageDown/Home/End scroll
- // FIXME-NAV: Consider enabling those keys even without the master ImGuiConfigFlags_NavEnableKeyboard flag?
- float nav_scoring_rect_offset_y = 0.0f;
- if (nav_keyboard_active)
- nav_scoring_rect_offset_y = NavUpdatePageUpPageDown();
-
- // If we initiate a movement request and have no current NavId, we initiate a InitDefautRequest that will be used as a fallback if the direction fails to find a match
- if (g.NavMoveDir != ImGuiDir_None)
- {
- g.NavMoveRequest = true;
- g.NavMoveDirLast = g.NavMoveDir;
- }
- if (g.NavMoveRequest && g.NavId == 0)
- {
- //IMGUI_DEBUG_LOG("[Nav] NavInitRequest from move, window \"%s\", layer=%d\n", g.NavWindow->Name, g.NavLayer);
- g.NavInitRequest = g.NavInitRequestFromMove = true;
- g.NavInitResultId = 0;
- g.NavDisableHighlight = false;
- }
- NavUpdateAnyRequestFlag();
-
- // Scrolling
- if (g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.NavWindowingTarget)
- {
- // *Fallback* manual-scroll with Nav directional keys when window has no navigable item
- ImGuiWindow* window = g.NavWindow;
- const float scroll_speed = ImFloor(window->CalcFontSize() * 100 * g.IO.DeltaTime + 0.5f); // We need round the scrolling speed because sub-pixel scroll isn't reliably supported.
- if (window->DC.NavLayerActiveMask == 0x00 && window->DC.NavHasScroll && g.NavMoveRequest)
- {
- if (g.NavMoveDir == ImGuiDir_Left || g.NavMoveDir == ImGuiDir_Right)
- SetScrollX(window, ImFloor(window->Scroll.x + ((g.NavMoveDir == ImGuiDir_Left) ? -1.0f : +1.0f) * scroll_speed));
- if (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down)
- SetScrollY(window, ImFloor(window->Scroll.y + ((g.NavMoveDir == ImGuiDir_Up) ? -1.0f : +1.0f) * scroll_speed));
- }
-
- // *Normal* Manual scroll with NavScrollXXX keys
- // Next movement request will clamp the NavId reference rectangle to the visible area, so navigation will resume within those bounds.
- ImVec2 scroll_dir = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down, 1.0f/10.0f, 10.0f);
- if (scroll_dir.x != 0.0f && window->ScrollbarX)
- {
- SetScrollX(window, ImFloor(window->Scroll.x + scroll_dir.x * scroll_speed));
- g.NavMoveFromClampedRefRect = true;
- }
- if (scroll_dir.y != 0.0f)
- {
- SetScrollY(window, ImFloor(window->Scroll.y + scroll_dir.y * scroll_speed));
- g.NavMoveFromClampedRefRect = true;
- }
- }
-
- // Reset search results
- g.NavMoveResultLocal.Clear();
- g.NavMoveResultLocalVisibleSet.Clear();
- g.NavMoveResultOther.Clear();
-
- // When we have manually scrolled (without using navigation) and NavId becomes out of bounds, we project its bounding box to the visible area to restart navigation within visible items
- if (g.NavMoveRequest && g.NavMoveFromClampedRefRect && g.NavLayer == 0)
- {
- ImGuiWindow* window = g.NavWindow;
- ImRect window_rect_rel(window->InnerRect.Min - window->Pos - ImVec2(1,1), window->InnerRect.Max - window->Pos + ImVec2(1,1));
- if (!window_rect_rel.Contains(window->NavRectRel[g.NavLayer]))
- {
- float pad = window->CalcFontSize() * 0.5f;
- window_rect_rel.Expand(ImVec2(-ImMin(window_rect_rel.GetWidth(), pad), -ImMin(window_rect_rel.GetHeight(), pad))); // Terrible approximation for the intent of starting navigation from first fully visible item
- window->NavRectRel[g.NavLayer].ClipWith(window_rect_rel);
- g.NavId = 0;
- }
- g.NavMoveFromClampedRefRect = false;
- }
-
- // For scoring we use a single segment on the left side our current item bounding box (not touching the edge to avoid box overlap with zero-spaced items)
- ImRect nav_rect_rel = (g.NavWindow && !g.NavWindow->NavRectRel[g.NavLayer].IsInverted()) ? g.NavWindow->NavRectRel[g.NavLayer] : ImRect(0,0,0,0);
- g.NavScoringRectScreen = g.NavWindow ? ImRect(g.NavWindow->Pos + nav_rect_rel.Min, g.NavWindow->Pos + nav_rect_rel.Max) : ImRect(0,0,0,0);
- g.NavScoringRectScreen.TranslateY(nav_scoring_rect_offset_y);
- g.NavScoringRectScreen.Min.x = ImMin(g.NavScoringRectScreen.Min.x + 1.0f, g.NavScoringRectScreen.Max.x);
- g.NavScoringRectScreen.Max.x = g.NavScoringRectScreen.Min.x;
- IM_ASSERT(!g.NavScoringRectScreen.IsInverted()); // Ensure if we have a finite, non-inverted bounding box here will allows us to remove extraneous ImFabs() calls in NavScoreItem().
- //GetForegroundDrawList()->AddRect(g.NavScoringRectScreen.Min, g.NavScoringRectScreen.Max, IM_COL32(255,200,0,255)); // [DEBUG]
- g.NavScoringCount = 0;
-#if IMGUI_DEBUG_NAV_RECTS
- if (g.NavWindow)
- {
- ImDrawList* draw_list = GetForegroundDrawList(g.NavWindow);
- if (1) { for (int layer = 0; layer < 2; layer++) draw_list->AddRect(g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Min, g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Max, IM_COL32(255,200,0,255)); } // [DEBUG]
- if (1) { ImU32 col = (!g.NavWindow->Hidden) ? IM_COL32(255,0,255,255) : IM_COL32(255,0,0,255); ImVec2 p = NavCalcPreferredRefPos(); char buf[32]; ImFormatString(buf, 32, "%d", g.NavLayer); draw_list->AddCircleFilled(p, 3.0f, col); draw_list->AddText(NULL, 13.0f, p + ImVec2(8,-4), col, buf); }
- }
-#endif
-}
-
-// Apply result from previous frame navigation directional move request
-static void ImGui::NavUpdateMoveResult()
-{
- ImGuiContext& g = *GImGui;
- if (g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0)
- {
- // In a situation when there is no results but NavId != 0, re-enable the Navigation highlight (because g.NavId is not considered as a possible result)
- if (g.NavId != 0)
- {
- g.NavDisableHighlight = false;
- g.NavDisableMouseHover = true;
- }
- return;
- }
-
- // Select which result to use
- ImGuiNavMoveResult* result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;
-
- // PageUp/PageDown behavior first jumps to the bottom/top mostly visible item, _otherwise_ use the result from the previous/next page.
- if (g.NavMoveRequestFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet)
- if (g.NavMoveResultLocalVisibleSet.ID != 0 && g.NavMoveResultLocalVisibleSet.ID != g.NavId)
- result = &g.NavMoveResultLocalVisibleSet;
-
- // Maybe entering a flattened child from the outside? In this case solve the tie using the regular scoring rules.
- if (result != &g.NavMoveResultOther && g.NavMoveResultOther.ID != 0 && g.NavMoveResultOther.Window->ParentWindow == g.NavWindow)
- if ((g.NavMoveResultOther.DistBox < result->DistBox) || (g.NavMoveResultOther.DistBox == result->DistBox && g.NavMoveResultOther.DistCenter < result->DistCenter))
- result = &g.NavMoveResultOther;
- IM_ASSERT(g.NavWindow && result->Window);
-
- // Scroll to keep newly navigated item fully into view.
- if (g.NavLayer == 0)
- {
- ImVec2 delta_scroll;
- if (g.NavMoveRequestFlags & ImGuiNavMoveFlags_ScrollToEdge)
- {
- float scroll_target = (g.NavMoveDir == ImGuiDir_Up) ? result->Window->ScrollMax.y : 0.0f;
- delta_scroll.y = result->Window->Scroll.y - scroll_target;
- SetScrollY(result->Window, scroll_target);
- }
- else
- {
- ImRect rect_abs = ImRect(result->RectRel.Min + result->Window->Pos, result->RectRel.Max + result->Window->Pos);
- delta_scroll = ScrollToBringRectIntoView(result->Window, rect_abs);
- }
-
- // Offset our result position so mouse position can be applied immediately after in NavUpdate()
- result->RectRel.TranslateX(-delta_scroll.x);
- result->RectRel.TranslateY(-delta_scroll.y);
- }
-
- ClearActiveID();
- g.NavWindow = result->Window;
- if (g.NavId != result->ID)
- {
- // Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId)
- g.NavJustMovedToId = result->ID;
- g.NavJustMovedToMultiSelectScopeId = result->SelectScopeId;
- }
- SetNavIDWithRectRel(result->ID, g.NavLayer, result->RectRel);
- g.NavMoveFromClampedRefRect = false;
-}
-
-// Handle PageUp/PageDown/Home/End keys
-static float ImGui::NavUpdatePageUpPageDown()
-{
- ImGuiContext& g = *GImGui;
- if (g.NavMoveDir != ImGuiDir_None || g.NavWindow == NULL)
- return 0.0f;
- if ((g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) || g.NavWindowingTarget != NULL || g.NavLayer != 0)
- return 0.0f;
-
- ImGuiWindow* window = g.NavWindow;
- const bool page_up_held = IsKeyDown(g.IO.KeyMap[ImGuiKey_PageUp]) && !IsActiveIdUsingKey(ImGuiKey_PageUp);
- const bool page_down_held = IsKeyDown(g.IO.KeyMap[ImGuiKey_PageDown]) && !IsActiveIdUsingKey(ImGuiKey_PageDown);
- const bool home_pressed = IsKeyPressed(g.IO.KeyMap[ImGuiKey_Home]) && !IsActiveIdUsingKey(ImGuiKey_Home);
- const bool end_pressed = IsKeyPressed(g.IO.KeyMap[ImGuiKey_End]) && !IsActiveIdUsingKey(ImGuiKey_End);
- if (page_up_held != page_down_held || home_pressed != end_pressed) // If either (not both) are pressed
- {
- if (window->DC.NavLayerActiveMask == 0x00 && window->DC.NavHasScroll)
- {
- // Fallback manual-scroll when window has no navigable item
- if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageUp], true))
- SetScrollY(window, window->Scroll.y - window->InnerRect.GetHeight());
- else if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageDown], true))
- SetScrollY(window, window->Scroll.y + window->InnerRect.GetHeight());
- else if (home_pressed)
- SetScrollY(window, 0.0f);
- else if (end_pressed)
- SetScrollY(window, window->ScrollMax.y);
- }
- else
- {
- ImRect& nav_rect_rel = window->NavRectRel[g.NavLayer];
- const float page_offset_y = ImMax(0.0f, window->InnerRect.GetHeight() - window->CalcFontSize() * 1.0f + nav_rect_rel.GetHeight());
- float nav_scoring_rect_offset_y = 0.0f;
- if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageUp], true))
- {
- nav_scoring_rect_offset_y = -page_offset_y;
- g.NavMoveDir = ImGuiDir_Down; // Because our scoring rect is offset up, we request the down direction (so we can always land on the last item)
- g.NavMoveClipDir = ImGuiDir_Up;
- g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
- }
- else if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageDown], true))
- {
- nav_scoring_rect_offset_y = +page_offset_y;
- g.NavMoveDir = ImGuiDir_Up; // Because our scoring rect is offset down, we request the up direction (so we can always land on the last item)
- g.NavMoveClipDir = ImGuiDir_Down;
- g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
- }
- else if (home_pressed)
- {
- // FIXME-NAV: handling of Home/End is assuming that the top/bottom most item will be visible with Scroll.y == 0/ScrollMax.y
- // Scrolling will be handled via the ImGuiNavMoveFlags_ScrollToEdge flag, we don't scroll immediately to avoid scrolling happening before nav result.
- // Preserve current horizontal position if we have any.
- nav_rect_rel.Min.y = nav_rect_rel.Max.y = -window->Scroll.y;
- if (nav_rect_rel.IsInverted())
- nav_rect_rel.Min.x = nav_rect_rel.Max.x = 0.0f;
- g.NavMoveDir = ImGuiDir_Down;
- g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_ScrollToEdge;
- }
- else if (end_pressed)
- {
- nav_rect_rel.Min.y = nav_rect_rel.Max.y = window->ScrollMax.y + window->SizeFull.y - window->Scroll.y;
- if (nav_rect_rel.IsInverted())
- nav_rect_rel.Min.x = nav_rect_rel.Max.x = 0.0f;
- g.NavMoveDir = ImGuiDir_Up;
- g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_ScrollToEdge;
- }
- return nav_scoring_rect_offset_y;
- }
- }
- return 0.0f;
-}
-
-static int ImGui::FindWindowFocusIndex(ImGuiWindow* window) // FIXME-OPT O(N)
-{
- ImGuiContext& g = *GImGui;
- for (int i = g.WindowsFocusOrder.Size-1; i >= 0; i--)
- if (g.WindowsFocusOrder[i] == window)
- return i;
- return -1;
-}
-
-static ImGuiWindow* FindWindowNavFocusable(int i_start, int i_stop, int dir) // FIXME-OPT O(N)
-{
- ImGuiContext& g = *GImGui;
- for (int i = i_start; i >= 0 && i < g.WindowsFocusOrder.Size && i != i_stop; i += dir)
- if (ImGui::IsWindowNavFocusable(g.WindowsFocusOrder[i]))
- return g.WindowsFocusOrder[i];
- return NULL;
-}
-
-static void NavUpdateWindowingHighlightWindow(int focus_change_dir)
-{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(g.NavWindowingTarget);
- if (g.NavWindowingTarget->Flags & ImGuiWindowFlags_Modal)
- return;
-
- const int i_current = ImGui::FindWindowFocusIndex(g.NavWindowingTarget);
- ImGuiWindow* window_target = FindWindowNavFocusable(i_current + focus_change_dir, -INT_MAX, focus_change_dir);
- if (!window_target)
- window_target = FindWindowNavFocusable((focus_change_dir < 0) ? (g.WindowsFocusOrder.Size - 1) : 0, i_current, focus_change_dir);
- if (window_target) // Don't reset windowing target if there's a single window in the list
- g.NavWindowingTarget = g.NavWindowingTargetAnim = window_target;
- g.NavWindowingToggleLayer = false;
-}
-
-// Windowing management mode
-// Keyboard: CTRL+Tab (change focus/move/resize), Alt (toggle menu layer)
-// Gamepad: Hold Menu/Square (change focus/move/resize), Tap Menu/Square (toggle menu layer)
-static void ImGui::NavUpdateWindowing()
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* apply_focus_window = NULL;
- bool apply_toggle_layer = false;
-
- ImGuiWindow* modal_window = GetTopMostPopupModal();
- if (modal_window != NULL)
- {
- g.NavWindowingTarget = NULL;
- return;
- }
-
- // Fade out
- if (g.NavWindowingTargetAnim && g.NavWindowingTarget == NULL)
- {
- g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha - g.IO.DeltaTime * 10.0f, 0.0f);
- if (g.DimBgRatio <= 0.0f && g.NavWindowingHighlightAlpha <= 0.0f)
- g.NavWindowingTargetAnim = NULL;
- }
-
- // Start CTRL-TAB or Square+L/R window selection
- bool start_windowing_with_gamepad = !g.NavWindowingTarget && IsNavInputPressed(ImGuiNavInput_Menu, ImGuiInputReadMode_Pressed);
- bool start_windowing_with_keyboard = !g.NavWindowingTarget && g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab) && (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard);
- if (start_windowing_with_gamepad || start_windowing_with_keyboard)
- if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1))
- {
- g.NavWindowingTarget = g.NavWindowingTargetAnim = window;
- g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f;
- g.NavWindowingToggleLayer = start_windowing_with_keyboard ? false : true;
- g.NavInputSource = start_windowing_with_keyboard ? ImGuiInputSource_NavKeyboard : ImGuiInputSource_NavGamepad;
- }
-
- // Gamepad update
- g.NavWindowingTimer += g.IO.DeltaTime;
- if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_NavGamepad)
- {
- // Highlight only appears after a brief time holding the button, so that a fast tap on PadMenu (to toggle NavLayer) doesn't add visual noise
- g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f));
-
- // Select window to focus
- const int focus_change_dir = (int)IsNavInputPressed(ImGuiNavInput_FocusPrev, ImGuiInputReadMode_RepeatSlow) - (int)IsNavInputPressed(ImGuiNavInput_FocusNext, ImGuiInputReadMode_RepeatSlow);
- if (focus_change_dir != 0)
- {
- NavUpdateWindowingHighlightWindow(focus_change_dir);
- g.NavWindowingHighlightAlpha = 1.0f;
- }
-
- // Single press toggles NavLayer, long press with L/R apply actual focus on release (until then the window was merely rendered top-most)
- if (!IsNavInputDown(ImGuiNavInput_Menu))
- {
- g.NavWindowingToggleLayer &= (g.NavWindowingHighlightAlpha < 1.0f); // Once button was held long enough we don't consider it a tap-to-toggle-layer press anymore.
- if (g.NavWindowingToggleLayer && g.NavWindow)
- apply_toggle_layer = true;
- else if (!g.NavWindowingToggleLayer)
- apply_focus_window = g.NavWindowingTarget;
- g.NavWindowingTarget = NULL;
- }
- }
-
- // Keyboard: Focus
- if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_NavKeyboard)
- {
- // Visuals only appears after a brief time after pressing TAB the first time, so that a fast CTRL+TAB doesn't add visual noise
- g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f)); // 1.0f
- if (IsKeyPressedMap(ImGuiKey_Tab, true))
- NavUpdateWindowingHighlightWindow(g.IO.KeyShift ? +1 : -1);
- if (!g.IO.KeyCtrl)
- apply_focus_window = g.NavWindowingTarget;
- }
-
- // Keyboard: Press and Release ALT to toggle menu layer
- // FIXME: We lack an explicit IO variable for "is the imgui window focused", so compare mouse validity to detect the common case of back-end clearing releases all keys on ALT-TAB
- if (IsNavInputPressed(ImGuiNavInput_KeyMenu_, ImGuiInputReadMode_Pressed))
- g.NavWindowingToggleLayer = true;
- if ((g.ActiveId == 0 || g.ActiveIdAllowOverlap) && g.NavWindowingToggleLayer && IsNavInputPressed(ImGuiNavInput_KeyMenu_, ImGuiInputReadMode_Released))
- if (IsMousePosValid(&g.IO.MousePos) == IsMousePosValid(&g.IO.MousePosPrev))
- apply_toggle_layer = true;
-
- // Move window
- if (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoMove))
- {
- ImVec2 move_delta;
- if (g.NavInputSource == ImGuiInputSource_NavKeyboard && !g.IO.KeyShift)
- move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard, ImGuiInputReadMode_Down);
- if (g.NavInputSource == ImGuiInputSource_NavGamepad)
- move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down);
- if (move_delta.x != 0.0f || move_delta.y != 0.0f)
- {
- const float NAV_MOVE_SPEED = 800.0f;
- const float move_speed = ImFloor(NAV_MOVE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y)); // FIXME: Doesn't code variable framerate very well
- SetWindowPos(g.NavWindowingTarget->RootWindow, g.NavWindowingTarget->RootWindow->Pos + move_delta * move_speed, ImGuiCond_Always);
- g.NavDisableMouseHover = true;
- MarkIniSettingsDirty(g.NavWindowingTarget);
- }
- }
-
- // Apply final focus
- if (apply_focus_window && (g.NavWindow == NULL || apply_focus_window != g.NavWindow->RootWindowDockStop))
- {
- ImGuiViewport* previous_viewport = g.NavWindow ? g.NavWindow->Viewport : NULL;
- ClearActiveID();
- g.NavDisableHighlight = false;
- g.NavDisableMouseHover = true;
- apply_focus_window = NavRestoreLastChildNavWindow(apply_focus_window);
- ClosePopupsOverWindow(apply_focus_window, false);
- FocusWindow(apply_focus_window);
- if (apply_focus_window->NavLastIds[0] == 0)
- NavInitWindow(apply_focus_window, false);
-
- // If the window only has a menu layer, select it directly
- if (apply_focus_window->DC.NavLayerActiveMask == (1 << ImGuiNavLayer_Menu))
- g.NavLayer = ImGuiNavLayer_Menu;
-
- // Request OS level focus
- if (apply_focus_window->Viewport != previous_viewport && g.PlatformIO.Platform_SetWindowFocus)
- g.PlatformIO.Platform_SetWindowFocus(apply_focus_window->Viewport);
- }
- if (apply_focus_window)
- g.NavWindowingTarget = NULL;
-
- // Apply menu/layer toggle
- if (apply_toggle_layer && g.NavWindow)
- {
- // Move to parent menu if necessary
- ImGuiWindow* new_nav_window = g.NavWindow;
- while (new_nav_window->ParentWindow
- && (new_nav_window->DC.NavLayerActiveMask & (1 << ImGuiNavLayer_Menu)) == 0
- && (new_nav_window->Flags & ImGuiWindowFlags_ChildWindow) != 0
- && (new_nav_window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0)
- new_nav_window = new_nav_window->ParentWindow;
- if (new_nav_window != g.NavWindow)
- {
- ImGuiWindow* old_nav_window = g.NavWindow;
- FocusWindow(new_nav_window);
- new_nav_window->NavLastChildNavWindow = old_nav_window;
- }
- g.NavDisableHighlight = false;
- g.NavDisableMouseHover = true;
-
- // When entering a regular menu bar with the Alt key, we always reinitialize the navigation ID. It however persist on docking tab tabs.
- const ImGuiNavLayer new_nav_layer = (g.NavWindow->DC.NavLayerActiveMask & (1 << ImGuiNavLayer_Menu)) ? (ImGuiNavLayer)((int)g.NavLayer ^ 1) : ImGuiNavLayer_Main;
- const bool preserve_layer_1_nav_id = (new_nav_window->DockNodeAsHost != NULL);
- if (new_nav_layer == ImGuiNavLayer_Menu && !preserve_layer_1_nav_id)
- g.NavWindow->NavLastIds[ImGuiNavLayer_Menu] = 0;
- NavRestoreLayer(new_nav_layer);
- }
-}
-
-// Window has already passed the IsWindowNavFocusable()
-static const char* GetFallbackWindowNameForWindowingList(ImGuiWindow* window)
-{
- if (window->Flags & ImGuiWindowFlags_Popup)
- return "(Popup)";
- if ((window->Flags & ImGuiWindowFlags_MenuBar) && strcmp(window->Name, "##MainMenuBar") == 0)
- return "(Main menu bar)";
- if (window->DockNodeAsHost)
- return "(Dock node)";
- return "(Untitled)";
-}
-
-// Overlay displayed when using CTRL+TAB. Called by EndFrame().
-void ImGui::NavUpdateWindowingOverlay()
-{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(g.NavWindowingTarget != NULL);
-
- if (g.NavWindowingTimer < NAV_WINDOWING_LIST_APPEAR_DELAY)
- return;
-
- if (g.NavWindowingList == NULL)
- g.NavWindowingList = FindWindowByName("###NavWindowingList");
- ImGuiViewportP* viewport = /*g.NavWindow ? g.NavWindow->Viewport :*/ (ImGuiViewportP*)GetMainViewport();
- SetNextWindowSizeConstraints(ImVec2(viewport->Size.x * 0.20f, viewport->Size.y * 0.20f), ImVec2(FLT_MAX, FLT_MAX));
- SetNextWindowPos(viewport->Pos + viewport->Size * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
- PushStyleVar(ImGuiStyleVar_WindowPadding, g.Style.WindowPadding * 2.0f);
- Begin("###NavWindowingList", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings);
- for (int n = g.WindowsFocusOrder.Size - 1; n >= 0; n--)
- {
- ImGuiWindow* window = g.WindowsFocusOrder[n];
- if (!IsWindowNavFocusable(window))
- continue;
- const char* label = window->Name;
- if (label == FindRenderedTextEnd(label))
- label = GetFallbackWindowNameForWindowingList(window);
- Selectable(label, g.NavWindowingTarget == window);
- }
- End();
- PopStyleVar();
-}
-
-
-//-----------------------------------------------------------------------------
-// [SECTION] DRAG AND DROP
-//-----------------------------------------------------------------------------
-
-void ImGui::ClearDragDrop()
-{
- ImGuiContext& g = *GImGui;
- g.DragDropActive = false;
- g.DragDropPayload.Clear();
- g.DragDropAcceptFlags = ImGuiDragDropFlags_None;
- g.DragDropAcceptIdCurr = g.DragDropAcceptIdPrev = 0;
- g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
- g.DragDropAcceptFrameCount = -1;
-
- g.DragDropPayloadBufHeap.clear();
- memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal));
-}
-
-// Call when current ID is active.
-// When this returns true you need to: a) call SetDragDropPayload() exactly once, b) you may render the payload visual/description, c) call EndDragDropSource()
-bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
-
- bool source_drag_active = false;
- ImGuiID source_id = 0;
- ImGuiID source_parent_id = 0;
- int mouse_button = 0;
- if (!(flags & ImGuiDragDropFlags_SourceExtern))
- {
- source_id = window->DC.LastItemId;
- if (source_id != 0 && g.ActiveId != source_id) // Early out for most common case
- return false;
- if (g.IO.MouseDown[mouse_button] == false)
- return false;
-
- if (source_id == 0)
- {
- // If you want to use BeginDragDropSource() on an item with no unique identifier for interaction, such as Text() or Image(), you need to:
- // A) Read the explanation below, B) Use the ImGuiDragDropFlags_SourceAllowNullID flag, C) Swallow your programmer pride.
- if (!(flags & ImGuiDragDropFlags_SourceAllowNullID))
- {
- IM_ASSERT(0);
- return false;
- }
-
- // Early out
- if ((window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect) == 0 && (g.ActiveId == 0 || g.ActiveIdWindow != window))
- return false;
-
- // Magic fallback (=somehow reprehensible) to handle items with no assigned ID, e.g. Text(), Image()
- // We build a throwaway ID based on current ID stack + relative AABB of items in window.
- // THE IDENTIFIER WON'T SURVIVE ANY REPOSITIONING OF THE WIDGET, so if your widget moves your dragging operation will be canceled.
- // We don't need to maintain/call ClearActiveID() as releasing the button will early out this function and trigger !ActiveIdIsAlive.
- source_id = window->DC.LastItemId = window->GetIDFromRectangle(window->DC.LastItemRect);
- bool is_hovered = ItemHoverable(window->DC.LastItemRect, source_id);
- if (is_hovered && g.IO.MouseClicked[mouse_button])
- {
- SetActiveID(source_id, window);
- FocusWindow(window);
- }
- if (g.ActiveId == source_id) // Allow the underlying widget to display/return hovered during the mouse release frame, else we would get a flicker.
- g.ActiveIdAllowOverlap = is_hovered;
- }
- else
- {
- g.ActiveIdAllowOverlap = false;
- }
- if (g.ActiveId != source_id)
- return false;
- source_parent_id = window->IDStack.back();
- source_drag_active = IsMouseDragging(mouse_button);
- }
- else
- {
- window = NULL;
- source_id = ImHashStr("#SourceExtern");
- source_drag_active = true;
- }
-
- if (source_drag_active)
- {
- if (!g.DragDropActive)
- {
- IM_ASSERT(source_id != 0);
- ClearDragDrop();
- ImGuiPayload& payload = g.DragDropPayload;
- payload.SourceId = source_id;
- payload.SourceParentId = source_parent_id;
- g.DragDropActive = true;
- g.DragDropSourceFlags = flags;
- g.DragDropMouseButton = mouse_button;
- }
- g.DragDropSourceFrameCount = g.FrameCount;
- g.DragDropWithinSourceOrTarget = true;
-
- if (!(flags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
- {
- // Target can request the Source to not display its tooltip (we use a dedicated flag to make this request explicit)
- // We unfortunately can't just modify the source flags and skip the call to BeginTooltip, as caller may be emitting contents.
- BeginTooltip();
- if (g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip))
- {
- ImGuiWindow* tooltip_window = g.CurrentWindow;
- tooltip_window->SkipItems = true;
- tooltip_window->HiddenFramesCanSkipItems = 1;
- }
- }
-
- if (!(flags & ImGuiDragDropFlags_SourceNoDisableHover) && !(flags & ImGuiDragDropFlags_SourceExtern))
- window->DC.LastItemStatusFlags &= ~ImGuiItemStatusFlags_HoveredRect;
-
- return true;
- }
- return false;
-}
-
-void ImGui::EndDragDropSource()
-{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(g.DragDropActive);
- IM_ASSERT(g.DragDropWithinSourceOrTarget && "Not after a BeginDragDropSource()?");
-
- if (!(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
- EndTooltip();
-
- // Discard the drag if have not called SetDragDropPayload()
- if (g.DragDropPayload.DataFrameCount == -1)
- ClearDragDrop();
- g.DragDropWithinSourceOrTarget = false;
-}
-
-// Use 'cond' to choose to submit payload on drag start or every frame
-bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_size, ImGuiCond cond)
-{
- ImGuiContext& g = *GImGui;
- ImGuiPayload& payload = g.DragDropPayload;
- if (cond == 0)
- cond = ImGuiCond_Always;
-
- IM_ASSERT(type != NULL);
- IM_ASSERT(strlen(type) < IM_ARRAYSIZE(payload.DataType) && "Payload type can be at most 32 characters long");
- IM_ASSERT((data != NULL && data_size > 0) || (data == NULL && data_size == 0));
- IM_ASSERT(cond == ImGuiCond_Always || cond == ImGuiCond_Once);
- IM_ASSERT(payload.SourceId != 0); // Not called between BeginDragDropSource() and EndDragDropSource()
-
- if (cond == ImGuiCond_Always || payload.DataFrameCount == -1)
- {
- // Copy payload
- ImStrncpy(payload.DataType, type, IM_ARRAYSIZE(payload.DataType));
- g.DragDropPayloadBufHeap.resize(0);
- if (data_size > sizeof(g.DragDropPayloadBufLocal))
- {
- // Store in heap
- g.DragDropPayloadBufHeap.resize((int)data_size);
- payload.Data = g.DragDropPayloadBufHeap.Data;
- memcpy(payload.Data, data, data_size);
- }
- else if (data_size > 0)
- {
- // Store locally
- memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal));
- payload.Data = g.DragDropPayloadBufLocal;
- memcpy(payload.Data, data, data_size);
- }
- else
- {
- payload.Data = NULL;
- }
- payload.DataSize = (int)data_size;
- }
- payload.DataFrameCount = g.FrameCount;
-
- return (g.DragDropAcceptFrameCount == g.FrameCount) || (g.DragDropAcceptFrameCount == g.FrameCount - 1);
-}
-
-bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id)
-{
- ImGuiContext& g = *GImGui;
- if (!g.DragDropActive)
- return false;
-
- ImGuiWindow* window = g.CurrentWindow;
- if (g.HoveredWindowUnderMovingWindow == NULL || window->RootWindow != g.HoveredWindowUnderMovingWindow->RootWindow)
- return false;
- IM_ASSERT(id != 0);
- if (!IsMouseHoveringRect(bb.Min, bb.Max) || (id == g.DragDropPayload.SourceId))
- return false;
- if (window->SkipItems)
- return false;
-
- IM_ASSERT(g.DragDropWithinSourceOrTarget == false);
- g.DragDropTargetRect = bb;
- g.DragDropTargetId = id;
- g.DragDropWithinSourceOrTarget = true;
- return true;
-}
-
-// We don't use BeginDragDropTargetCustom() and duplicate its code because:
-// 1) we use LastItemRectHoveredRect which handles items that pushes a temporarily clip rectangle in their code. Calling BeginDragDropTargetCustom(LastItemRect) would not handle them.
-// 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can.
-// Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case)
-bool ImGui::BeginDragDropTarget()
-{
- ImGuiContext& g = *GImGui;
- if (!g.DragDropActive)
- return false;
-
- ImGuiWindow* window = g.CurrentWindow;
- if (!(window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect))
- return false;
- if (g.HoveredWindowUnderMovingWindow == NULL || window->RootWindow != g.HoveredWindowUnderMovingWindow->RootWindow)
- return false;
-
- const ImRect& display_rect = (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect) ? window->DC.LastItemDisplayRect : window->DC.LastItemRect;
- ImGuiID id = window->DC.LastItemId;
- if (id == 0)
- id = window->GetIDFromRectangle(display_rect);
- if (g.DragDropPayload.SourceId == id)
- return false;
-
- IM_ASSERT(g.DragDropWithinSourceOrTarget == false);
- g.DragDropTargetRect = display_rect;
- g.DragDropTargetId = id;
- g.DragDropWithinSourceOrTarget = true;
- return true;
-}
-
-bool ImGui::IsDragDropPayloadBeingAccepted()
-{
- ImGuiContext& g = *GImGui;
- return g.DragDropActive && g.DragDropAcceptIdPrev != 0;
-}
-
-const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags)
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
- ImGuiPayload& payload = g.DragDropPayload;
- IM_ASSERT(g.DragDropActive); // Not called between BeginDragDropTarget() and EndDragDropTarget() ?
- IM_ASSERT(payload.DataFrameCount != -1); // Forgot to call EndDragDropTarget() ?
- if (type != NULL && !payload.IsDataType(type))
- return NULL;
-
- // Accept smallest drag target bounding box, this allows us to nest drag targets conveniently without ordering constraints.
- // NB: We currently accept NULL id as target. However, overlapping targets requires a unique ID to function!
- const bool was_accepted_previously = (g.DragDropAcceptIdPrev == g.DragDropTargetId);
- ImRect r = g.DragDropTargetRect;
- float r_surface = r.GetWidth() * r.GetHeight();
- if (r_surface < g.DragDropAcceptIdCurrRectSurface)
- {
- g.DragDropAcceptFlags = flags;
- g.DragDropAcceptIdCurr = g.DragDropTargetId;
- g.DragDropAcceptIdCurrRectSurface = r_surface;
- }
-
- // Render default drop visuals
- payload.Preview = was_accepted_previously;
- flags |= (g.DragDropSourceFlags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect); // Source can also inhibit the preview (useful for external sources that lives for 1 frame)
- if (!(flags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect) && payload.Preview)
- {
- // FIXME-DRAG: Settle on a proper default visuals for drop target.
- r.Expand(3.5f);
- bool push_clip_rect = !window->ClipRect.Contains(r);
- if (push_clip_rect) window->DrawList->PushClipRect(r.Min-ImVec2(1,1), r.Max+ImVec2(1,1));
- window->DrawList->AddRect(r.Min, r.Max, GetColorU32(ImGuiCol_DragDropTarget), 0.0f, ~0, 2.0f);
- if (push_clip_rect) window->DrawList->PopClipRect();
- }
-
- g.DragDropAcceptFrameCount = g.FrameCount;
- payload.Delivery = was_accepted_previously && !IsMouseDown(g.DragDropMouseButton); // For extern drag sources affecting os window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased()
- if (!payload.Delivery && !(flags & ImGuiDragDropFlags_AcceptBeforeDelivery))
- return NULL;
-
- return &payload;
-}
-
-const ImGuiPayload* ImGui::GetDragDropPayload()
-{
- ImGuiContext& g = *GImGui;
- return g.DragDropActive ? &g.DragDropPayload : NULL;
-}
-
-// We don't really use/need this now, but added it for the sake of consistency and because we might need it later.
-void ImGui::EndDragDropTarget()
-{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(g.DragDropActive);
- IM_ASSERT(g.DragDropWithinSourceOrTarget);
- g.DragDropWithinSourceOrTarget = false;
-}
-
-
-//-----------------------------------------------------------------------------
-// [SECTION] LOGGING/CAPTURING
-//-----------------------------------------------------------------------------
-// All text output from the interface can be captured into tty/file/clipboard.
-// By default, tree nodes are automatically opened during logging.
-//-----------------------------------------------------------------------------
-
-// Pass text data straight to log (without being displayed)
-void ImGui::LogText(const char* fmt, ...)
-{
- ImGuiContext& g = *GImGui;
- if (!g.LogEnabled)
- return;
-
- va_list args;
- va_start(args, fmt);
- if (g.LogFile)
- vfprintf(g.LogFile, fmt, args);
- else
- g.LogBuffer.appendfv(fmt, args);
- va_end(args);
-}
-
-// Internal version that takes a position to decide on newline placement and pad items according to their depth.
-// We split text into individual lines to add current tree level padding
-void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end)
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
-
- if (!text_end)
- text_end = FindRenderedTextEnd(text, text_end);
-
- const bool log_new_line = ref_pos && (ref_pos->y > g.LogLinePosY + 1);
- if (ref_pos)
- g.LogLinePosY = ref_pos->y;
- if (log_new_line)
- g.LogLineFirstItem = true;
-
- const char* text_remaining = text;
- if (g.LogDepthRef > window->DC.TreeDepth) // Re-adjust padding if we have popped out of our starting depth
- g.LogDepthRef = window->DC.TreeDepth;
- const int tree_depth = (window->DC.TreeDepth - g.LogDepthRef);
- for (;;)
- {
- // Split the string. Each new line (after a '\n') is followed by spacing corresponding to the current depth of our log entry.
- // We don't add a trailing \n to allow a subsequent item on the same line to be captured.
- const char* line_start = text_remaining;
- const char* line_end = ImStreolRange(line_start, text_end);
- const bool is_first_line = (line_start == text);
- const bool is_last_line = (line_end == text_end);
- if (!is_last_line || (line_start != line_end))
- {
- const int char_count = (int)(line_end - line_start);
- if (log_new_line || !is_first_line)
- LogText(IM_NEWLINE "%*s%.*s", tree_depth * 4, "", char_count, line_start);
- else if (g.LogLineFirstItem)
- LogText("%*s%.*s", tree_depth * 4, "", char_count, line_start);
- else
- LogText(" %.*s", char_count, line_start);
- g.LogLineFirstItem = false;
- }
- else if (log_new_line)
- {
- // An empty "" string at a different Y position should output a carriage return.
- LogText(IM_NEWLINE);
- break;
- }
-
- if (is_last_line)
- break;
- text_remaining = line_end + 1;
- }
-}
-
-// Start logging/capturing text output
-void ImGui::LogBegin(ImGuiLogType type, int auto_open_depth)
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
- IM_ASSERT(g.LogEnabled == false);
- IM_ASSERT(g.LogFile == NULL);
- IM_ASSERT(g.LogBuffer.empty());
- g.LogEnabled = true;
- g.LogType = type;
- g.LogDepthRef = window->DC.TreeDepth;
- g.LogDepthToExpand = ((auto_open_depth >= 0) ? auto_open_depth : g.LogDepthToExpandDefault);
- g.LogLinePosY = FLT_MAX;
- g.LogLineFirstItem = true;
-}
-
-void ImGui::LogToTTY(int auto_open_depth)
-{
- ImGuiContext& g = *GImGui;
- if (g.LogEnabled)
- return;
- LogBegin(ImGuiLogType_TTY, auto_open_depth);
- g.LogFile = stdout;
-}
-
-// Start logging/capturing text output to given file
-void ImGui::LogToFile(int auto_open_depth, const char* filename)
-{
- ImGuiContext& g = *GImGui;
- if (g.LogEnabled)
- return;
-
- // FIXME: We could probably open the file in text mode "at", however note that clipboard/buffer logging will still
- // be subject to outputting OS-incompatible carriage return if within strings the user doesn't use IM_NEWLINE.
- // By opening the file in binary mode "ab" we have consistent output everywhere.
- if (!filename)
- filename = g.IO.LogFilename;
- if (!filename || !filename[0])
- return;
- FILE* f = ImFileOpen(filename, "ab");
- if (f == NULL)
- {
- IM_ASSERT(0);
- return;
- }
-
- LogBegin(ImGuiLogType_File, auto_open_depth);
- g.LogFile = f;
-}
-
-// Start logging/capturing text output to clipboard
-void ImGui::LogToClipboard(int auto_open_depth)
-{
- ImGuiContext& g = *GImGui;
- if (g.LogEnabled)
- return;
- LogBegin(ImGuiLogType_Clipboard, auto_open_depth);
-}
-
-void ImGui::LogToBuffer(int auto_open_depth)
-{
- ImGuiContext& g = *GImGui;
- if (g.LogEnabled)
- return;
- LogBegin(ImGuiLogType_Buffer, auto_open_depth);
-}
-
-void ImGui::LogFinish()
-{
- ImGuiContext& g = *GImGui;
- if (!g.LogEnabled)
- return;
-
- LogText(IM_NEWLINE);
- switch (g.LogType)
- {
- case ImGuiLogType_TTY:
- fflush(g.LogFile);
- break;
- case ImGuiLogType_File:
- fclose(g.LogFile);
- break;
- case ImGuiLogType_Buffer:
- break;
- case ImGuiLogType_Clipboard:
- if (!g.LogBuffer.empty())
- SetClipboardText(g.LogBuffer.begin());
- break;
- case ImGuiLogType_None:
- IM_ASSERT(0);
- break;
- }
-
- g.LogEnabled = false;
- g.LogType = ImGuiLogType_None;
- g.LogFile = NULL;
- g.LogBuffer.clear();
-}
-
-// Helper to display logging buttons
-// FIXME-OBSOLETE: We should probably obsolete this and let the user have their own helper (this is one of the oldest function alive!)
-void ImGui::LogButtons()
-{
- ImGuiContext& g = *GImGui;
-
- PushID("LogButtons");
- const bool log_to_tty = Button("Log To TTY"); SameLine();
- const bool log_to_file = Button("Log To File"); SameLine();
- const bool log_to_clipboard = Button("Log To Clipboard"); SameLine();
- PushAllowKeyboardFocus(false);
- SetNextItemWidth(80.0f);
- SliderInt("Default Depth", &g.LogDepthToExpandDefault, 0, 9, NULL);
- PopAllowKeyboardFocus();
- PopID();
-
- // Start logging at the end of the function so that the buttons don't appear in the log
- if (log_to_tty)
- LogToTTY();
- if (log_to_file)
- LogToFile();
- if (log_to_clipboard)
- LogToClipboard();
-}
-
-
-//-----------------------------------------------------------------------------
-// [SECTION] SETTINGS
-//-----------------------------------------------------------------------------
-
-void ImGui::MarkIniSettingsDirty()
-{
- ImGuiContext& g = *GImGui;
- if (g.SettingsDirtyTimer <= 0.0f)
- g.SettingsDirtyTimer = g.IO.IniSavingRate;
-}
-
-void ImGui::MarkIniSettingsDirty(ImGuiWindow* window)
-{
- ImGuiContext& g = *GImGui;
- if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings))
- if (g.SettingsDirtyTimer <= 0.0f)
- g.SettingsDirtyTimer = g.IO.IniSavingRate;
-}
-
-ImGuiWindowSettings* ImGui::CreateNewWindowSettings(const char* name)
-{
- ImGuiContext& g = *GImGui;
- g.SettingsWindows.push_back(ImGuiWindowSettings());
- ImGuiWindowSettings* settings = &g.SettingsWindows.back();
-#if !IMGUI_DEBUG_INI_SETTINGS
- // Skip to the "###" marker if any. We don't skip past to match the behavior of GetID()
- // Preserve the full string when IMGUI_DEBUG_INI_SETTINGS is set to make .ini inspection easier.
- if (const char* p = strstr(name, "###"))
- name = p;
-#endif
- settings->Name = ImStrdup(name);
- settings->ID = ImHashStr(name);
- return settings;
-}
-
-ImGuiWindowSettings* ImGui::FindWindowSettings(ImGuiID id)
-{
- ImGuiContext& g = *GImGui;
- for (int i = 0; i != g.SettingsWindows.Size; i++)
- if (g.SettingsWindows[i].ID == id)
- return &g.SettingsWindows[i];
- return NULL;
-}
-
-ImGuiWindowSettings* ImGui::FindOrCreateWindowSettings(const char* name)
-{
- if (ImGuiWindowSettings* settings = FindWindowSettings(ImHashStr(name)))
- return settings;
- return CreateNewWindowSettings(name);
-}
-
-void ImGui::LoadIniSettingsFromDisk(const char* ini_filename)
-{
- size_t file_data_size = 0;
- char* file_data = (char*)ImFileLoadToMemory(ini_filename, "rb", &file_data_size);
- if (!file_data)
- return;
- LoadIniSettingsFromMemory(file_data, (size_t)file_data_size);
- IM_FREE(file_data);
-}
-
-ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name)
-{
- ImGuiContext& g = *GImGui;
- const ImGuiID type_hash = ImHashStr(type_name);
- for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
- if (g.SettingsHandlers[handler_n].TypeHash == type_hash)
- return &g.SettingsHandlers[handler_n];
- return NULL;
-}
-
-// Zero-tolerance, no error reporting, cheap .ini parsing
-void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
-{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(g.Initialized);
- IM_ASSERT(g.SettingsLoaded == false && g.FrameCount == 0);
-
- // For user convenience, we allow passing a non zero-terminated string (hence the ini_size parameter).
- // For our convenience and to make the code simpler, we'll also write zero-terminators within the buffer. So let's create a writable copy..
- if (ini_size == 0)
- ini_size = strlen(ini_data);
- char* buf = (char*)IM_ALLOC(ini_size + 1);
- char* buf_end = buf + ini_size;
- memcpy(buf, ini_data, ini_size);
- buf[ini_size] = 0;
-
- void* entry_data = NULL;
- ImGuiSettingsHandler* entry_handler = NULL;
-
- char* line_end = NULL;
- for (char* line = buf; line < buf_end; line = line_end + 1)
- {
- // Skip new lines markers, then find end of the line
- while (*line == '\n' || *line == '\r')
- line++;
- line_end = line;
- while (line_end < buf_end && *line_end != '\n' && *line_end != '\r')
- line_end++;
- line_end[0] = 0;
- if (line[0] == ';')
- continue;
- if (line[0] == '[' && line_end > line && line_end[-1] == ']')
- {
- // Parse "[Type][Name]". Note that 'Name' can itself contains [] characters, which is acceptable with the current format and parsing code.
- line_end[-1] = 0;
- const char* name_end = line_end - 1;
- const char* type_start = line + 1;
- char* type_end = (char*)(intptr_t)ImStrchrRange(type_start, name_end, ']');
- const char* name_start = type_end ? ImStrchrRange(type_end + 1, name_end, '[') : NULL;
- if (!type_end || !name_start)
- {
- name_start = type_start; // Import legacy entries that have no type
- type_start = "Window";
- }
- else
- {
- *type_end = 0; // Overwrite first ']'
- name_start++; // Skip second '['
- }
- entry_handler = FindSettingsHandler(type_start);
- entry_data = entry_handler ? entry_handler->ReadOpenFn(&g, entry_handler, name_start) : NULL;
- }
- else if (entry_handler != NULL && entry_data != NULL)
- {
- // Let type handler parse the line
- entry_handler->ReadLineFn(&g, entry_handler, entry_data, line);
- }
- }
- IM_FREE(buf);
- g.SettingsLoaded = true;
- DockContextOnLoadSettings(&g);
-}
-
-void ImGui::SaveIniSettingsToDisk(const char* ini_filename)
-{
- ImGuiContext& g = *GImGui;
- g.SettingsDirtyTimer = 0.0f;
- if (!ini_filename)
- return;
-
- size_t ini_data_size = 0;
- const char* ini_data = SaveIniSettingsToMemory(&ini_data_size);
- FILE* f = ImFileOpen(ini_filename, "wt");
- if (!f)
- return;
- fwrite(ini_data, sizeof(char), ini_data_size, f);
- fclose(f);
-}
-
-// Call registered handlers (e.g. SettingsHandlerWindow_WriteAll() + custom handlers) to write their stuff into a text buffer
-const char* ImGui::SaveIniSettingsToMemory(size_t* out_size)
-{
- ImGuiContext& g = *GImGui;
- g.SettingsDirtyTimer = 0.0f;
- g.SettingsIniData.Buf.resize(0);
- g.SettingsIniData.Buf.push_back(0);
- for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
- {
- ImGuiSettingsHandler* handler = &g.SettingsHandlers[handler_n];
- handler->WriteAllFn(&g, handler, &g.SettingsIniData);
- }
- if (out_size)
- *out_size = (size_t)g.SettingsIniData.size();
- return g.SettingsIniData.c_str();
-}
-
-static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
-{
- ImGuiWindowSettings* settings = ImGui::FindWindowSettings(ImHashStr(name));
- if (!settings)
- settings = ImGui::CreateNewWindowSettings(name);
- return (void*)settings;
-}
-
-static void SettingsHandlerWindow_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line)
-{
- ImGuiWindowSettings* settings = (ImGuiWindowSettings*)entry;
- int x, y;
- int i;
- ImU32 u1;
- if (sscanf(line, "Pos=%i,%i", &x, &y) == 2) { settings->Pos = ImVec2ih((short)x, (short)y); }
- else if (sscanf(line, "Size=%i,%i", &x, &y) == 2) { settings->Size = ImVec2ih((short)x, (short)y); }
- else if (sscanf(line, "ViewportId=0x%08X", &u1) == 1) { settings->ViewportId = u1; }
- else if (sscanf(line, "ViewportPos=%i,%i", &x, &y) == 2) { settings->ViewportPos = ImVec2ih((short)x, (short)y); }
- else if (sscanf(line, "Collapsed=%d", &i) == 1) { settings->Collapsed = (i != 0); }
- else if (sscanf(line, "DockId=0x%X,%d", &u1, &i) == 2) { settings->DockId = u1; settings->DockOrder = (short)i; }
- else if (sscanf(line, "DockId=0x%X", &u1) == 1) { settings->DockId = u1; settings->DockOrder = -1; }
- else if (sscanf(line, "ClassId=0x%X", &u1) == 1) { settings->ClassId = u1; }
-}
-
-static void SettingsHandlerWindow_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf)
-{
- // Gather data from windows that were active during this session
- // (if a window wasn't opened in this session we preserve its settings)
- ImGuiContext& g = *ctx;
- for (int i = 0; i != g.Windows.Size; i++)
- {
- ImGuiWindow* window = g.Windows[i];
- if (window->Flags & ImGuiWindowFlags_NoSavedSettings)
- continue;
-
- ImGuiWindowSettings* settings = (window->SettingsIdx != -1) ? &g.SettingsWindows[window->SettingsIdx] : ImGui::FindWindowSettings(window->ID);
- if (!settings)
- {
- settings = ImGui::CreateNewWindowSettings(window->Name);
- window->SettingsIdx = g.SettingsWindows.index_from_ptr(settings);
- }
- IM_ASSERT(settings->ID == window->ID);
- settings->Pos = ImVec2ih(window->Pos - window->ViewportPos);
- settings->Size = ImVec2ih(window->SizeFull);
- settings->ViewportId = window->ViewportId;
- settings->ViewportPos = ImVec2ih(window->ViewportPos);
- IM_ASSERT(window->DockNode == NULL || window->DockNode->ID == window->DockId);
- settings->DockId = window->DockId;
- settings->ClassId = window->WindowClass.ClassId;
- settings->DockOrder = window->DockOrder;
- settings->Collapsed = window->Collapsed;
- }
-
- // Write to text buffer
- buf->reserve(buf->size() + g.SettingsWindows.Size * 96); // ballpark reserve
- for (int i = 0; i != g.SettingsWindows.Size; i++)
- {
- const ImGuiWindowSettings* settings = &g.SettingsWindows[i];
- buf->appendf("[%s][%s]\n", handler->TypeName, settings->Name);
- if (settings->ViewportId != 0 && settings->ViewportId != ImGui::IMGUI_VIEWPORT_DEFAULT_ID)
- {
- buf->appendf("ViewportPos=%d,%d\n", settings->ViewportPos.x, settings->ViewportPos.y);
- buf->appendf("ViewportId=0x%08X\n", settings->ViewportId);
- }
- if (settings->Pos.x != 0 || settings->Pos.y != 0 || settings->ViewportId == ImGui::IMGUI_VIEWPORT_DEFAULT_ID)
- buf->appendf("Pos=%d,%d\n", settings->Pos.x, settings->Pos.y);
- if (settings->Size.x != 0 || settings->Size.y != 0)
- buf->appendf("Size=%d,%d\n", settings->Size.x, settings->Size.y);
- buf->appendf("Collapsed=%d\n", settings->Collapsed);
- if (settings->DockId != 0)
- {
- // Write DockId as 4 digits if possible. Automatic DockId are small numbers, but full explicit DockSpace() are full ImGuiID range.
- if (settings->DockOrder == -1)
- buf->appendf("DockId=0x%08X\n", settings->DockId);
- else
- buf->appendf("DockId=0x%08X,%d\n", settings->DockId, settings->DockOrder);
- if (settings->ClassId != 0)
- buf->appendf("ClassId=0x%08X\n", settings->ClassId);
- }
- buf->appendf("\n");
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// [SECTION] VIEWPORTS, PLATFORM WINDOWS
-//-----------------------------------------------------------------------------
-// - GetMainViewport()
-// - FindViewportByID()
-// - FindViewportByPlatformHandle()
-// - SetCurrentViewport() [Internal]
-// - SetWindowViewport() [Internal]
-// - GetWindowAlwaysWantOwnViewport() [Internal]
-// - UpdateTryMergeWindowIntoHostViewport() [Internal]
-// - UpdateTryMergeWindowIntoHostViewports() [Internal]
-// - TranslateWindowsInViewport() [Internal]
-// - ScaleWindowsInViewport() [Internal]
-// - FindHoveredViewportFromPlatformWindowStack() [Internal]
-// - UpdateViewportsNewFrame() [Internal]
-// - UpdateViewportsEndFrame() [Internal]
-// - AddUpdateViewport() [Internal]
-// - UpdateSelectWindowViewport() [Internal]
-// - UpdatePlatformWindows()
-// - RenderPlatformWindowsDefault()
-// - FindPlatformMonitorForPos() [Internal]
-// - FindPlatformMonitorForRect() [Internal]
-// - UpdateViewportPlatformMonitor() [Internal]
-// - DestroyPlatformWindow() [Internal]
-// - DestroyPlatformWindows()
-//-----------------------------------------------------------------------------
-
-ImGuiViewport* ImGui::GetMainViewport()
-{
- ImGuiContext& g = *GImGui;
- return g.Viewports[0];
-}
-
-ImGuiViewport* ImGui::FindViewportByID(ImGuiID id)
-{
- ImGuiContext& g = *GImGui;
- for (int n = 0; n < g.Viewports.Size; n++)
- if (g.Viewports[n]->ID == id)
- return g.Viewports[n];
- return NULL;
-}
-
-ImGuiViewport* ImGui::FindViewportByPlatformHandle(void* platform_handle)
-{
- ImGuiContext& g = *GImGui;
- for (int i = 0; i != g.Viewports.Size; i++)
- if (g.Viewports[i]->PlatformHandle == platform_handle)
- return g.Viewports[i];
- return NULL;
-}
-
-void ImGui::SetCurrentViewport(ImGuiWindow* current_window, ImGuiViewportP* viewport)
-{
- ImGuiContext& g = *GImGui;
- (void)current_window;
-
- if (viewport)
- viewport->LastFrameActive = g.FrameCount;
- if (g.CurrentViewport == viewport)
- return;
- g.CurrentViewport = viewport;
- //IMGUI_DEBUG_LOG_VIEWPORT("SetCurrentViewport changed '%s' 0x%08X\n", current_window ? current_window->Name : NULL, viewport ? viewport->ID : 0);
-
- // Notify platform layer of viewport changes
- // FIXME-DPI: This is only currently used for experimenting with handling of multiple DPI
- if (g.CurrentViewport && g.PlatformIO.Platform_OnChangedViewport)
- g.PlatformIO.Platform_OnChangedViewport(g.CurrentViewport);
-}
-
-static void SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport)
-{
- window->Viewport = viewport;
- window->ViewportId = viewport->ID;
- window->ViewportOwned = (viewport->Window == window);
-}
-
-static bool ImGui::GetWindowAlwaysWantOwnViewport(ImGuiWindow* window)
-{
- // Tooltips and menus are not automatically forced into their own viewport when the NoMerge flag is set, however the multiplication of viewports makes them more likely to protrude and create their own.
- ImGuiContext& g = *GImGui;
- if (g.IO.ConfigViewportsNoAutoMerge || (window->WindowClass.ViewportFlagsOverrideSet & ImGuiViewportFlags_NoAutoMerge))
- if (g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable)
- if (!window->DockIsActive)
- if ((window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_Tooltip)) == 0)
- if ((window->Flags & ImGuiWindowFlags_Popup) == 0 || (window->Flags & ImGuiWindowFlags_Modal) != 0)
- return true;
- return false;
-}
-
-static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImGuiViewportP* viewport)
-{
- ImGuiContext& g = *GImGui;
- if (!(viewport->Flags & (ImGuiViewportFlags_CanHostOtherWindows | ImGuiViewportFlags_Minimized)) || window->Viewport == viewport)
- return false;
- if (!viewport->GetRect().Contains(window->Rect()))
- return false;
- if (GetWindowAlwaysWantOwnViewport(window))
- return false;
+ window->DC.CurrLineTextBaseOffset = ImMax(window->DC.PrevLineTextBaseOffset, group_data.BackupCurrLineTextBaseOffset); // FIXME: Incorrect, we should grab the base offset from the *first line* of the group but it is hard to obtain now.
+ ItemSize(group_bb.GetSize());
+ ItemAdd(group_bb, 0);
- for (int n = 0; n < g.Windows.Size; n++)
- {
- ImGuiWindow* window_behind = g.Windows[n];
- if (window_behind == window)
- break;
- if (window_behind->WasActive && window_behind->ViewportOwned && !(window_behind->Flags & ImGuiWindowFlags_ChildWindow))
- if (window_behind->Viewport->GetRect().Overlaps(window->Rect()))
- return false;
- }
+ // If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive(), IsItemDeactivated() etc. will be functional on the entire group.
+ // It would be be neater if we replaced window.DC.LastItemId by e.g. 'bool LastItemIsActive', but would put a little more burden on individual widgets.
+ // Also if you grep for LastItemId you'll notice it is only used in that context.
+ // (The tests not symmetrical because ActiveIdIsAlive is an ID itself, in order to be able to handle ActiveId being overwritten during the frame.)
+ const bool group_contains_curr_active_id = (group_data.BackupActiveIdIsAlive != g.ActiveId) && (g.ActiveIdIsAlive == g.ActiveId) && g.ActiveId;
+ const bool group_contains_prev_active_id = !group_data.BackupActiveIdPreviousFrameIsAlive && g.ActiveIdPreviousFrameIsAlive;
+ if (group_contains_curr_active_id)
+ window->DC.LastItemId = g.ActiveId;
+ else if (group_contains_prev_active_id)
+ window->DC.LastItemId = g.ActiveIdPreviousFrame;
+ window->DC.LastItemRect = group_bb;
- // Move to the existing viewport, Move child/hosted windows as well (FIXME-OPT: iterate child)
- ImGuiViewportP* old_viewport = window->Viewport;
- if (window->ViewportOwned)
- for (int n = 0; n < g.Windows.Size; n++)
- if (g.Windows[n]->Viewport == old_viewport)
- SetWindowViewport(g.Windows[n], viewport);
- SetWindowViewport(window, viewport);
- BringWindowToDisplayFront(window);
+ // Forward Edited flag
+ if (group_contains_curr_active_id && g.ActiveIdHasBeenEditedThisFrame)
+ window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Edited;
- return true;
-}
+ // Forward Deactivated flag
+ window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HasDeactivated;
+ if (group_contains_prev_active_id && g.ActiveId != g.ActiveIdPreviousFrame)
+ window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Deactivated;
-static bool ImGui::UpdateTryMergeWindowIntoHostViewports(ImGuiWindow* window)
-{
- ImGuiContext& g = *GImGui;
- return UpdateTryMergeWindowIntoHostViewport(window, g.Viewports[0]);
+ window->DC.GroupStack.pop_back();
+ //window->DrawList->AddRect(group_bb.Min, group_bb.Max, IM_COL32(255,0,255,255)); // [Debug]
}
-// Translate imgui windows when a Host Viewport has been moved
-// (This additionally keeps windows at the same place when ImGuiConfigFlags_ViewportsEnable is toggled!)
-void ImGui::TranslateWindowsInViewport(ImGuiViewportP* viewport, const ImVec2& old_pos, const ImVec2& new_pos)
-{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(viewport->Window == NULL && (viewport->Flags & ImGuiViewportFlags_CanHostOtherWindows));
- // 1) We test if ImGuiConfigFlags_ViewportsEnable was just toggled, which allows us to conveniently
- // translate imgui windows from OS-window-local to absolute coordinates or vice-versa.
- // 2) If it's not going to fit into the new size, keep it at same absolute position.
- // One problem with this is that most Win32 applications doesn't update their render while dragging,
- // and so the window will appear to teleport when releasing the mouse.
- const bool translate_all_windows = (g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable) != (g.ConfigFlagsLastFrame & ImGuiConfigFlags_ViewportsEnable);
- ImRect test_still_fit_rect(old_pos, old_pos + viewport->Size);
- ImVec2 delta_pos = new_pos - old_pos;
- for (int window_n = 0; window_n < g.Windows.Size; window_n++) // FIXME-OPT
- if (translate_all_windows || (g.Windows[window_n]->Viewport == viewport && test_still_fit_rect.Contains(g.Windows[window_n]->Rect())))
- TranslateWindow(g.Windows[window_n], delta_pos);
-}
+//-----------------------------------------------------------------------------
+// [SECTION] SCROLLING
+//-----------------------------------------------------------------------------
-// Scale all windows (position, size). Use when e.g. changing DPI. (This is a lossy operation!)
-void ImGui::ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale)
+static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window, bool snap_on_edges)
{
ImGuiContext& g = *GImGui;
- if (viewport->Window)
+ ImVec2 scroll = window->Scroll;
+ if (window->ScrollTarget.x < FLT_MAX)
{
- ScaleWindow(viewport->Window, scale);
+ float cr_x = window->ScrollTargetCenterRatio.x;
+ float target_x = window->ScrollTarget.x;
+ if (snap_on_edges && cr_x <= 0.0f && target_x <= window->WindowPadding.x)
+ target_x = 0.0f;
+ else if (snap_on_edges && cr_x >= 1.0f && target_x >= window->ContentSize.x + window->WindowPadding.x + g.Style.ItemSpacing.x)
+ target_x = window->ContentSize.x + window->WindowPadding.x * 2.0f;
+ scroll.x = target_x - cr_x * (window->SizeFull.x - window->ScrollbarSizes.x);
}
- else
+ if (window->ScrollTarget.y < FLT_MAX)
{
- for (int i = 0; i != g.Windows.Size; i++)
- if (g.Windows[i]->Viewport == viewport)
- ScaleWindow(g.Windows[i], scale);
+ // 'snap_on_edges' allows for a discontinuity at the edge of scrolling limits to take account of WindowPadding so that scrolling to make the last item visible scroll far enough to see the padding.
+ float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight();
+ float cr_y = window->ScrollTargetCenterRatio.y;
+ float target_y = window->ScrollTarget.y;
+ if (snap_on_edges && cr_y <= 0.0f && target_y <= window->WindowPadding.y)
+ target_y = 0.0f;
+ if (snap_on_edges && cr_y >= 1.0f && target_y >= window->ContentSize.y + window->WindowPadding.y + g.Style.ItemSpacing.y)
+ target_y = window->ContentSize.y + window->WindowPadding.y * 2.0f;
+ scroll.y = target_y - cr_y * (window->SizeFull.y - window->ScrollbarSizes.y - decoration_up_height);
}
-}
-
-// If the back-end doesn't set MouseLastHoveredViewport or doesn't honor ImGuiViewportFlags_NoInputs, we do a search ourselves.
-// A) It won't take account of the possibility that non-imgui windows may be in-between our dragged window and our target window.
-// B) It requires Platform_GetWindowFocus to be implemented by back-end.
-static ImGuiViewportP* FindHoveredViewportFromPlatformWindowStack(const ImVec2 mouse_platform_pos)
-{
- ImGuiContext& g = *GImGui;
- ImGuiViewportP* best_candidate = NULL;
- for (int n = 0; n < g.Viewports.Size; n++)
+ scroll.x = IM_FLOOR(ImMax(scroll.x, 0.0f));
+ scroll.y = IM_FLOOR(ImMax(scroll.y, 0.0f));
+ if (!window->Collapsed && !window->SkipItems)
{
- ImGuiViewportP* viewport = g.Viewports[n];
- if (!(viewport->Flags & (ImGuiViewportFlags_NoInputs | ImGuiViewportFlags_Minimized)) && viewport->GetRect().Contains(mouse_platform_pos))
- if (best_candidate == NULL || best_candidate->LastFrontMostStampCount < viewport->LastFrontMostStampCount)
- best_candidate = viewport;
+ scroll.x = ImMin(scroll.x, window->ScrollMax.x);
+ scroll.y = ImMin(scroll.y, window->ScrollMax.y);
}
- return best_candidate;
+ return scroll;
}
-// Update viewports and monitor infos
-// Note that this is running even if 'ImGuiConfigFlags_ViewportsEnable' is not set, in order to clear unused viewports (if any) and update monitor info.
-static void ImGui::UpdateViewportsNewFrame()
+// Scroll to keep newly navigated item fully into view
+ImVec2 ImGui::ScrollToBringRectIntoView(ImGuiWindow* window, const ImRect& item_rect)
{
ImGuiContext& g = *GImGui;
- IM_ASSERT(g.PlatformIO.Viewports.Size <= g.Viewports.Size);
-
- // Update Minimized status (we need it first in order to decide if we'll apply Pos/Size of the main viewport)
- if ((g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable))
- {
- for (int n = 0; n < g.Viewports.Size; n++)
- {
- ImGuiViewportP* viewport = g.Viewports[n];
- const bool platform_funcs_available = viewport->PlatformWindowCreated;
- if (g.PlatformIO.Platform_GetWindowMinimized && platform_funcs_available)
- {
- bool minimized = g.PlatformIO.Platform_GetWindowMinimized(viewport);
- if (minimized)
- viewport->Flags |= ImGuiViewportFlags_Minimized;
- else
- viewport->Flags &= ~ImGuiViewportFlags_Minimized;
- }
- }
- }
-
- // Create/update main viewport with current platform position and size
- ImGuiViewportP* main_viewport = g.Viewports[0];
- IM_ASSERT(main_viewport->ID == IMGUI_VIEWPORT_DEFAULT_ID);
- IM_ASSERT(main_viewport->Window == NULL);
- ImVec2 main_viewport_platform_pos = ImVec2(0.0f, 0.0f);
- ImVec2 main_viewport_platform_size = g.IO.DisplaySize;
- if (g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable)
- main_viewport_platform_pos = (main_viewport->Flags & ImGuiViewportFlags_Minimized) ? main_viewport->Pos : g.PlatformIO.Platform_GetWindowPos(main_viewport);
- AddUpdateViewport(NULL, IMGUI_VIEWPORT_DEFAULT_ID, main_viewport_platform_pos, main_viewport_platform_size, ImGuiViewportFlags_CanHostOtherWindows);
-
- g.CurrentViewport = NULL;
- g.MouseViewport = NULL;
- for (int n = 0; n < g.Viewports.Size; n++)
- {
- ImGuiViewportP* viewport = g.Viewports[n];
- viewport->Idx = n;
-
- // Erase unused viewports
- if (n > 0 && viewport->LastFrameActive < g.FrameCount - 2)
- {
- // Clear references to this viewport in windows (window->ViewportId becomes the master data)
- for (int window_n = 0; window_n < g.Windows.Size; window_n++)
- if (g.Windows[window_n]->Viewport == viewport)
- {
- g.Windows[window_n]->Viewport = NULL;
- g.Windows[window_n]->ViewportOwned = false;
- }
- if (viewport == g.MouseLastHoveredViewport)
- g.MouseLastHoveredViewport = NULL;
- g.Viewports.erase(g.Viewports.Data + n);
-
- // Destroy
- IMGUI_DEBUG_LOG_VIEWPORT("Delete Viewport %08X (%s)\n", viewport->ID, viewport->Window ? viewport->Window->Name : "n/a");
- DestroyPlatformWindow(viewport); // In most circumstances the platform window will already be destroyed here.
- IM_ASSERT(g.PlatformIO.Viewports.contains(viewport) == false);
- IM_DELETE(viewport);
- n--;
- continue;
- }
-
- const bool platform_funcs_available = viewport->PlatformWindowCreated;
- if ((g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable))
- {
- // Update Position and Size (from Platform Window to ImGui) if requested.
- // We do it early in the frame instead of waiting for UpdatePlatformWindows() to avoid a frame of lag when moving/resizing using OS facilities.
- if (!(viewport->Flags & ImGuiViewportFlags_Minimized) && platform_funcs_available)
- {
- if (viewport->PlatformRequestMove)
- viewport->Pos = viewport->LastPlatformPos = g.PlatformIO.Platform_GetWindowPos(viewport);
- if (viewport->PlatformRequestResize)
- viewport->Size = viewport->LastPlatformSize = g.PlatformIO.Platform_GetWindowSize(viewport);
- }
- }
-
- // Update/copy monitor info
- UpdateViewportPlatformMonitor(viewport);
-
- // Reset alpha every frame. Users of transparency (docking) needs to request a lower alpha back.
- viewport->Alpha = 1.0f;
-
- // Translate imgui windows when a Host Viewport has been moved
- // (This additionally keeps windows at the same place when ImGuiConfigFlags_ViewportsEnable is toggled!)
- const ImVec2 viewport_delta_pos = viewport->Pos - viewport->LastPos;
- if ((viewport->Flags & ImGuiViewportFlags_CanHostOtherWindows) && (viewport_delta_pos.x != 0.0f || viewport_delta_pos.y != 0.0f))
- TranslateWindowsInViewport(viewport, viewport->LastPos, viewport->Pos);
-
- // Update DPI scale
- float new_dpi_scale;
- if (g.PlatformIO.Platform_GetWindowDpiScale && platform_funcs_available)
- new_dpi_scale = g.PlatformIO.Platform_GetWindowDpiScale(viewport);
- else if (viewport->PlatformMonitor != -1)
- new_dpi_scale = g.PlatformIO.Monitors[viewport->PlatformMonitor].DpiScale;
- else
- new_dpi_scale = (viewport->DpiScale != 0.0f) ? viewport->DpiScale : 1.0f;
- if (viewport->DpiScale != 0.0f && new_dpi_scale != viewport->DpiScale)
- {
- float scale_factor = new_dpi_scale / viewport->DpiScale;
- if (g.IO.ConfigFlags & ImGuiConfigFlags_DpiEnableScaleViewports)
- ScaleWindowsInViewport(viewport, scale_factor);
- //if (viewport == GetMainViewport())
- // g.PlatformInterface.SetWindowSize(viewport, viewport->Size * scale_factor);
-
- // Scale our window moving pivot so that the window will rescale roughly around the mouse position.
- // FIXME-VIEWPORT: This currently creates a resizing feedback loop when a window is straddling a DPI transition border.
- // (Minor: since our sizes do not perfectly linearly scale, deferring the click offset scale until we know the actual window scale ratio may get us slightly more precise mouse positioning.)
- //if (g.MovingWindow != NULL && g.MovingWindow->Viewport == viewport)
- // g.ActiveIdClickOffset = ImFloor(g.ActiveIdClickOffset * scale_factor);
- }
- viewport->DpiScale = new_dpi_scale;
- }
+ ImRect window_rect(window->InnerRect.Min - ImVec2(1, 1), window->InnerRect.Max + ImVec2(1, 1));
+ //GetForegroundDrawList(window)->AddRect(window_rect.Min, window_rect.Max, IM_COL32_WHITE); // [DEBUG]
- if (!(g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable))
+ ImVec2 delta_scroll;
+ if (!window_rect.Contains(item_rect))
{
- g.MouseViewport = main_viewport;
- return;
- }
+ if (window->ScrollbarX && item_rect.Min.x < window_rect.Min.x)
+ SetScrollFromPosX(window, item_rect.Min.x - window->Pos.x + g.Style.ItemSpacing.x, 0.0f);
+ else if (window->ScrollbarX && item_rect.Max.x >= window_rect.Max.x)
+ SetScrollFromPosX(window, item_rect.Max.x - window->Pos.x + g.Style.ItemSpacing.x, 1.0f);
+ if (item_rect.Min.y < window_rect.Min.y)
+ SetScrollFromPosY(window, item_rect.Min.y - window->Pos.y - g.Style.ItemSpacing.y, 0.0f);
+ else if (item_rect.Max.y >= window_rect.Max.y)
+ SetScrollFromPosY(window, item_rect.Max.y - window->Pos.y + g.Style.ItemSpacing.y, 1.0f);
- // Mouse handling: decide on the actual mouse viewport for this frame between the active/focused viewport and the hovered viewport.
- // Note that 'viewport_hovered' should skip over any viewport that has the ImGuiViewportFlags_NoInputs flags set.
- ImGuiViewportP* viewport_hovered = NULL;
- if (g.IO.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport)
- {
- viewport_hovered = g.IO.MouseHoveredViewport ? (ImGuiViewportP*)FindViewportByID(g.IO.MouseHoveredViewport) : NULL;
- if (viewport_hovered && (viewport_hovered->Flags & ImGuiViewportFlags_NoInputs))
- {
- // Back-end failed at honoring its contract if it returned a viewport with the _NoInputs flag.
- IM_ASSERT(0);
- viewport_hovered = FindHoveredViewportFromPlatformWindowStack(g.IO.MousePos);
- }
- }
- else
- {
- // If the back-end doesn't know how to honor ImGuiViewportFlags_NoInputs, we do a search ourselves. Note that this search:
- // A) won't take account of the possibility that non-imgui windows may be in-between our dragged window and our target window.
- // B) uses LastFrameAsRefViewport as a flawed replacement for the last time a window was focused (we could/should fix that by introducing Focus functions in PlatformIO)
- viewport_hovered = FindHoveredViewportFromPlatformWindowStack(g.IO.MousePos);
+ ImVec2 next_scroll = CalcNextScrollFromScrollTargetAndClamp(window, false);
+ delta_scroll = next_scroll - window->Scroll;
}
- if (viewport_hovered != NULL)
- g.MouseLastHoveredViewport = viewport_hovered;
- else if (g.MouseLastHoveredViewport == NULL)
- g.MouseLastHoveredViewport = g.Viewports[0];
- // Update mouse reference viewport
- // (when moving a window we aim at its viewport, but this will be overwritten below if we go in drag and drop mode)
- if (g.MovingWindow)
- g.MouseViewport = g.MovingWindow->Viewport;
- else
- g.MouseViewport = g.MouseLastHoveredViewport;
-
- // When dragging something, always refer to the last hovered viewport.
- // - when releasing a moving window we will revert to aiming behind (at viewport_hovered)
- // - when we are between viewports, our dragged preview will tend to show in the last viewport _even_ if we don't have tooltips in their viewports (when lacking monitor info)
- // - consider the case of holding on a menu item to browse child menus: even thou a mouse button is held, there's no active id because menu items only react on mouse release.
- const bool is_mouse_dragging_with_an_expected_destination = g.DragDropActive;
- if (is_mouse_dragging_with_an_expected_destination && viewport_hovered == NULL)
- viewport_hovered = g.MouseLastHoveredViewport;
- if (is_mouse_dragging_with_an_expected_destination || g.ActiveId == 0 || !IsAnyMouseDown())
- if (viewport_hovered != NULL && viewport_hovered != g.MouseViewport && !(viewport_hovered->Flags & ImGuiViewportFlags_NoInputs))
- g.MouseViewport = viewport_hovered;
+ // Also scroll parent window to keep us into view if necessary
+ if (window->Flags & ImGuiWindowFlags_ChildWindow)
+ delta_scroll += ScrollToBringRectIntoView(window->ParentWindow, ImRect(item_rect.Min - delta_scroll, item_rect.Max - delta_scroll));
- IM_ASSERT(g.MouseViewport != NULL);
+ return delta_scroll;
}
-// Update user-facing viewport list (g.Viewports -> g.PlatformIO.Viewports after filtering out some)
-static void ImGui::UpdateViewportsEndFrame()
+float ImGui::GetScrollX()
{
- ImGuiContext& g = *GImGui;
- g.PlatformIO.MainViewport = g.Viewports[0];
- g.PlatformIO.Viewports.resize(0);
- for (int i = 0; i < g.Viewports.Size; i++)
- {
- ImGuiViewportP* viewport = g.Viewports[i];
- viewport->LastPos = viewport->Pos;
- if (viewport->LastFrameActive < g.FrameCount || viewport->Size.x <= 0.0f || viewport->Size.y <= 0.0f)
- if (i > 0) // Always include main viewport in the list
- continue;
- if (viewport->Window && !IsWindowActiveAndVisible(viewport->Window))
- continue;
- if (i > 0)
- IM_ASSERT(viewport->Window != NULL);
- g.PlatformIO.Viewports.push_back(viewport);
- }
- g.Viewports[0]->ClearRequestFlags(); // Clear main viewport flags because UpdatePlatformWindows() won't do it and may not even be called
+ ImGuiWindow* window = GImGui->CurrentWindow;
+ return window->Scroll.x;
}
-// FIXME: We should ideally refactor the system to call this every frame (we currently don't)
-ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const ImVec2& pos, const ImVec2& size, ImGuiViewportFlags flags)
+float ImGui::GetScrollY()
{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(id != 0);
-
- if (window != NULL)
- {
- if (g.MovingWindow && g.MovingWindow->RootWindow == window)
- flags |= ImGuiViewportFlags_NoInputs | ImGuiViewportFlags_NoFocusOnAppearing;
- if ((window->Flags & ImGuiWindowFlags_NoMouseInputs) && (window->Flags & ImGuiWindowFlags_NoNavInputs))
- flags |= ImGuiViewportFlags_NoInputs;
- if (window->Flags & ImGuiWindowFlags_NoFocusOnAppearing)
- flags |= ImGuiViewportFlags_NoFocusOnAppearing;
- }
-
- ImGuiViewportP* viewport = (ImGuiViewportP*)FindViewportByID(id);
- if (viewport)
- {
- if (!viewport->PlatformRequestMove)
- viewport->Pos = pos;
- if (!viewport->PlatformRequestResize)
- viewport->Size = size;
- viewport->Flags = flags | (viewport->Flags & ImGuiViewportFlags_Minimized); // Preserve existing flags
- }
- else
- {
- // New viewport
- viewport = IM_NEW(ImGuiViewportP)();
- viewport->ID = id;
- viewport->Idx = g.Viewports.Size;
- viewport->Pos = viewport->LastPos = pos;
- viewport->Size = size;
- viewport->Flags = flags;
- UpdateViewportPlatformMonitor(viewport);
- g.Viewports.push_back(viewport);
- IMGUI_DEBUG_LOG_VIEWPORT("Add Viewport %08X (%s)\n", id, window->Name);
-
- // We normally setup for all viewports in NewFrame() but here need to handle the mid-frame creation of a new viewport.
- // We need to extend the fullscreen clip rect so the OverlayDrawList clip is correct for that the first frame
- g.DrawListSharedData.ClipRectFullscreen.x = ImMin(g.DrawListSharedData.ClipRectFullscreen.x, viewport->Pos.x);
- g.DrawListSharedData.ClipRectFullscreen.y = ImMin(g.DrawListSharedData.ClipRectFullscreen.y, viewport->Pos.y);
- g.DrawListSharedData.ClipRectFullscreen.z = ImMax(g.DrawListSharedData.ClipRectFullscreen.z, viewport->Pos.x + viewport->Size.x);
- g.DrawListSharedData.ClipRectFullscreen.w = ImMax(g.DrawListSharedData.ClipRectFullscreen.w, viewport->Pos.y + viewport->Size.y);
-
- // Store initial DpiScale before the OS platform window creation, based on expected monitor data.
- // This is so we can select an appropriate font size on the first frame of our window lifetime
- if (viewport->PlatformMonitor != -1)
- viewport->DpiScale = g.PlatformIO.Monitors[viewport->PlatformMonitor].DpiScale;
- }
-
- viewport->Window = window;
- viewport->LastFrameActive = g.FrameCount;
- IM_ASSERT(window == NULL || viewport->ID == window->ID);
-
- if (window != NULL)
- window->ViewportOwned = true;
-
- return viewport;
+ ImGuiWindow* window = GImGui->CurrentWindow;
+ return window->Scroll.y;
}
-// FIXME-VIEWPORT: This is all super messy and ought to be clarified or rewritten.
-static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
+float ImGui::GetScrollMaxX()
{
- ImGuiContext& g = *GImGui;
- ImGuiWindowFlags flags = window->Flags;
- window->ViewportAllowPlatformMonitorExtend = -1;
-
- // Restore main viewport if multi-viewport is not supported by the back-end
- ImGuiViewportP* main_viewport = g.Viewports[0];
- if (!(g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable))
- {
- SetWindowViewport(window, main_viewport);
- return;
- }
- window->ViewportOwned = false;
-
- // Appearing popups reset their viewport so they can inherit again
- if ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) && window->Appearing)
- {
- window->Viewport = NULL;
- window->ViewportId = 0;
- }
-
- if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasViewport) == 0)
- {
- // By default inherit from parent window
- if (window->Viewport == NULL && window->ParentWindow && !window->ParentWindow->IsFallbackWindow)
- window->Viewport = window->ParentWindow->Viewport;
-
- // Attempt to restore saved viewport id (= window that hasn't been activated yet), try to restore the viewport based on saved 'window->ViewportPos' restored from .ini file
- if (window->Viewport == NULL && window->ViewportId != 0)
- {
- window->Viewport = (ImGuiViewportP*)FindViewportByID(window->ViewportId);
- if (window->Viewport == NULL && window->ViewportPos.x != FLT_MAX && window->ViewportPos.y != FLT_MAX)
- window->Viewport = AddUpdateViewport(window, window->ID, window->ViewportPos, window->Size, ImGuiViewportFlags_None);
- }
- }
-
- bool lock_viewport = false;
- if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasViewport)
- {
- // Code explicitly request a viewport
- window->Viewport = (ImGuiViewportP*)FindViewportByID(g.NextWindowData.ViewportId);
- window->ViewportId = g.NextWindowData.ViewportId; // Store ID even if Viewport isn't resolved yet.
- lock_viewport = true;
- }
- else if ((flags & ImGuiWindowFlags_ChildWindow) || (flags & ImGuiWindowFlags_ChildMenu))
- {
- // Always inherit viewport from parent window
- window->Viewport = window->ParentWindow->Viewport;
- }
- else if (flags & ImGuiWindowFlags_Tooltip)
- {
- window->Viewport = g.MouseViewport;
- }
- else if (GetWindowAlwaysWantOwnViewport(window))
- {
- window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_None);
- }
- else if (g.MovingWindow && g.MovingWindow->RootWindow == window && IsMousePosValid())
- {
- if (window->Viewport != NULL && window->Viewport->Window == window)
- window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_None);
- }
- else
- {
- // Merge into host viewport?
- // We cannot test window->ViewportOwned as it set lower in the function.
- bool try_to_merge_into_host_viewport = (window->Viewport && window == window->Viewport->Window && g.ActiveId == 0);
- if (try_to_merge_into_host_viewport)
- UpdateTryMergeWindowIntoHostViewports(window);
- }
-
- // Fallback to default viewport
- if (window->Viewport == NULL)
- window->Viewport = main_viewport;
-
- // Mark window as allowed to protrude outside of its viewport and into the current monitor
- if (!lock_viewport)
- {
- if (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup))
- {
- // We need to take account of the possibility that mouse may become invalid.
- // Popups/Tooltip always set ViewportAllowPlatformMonitorExtend so GetWindowAllowedExtentRect() will return full monitor bounds.
- ImVec2 mouse_ref = (flags & ImGuiWindowFlags_Tooltip) ? g.IO.MousePos : g.BeginPopupStack.back().OpenMousePos;
- bool use_mouse_ref = (g.NavDisableHighlight || !g.NavDisableMouseHover || !g.NavWindow);
- bool mouse_valid = IsMousePosValid(&mouse_ref);
- if ((window->Appearing || (flags & ImGuiWindowFlags_Tooltip)) && (!use_mouse_ref || mouse_valid))
- window->ViewportAllowPlatformMonitorExtend = FindPlatformMonitorForPos((use_mouse_ref && mouse_valid) ? mouse_ref : NavCalcPreferredRefPos());
- else
- window->ViewportAllowPlatformMonitorExtend = window->Viewport->PlatformMonitor;
- }
- else if (window->Viewport && window != window->Viewport->Window && window->Viewport->Window && !(flags & ImGuiWindowFlags_ChildWindow))
- {
- // When called from Begin() we don't have access to a proper version of the Hidden flag yet, so we replicate this code.
- const bool will_be_visible = (window->DockIsActive && !window->DockTabIsVisible) ? false : true;
- if ((window->Flags & ImGuiWindowFlags_DockNodeHost) && window->Viewport->LastFrameActive < g.FrameCount && will_be_visible)
- {
- // Steal/transfer ownership
- IMGUI_DEBUG_LOG_VIEWPORT("Window '%s' steal Viewport %08X from Window '%s'\n", window->Name, window->Viewport->ID, window->Viewport->Window->Name);
- window->Viewport->Window = window;
- window->Viewport->ID = window->ID;
- window->Viewport->LastNameHash = 0;
- }
- else if (!UpdateTryMergeWindowIntoHostViewports(window)) // Merge?
- {
- // New viewport
- window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_NoFocusOnAppearing);
- }
- }
- else if (window->ViewportAllowPlatformMonitorExtend < 0 && (flags & ImGuiWindowFlags_ChildWindow) == 0)
- {
- // Regular (non-child, non-popup) windows by default are also allowed to protrude
- // Child windows are kept contained within their parent.
- window->ViewportAllowPlatformMonitorExtend = window->Viewport->PlatformMonitor;
- }
- }
-
- // Update flags
- window->ViewportOwned = (window == window->Viewport->Window);
- window->ViewportId = window->Viewport->ID;
-
- // If the OS window has a title bar, hide our imgui title bar
- //if (window->ViewportOwned && !(window->Viewport->Flags & ImGuiViewportFlags_NoDecoration))
- // window->Flags |= ImGuiWindowFlags_NoTitleBar;
+ ImGuiWindow* window = GImGui->CurrentWindow;
+ return window->ScrollMax.x;
}
-// Called by user at the end of the main loop, after EndFrame()
-// This will handle the creation/update of all OS windows via function defined in the ImGuiPlatformIO api.
-void ImGui::UpdatePlatformWindows()
+float ImGui::GetScrollMaxY()
{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(g.FrameCountEnded == g.FrameCount && "Forgot to call Render() or EndFrame() before UpdatePlatformWindows()?");
- IM_ASSERT(g.FrameCountPlatformEnded < g.FrameCount);
- g.FrameCountPlatformEnded = g.FrameCount;
- if (!(g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable))
- return;
-
- // Create/resize/destroy platform windows to match each active viewport.
- // Skip the main viewport (index 0), which is always fully handled by the application!
- for (int i = 1; i < g.Viewports.Size; i++)
- {
- ImGuiViewportP* viewport = g.Viewports[i];
-
- // Destroy platform window if the viewport hasn't been submitted or if it is hosting a hidden window
- // (the implicit/fallback Debug##Default window will be registering its viewport then be disabled, causing a dummy DestroyPlatformWindow to be made each frame)
- bool destroy_platform_window = false;
- destroy_platform_window |= (viewport->LastFrameActive < g.FrameCount - 1);
- destroy_platform_window |= (viewport->Window && !IsWindowActiveAndVisible(viewport->Window));
- if (destroy_platform_window)
- {
- DestroyPlatformWindow(viewport);
- continue;
- }
-
- // New windows that appears directly in a new viewport won't always have a size on their first frame
- if (viewport->LastFrameActive < g.FrameCount || viewport->Size.x <= 0 || viewport->Size.y <= 0)
- continue;
-
- // Create window
- bool is_new_platform_window = (viewport->PlatformWindowCreated == false);
- if (is_new_platform_window)
- {
- IMGUI_DEBUG_LOG_VIEWPORT("Create Platform Window %08X (%s)\n", viewport->ID, viewport->Window ? viewport->Window->Name : "n/a");
- g.PlatformIO.Platform_CreateWindow(viewport);
- if (g.PlatformIO.Renderer_CreateWindow != NULL)
- g.PlatformIO.Renderer_CreateWindow(viewport);
- viewport->LastNameHash = 0;
- viewport->LastPlatformPos = viewport->LastPlatformSize = ImVec2(FLT_MAX, FLT_MAX); // By clearing those we'll enforce a call to Platform_SetWindowPos/Size below, before Platform_ShowWindow (FIXME: Is that necessary?)
- viewport->LastRendererSize = viewport->Size; // We don't need to call Renderer_SetWindowSize() as it is expected Renderer_CreateWindow() already did it.
- viewport->PlatformWindowCreated = true;
- }
-
- // Apply Position and Size (from ImGui to Platform/Renderer back-ends)
- if ((viewport->LastPlatformPos.x != viewport->Pos.x || viewport->LastPlatformPos.y != viewport->Pos.y) && !viewport->PlatformRequestMove)
- g.PlatformIO.Platform_SetWindowPos(viewport, viewport->Pos);
- if ((viewport->LastPlatformSize.x != viewport->Size.x || viewport->LastPlatformSize.y != viewport->Size.y) && !viewport->PlatformRequestResize)
- g.PlatformIO.Platform_SetWindowSize(viewport, viewport->Size);
- if ((viewport->LastRendererSize.x != viewport->Size.x || viewport->LastRendererSize.y != viewport->Size.y) && g.PlatformIO.Renderer_SetWindowSize)
- g.PlatformIO.Renderer_SetWindowSize(viewport, viewport->Size);
- viewport->LastPlatformPos = viewport->Pos;
- viewport->LastPlatformSize = viewport->LastRendererSize = viewport->Size;
-
- // Update title bar (if it changed)
- if (ImGuiWindow* window_for_title = GetWindowForTitleDisplay(viewport->Window))
- {
- const char* title_begin = window_for_title->Name;
- char* title_end = (char*)(intptr_t)FindRenderedTextEnd(title_begin);
- const ImGuiID title_hash = ImHashStr(title_begin, title_end - title_begin);
- if (viewport->LastNameHash != title_hash)
- {
- char title_end_backup_c = *title_end;
- *title_end = 0; // Cut existing buffer short instead of doing an alloc/free, no small gain.
- g.PlatformIO.Platform_SetWindowTitle(viewport, title_begin);
- *title_end = title_end_backup_c;
- viewport->LastNameHash = title_hash;
- }
- }
-
- // Update alpha (if it changed)
- if (viewport->LastAlpha != viewport->Alpha && g.PlatformIO.Platform_SetWindowAlpha)
- g.PlatformIO.Platform_SetWindowAlpha(viewport, viewport->Alpha);
- viewport->LastAlpha = viewport->Alpha;
+ ImGuiWindow* window = GImGui->CurrentWindow;
+ return window->ScrollMax.y;
+}
- // Optional, general purpose call to allow the back-end to perform general book-keeping even if things haven't changed.
- if (g.PlatformIO.Platform_UpdateWindow)
- g.PlatformIO.Platform_UpdateWindow(viewport);
+void ImGui::SetScrollX(float scroll_x)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ window->ScrollTarget.x = scroll_x;
+ window->ScrollTargetCenterRatio.x = 0.0f;
+}
- if (is_new_platform_window)
- {
- // On startup ensure new platform window don't steal focus (give it a few frames, as nested contents may lead to viewport being created a few frames late)
- if (g.FrameCount < 3)
- viewport->Flags |= ImGuiViewportFlags_NoFocusOnAppearing;
+void ImGui::SetScrollY(float scroll_y)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ window->ScrollTarget.y = scroll_y;
+ window->ScrollTargetCenterRatio.y = 0.0f;
+}
- // Show window
- g.PlatformIO.Platform_ShowWindow(viewport);
+void ImGui::SetScrollX(ImGuiWindow* window, float new_scroll_x)
+{
+ window->ScrollTarget.x = new_scroll_x;
+ window->ScrollTargetCenterRatio.x = 0.0f;
+}
- // Even without focus, we assume the window becomes front-most.
- // This is useful for our platform z-order heuristic when io.MouseHoveredViewport is not available.
- if (viewport->LastFrontMostStampCount != g.ViewportFrontMostStampCount)
- viewport->LastFrontMostStampCount = ++g.ViewportFrontMostStampCount;
- }
+void ImGui::SetScrollY(ImGuiWindow* window, float new_scroll_y)
+{
+ window->ScrollTarget.y = new_scroll_y;
+ window->ScrollTargetCenterRatio.y = 0.0f;
+}
- // Clear request flags
- viewport->ClearRequestFlags();
- }
- // Update our implicit z-order knowledge of platform windows, which is used when the back-end cannot provide io.MouseHoveredViewport.
- // When setting Platform_GetWindowFocus, it is expected that the platform back-end can handle calls without crashing if it doesn't have data stored.
- if (g.PlatformIO.Platform_GetWindowFocus != NULL)
- {
- ImGuiViewportP* focused_viewport = NULL;
- for (int n = 0; n < g.Viewports.Size && focused_viewport == NULL; n++)
- {
- ImGuiViewportP* viewport = g.Viewports[n];
- if (viewport->PlatformWindowCreated)
- if (g.PlatformIO.Platform_GetWindowFocus(viewport))
- focused_viewport = viewport;
- }
- if (focused_viewport && g.PlatformLastFocusedViewport != focused_viewport->ID)
- {
- if (focused_viewport->LastFrontMostStampCount != g.ViewportFrontMostStampCount)
- focused_viewport->LastFrontMostStampCount = ++g.ViewportFrontMostStampCount;
- g.PlatformLastFocusedViewport = focused_viewport->ID;
- }
- }
+void ImGui::SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio)
+{
+ // We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size
+ IM_ASSERT(center_x_ratio >= 0.0f && center_x_ratio <= 1.0f);
+ window->ScrollTarget.x = IM_FLOOR(local_x + window->Scroll.x);
+ window->ScrollTargetCenterRatio.x = center_x_ratio;
}
-// This is a default/basic function for performing the rendering/swap of multiple Platform Windows.
-// Custom renderers may prefer to not call this function at all, and instead iterate the publicly exposed platform data and handle rendering/sync themselves.
-// The Render/Swap functions stored in ImGuiPlatformIO are merely here to allow for this helper to exist, but you can do it yourself:
-//
-// ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
-// for (int i = 1; i < platform_io.Viewports.Size; i++)
-// if ((platform_io.Viewports[i]->Flags & ImGuiViewportFlags_Minimized) == 0)
-// MyRenderFunction(platform_io.Viewports[i], my_args);
-// for (int i = 1; i < platform_io.Viewports.Size; i++)
-// if ((platform_io.Viewports[i]->Flags & ImGuiViewportFlags_Minimized) == 0)
-// MySwapBufferFunction(platform_io.Viewports[i], my_args);
-//
-void ImGui::RenderPlatformWindowsDefault(void* platform_render_arg, void* renderer_render_arg)
+void ImGui::SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y_ratio)
{
- // Skip the main viewport (index 0), which is always fully handled by the application!
- ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
- for (int i = 1; i < platform_io.Viewports.Size; i++)
- {
- ImGuiViewport* viewport = platform_io.Viewports[i];
- if (viewport->Flags & ImGuiViewportFlags_Minimized)
- continue;
- if (platform_io.Platform_RenderWindow) platform_io.Platform_RenderWindow(viewport, platform_render_arg);
- if (platform_io.Renderer_RenderWindow) platform_io.Renderer_RenderWindow(viewport, renderer_render_arg);
- }
- for (int i = 1; i < platform_io.Viewports.Size; i++)
- {
- ImGuiViewport* viewport = platform_io.Viewports[i];
- if (viewport->Flags & ImGuiViewportFlags_Minimized)
- continue;
- if (platform_io.Platform_SwapBuffers) platform_io.Platform_SwapBuffers(viewport, platform_render_arg);
- if (platform_io.Renderer_SwapBuffers) platform_io.Renderer_SwapBuffers(viewport, renderer_render_arg);
- }
+ // We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size
+ IM_ASSERT(center_y_ratio >= 0.0f && center_y_ratio <= 1.0f);
+ const float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight();
+ local_y -= decoration_up_height;
+ window->ScrollTarget.y = IM_FLOOR(local_y + window->Scroll.y);
+ window->ScrollTargetCenterRatio.y = center_y_ratio;
}
-static int ImGui::FindPlatformMonitorForPos(const ImVec2& pos)
+void ImGui::SetScrollFromPosX(float local_x, float center_x_ratio)
{
ImGuiContext& g = *GImGui;
- for (int monitor_n = 0; monitor_n < g.PlatformIO.Monitors.Size; monitor_n++)
- {
- const ImGuiPlatformMonitor& monitor = g.PlatformIO.Monitors[monitor_n];
- if (ImRect(monitor.MainPos, monitor.MainPos + monitor.MainSize).Contains(pos))
- return monitor_n;
- }
- return -1;
+ SetScrollFromPosX(g.CurrentWindow, local_x, center_x_ratio);
}
-// Search for the monitor with the largest intersection area with the given rectangle
-// We generally try to avoid searching loops but the monitor count should be very small here
-// FIXME-OPT: We could test the last monitor used for that viewport first, and early
-static int ImGui::FindPlatformMonitorForRect(const ImRect& rect)
+void ImGui::SetScrollFromPosY(float local_y, float center_y_ratio)
{
ImGuiContext& g = *GImGui;
+ SetScrollFromPosY(g.CurrentWindow, local_y, center_y_ratio);
+}
- const int monitor_count = g.PlatformIO.Monitors.Size;
- if (monitor_count <= 1)
- return monitor_count - 1;
-
- // Use a minimum threshold of 1.0f so a zero-sized rect won't false positive, and will still find the correct monitor given its position.
- // This is necessary for tooltips which always resize down to zero at first.
- const float surface_threshold = ImMax(rect.GetWidth() * rect.GetHeight() * 0.5f, 1.0f);
- int best_monitor_n = -1;
- float best_monitor_surface = 0.001f;
+// center_x_ratio: 0.0f left of last item, 0.5f horizontal center of last item, 1.0f right of last item.
+void ImGui::SetScrollHereX(float center_x_ratio)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ float target_x = window->DC.LastItemRect.Min.x - window->Pos.x; // Left of last item, in window space
+ float last_item_width = window->DC.LastItemRect.GetWidth();
+ target_x += (last_item_width * center_x_ratio) + (g.Style.ItemSpacing.x * (center_x_ratio - 0.5f) * 2.0f); // Precisely aim before, in the middle or after the last item.
+ SetScrollFromPosX(target_x, center_x_ratio);
+}
- for (int monitor_n = 0; monitor_n < g.PlatformIO.Monitors.Size && best_monitor_surface < surface_threshold; monitor_n++)
- {
- const ImGuiPlatformMonitor& monitor = g.PlatformIO.Monitors[monitor_n];
- const ImRect monitor_rect = ImRect(monitor.MainPos, monitor.MainPos + monitor.MainSize);
- if (monitor_rect.Contains(rect))
- return monitor_n;
- ImRect overlapping_rect = rect;
- overlapping_rect.ClipWithFull(monitor_rect);
- float overlapping_surface = overlapping_rect.GetWidth() * overlapping_rect.GetHeight();
- if (overlapping_surface < best_monitor_surface)
- continue;
- best_monitor_surface = overlapping_surface;
- best_monitor_n = monitor_n;
- }
- return best_monitor_n;
+// center_y_ratio: 0.0f top of last item, 0.5f vertical center of last item, 1.0f bottom of last item.
+void ImGui::SetScrollHereY(float center_y_ratio)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ float target_y = window->DC.CursorPosPrevLine.y - window->Pos.y; // Top of last item, in window space
+ target_y += (window->DC.PrevLineSize.y * center_y_ratio) + (g.Style.ItemSpacing.y * (center_y_ratio - 0.5f) * 2.0f); // Precisely aim above, in the middle or below the last line.
+ SetScrollFromPosY(target_y, center_y_ratio);
}
-// Update monitor from viewport rectangle (we'll use this info to clamp windows and save windows lost in a removed monitor)
-static void ImGui::UpdateViewportPlatformMonitor(ImGuiViewportP* viewport)
+//-----------------------------------------------------------------------------
+// [SECTION] TOOLTIPS
+//-----------------------------------------------------------------------------
+
+void ImGui::BeginTooltip()
{
- viewport->PlatformMonitor = (short)FindPlatformMonitorForRect(viewport->GetRect());
+ BeginTooltipEx(ImGuiWindowFlags_None, ImGuiTooltipFlags_None);
}
-void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport)
+void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags)
{
ImGuiContext& g = *GImGui;
- if (viewport->PlatformWindowCreated)
- {
- if (g.PlatformIO.Renderer_DestroyWindow)
- g.PlatformIO.Renderer_DestroyWindow(viewport);
- if (g.PlatformIO.Platform_DestroyWindow)
- g.PlatformIO.Platform_DestroyWindow(viewport);
- IM_ASSERT(viewport->RendererUserData == NULL && viewport->PlatformUserData == NULL);
- // Don't clear PlatformWindowCreated for the main viewport, as we initially set that up to true in Initialize()
- // The right-er way may be to leave it to the back-end to set this flag all-together, and made the flag public.
- if (viewport->ID != IMGUI_VIEWPORT_DEFAULT_ID)
- viewport->PlatformWindowCreated = false;
- }
- else
+ if (g.DragDropWithinSource || g.DragDropWithinTarget)
{
- IM_ASSERT(viewport->RendererUserData == NULL && viewport->PlatformUserData == NULL && viewport->PlatformHandle == NULL);
+ // The default tooltip position is a little offset to give space to see the context menu (it's also clamped within the current viewport/monitor)
+ // In the context of a dragging tooltip we try to reduce that offset and we enforce following the cursor.
+ // Whatever we do we want to call SetNextWindowPos() to enforce a tooltip position and disable clipping the tooltip without our display area, like regular tooltip do.
+ //ImVec2 tooltip_pos = g.IO.MousePos - g.ActiveIdClickOffset - g.Style.WindowPadding;
+ ImVec2 tooltip_pos = g.IO.MousePos + ImVec2(16 * g.Style.MouseCursorScale, 8 * g.Style.MouseCursorScale);
+ SetNextWindowPos(tooltip_pos);
+ SetNextWindowBgAlpha(g.Style.Colors[ImGuiCol_PopupBg].w * 0.60f);
+ //PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * 0.60f); // This would be nice but e.g ColorButton with checkboard has issue with transparent colors :(
+ tooltip_flags |= ImGuiTooltipFlags_OverridePreviousTooltip;
}
- viewport->RendererUserData = viewport->PlatformUserData = viewport->PlatformHandle = NULL;
- viewport->ClearRequestFlags();
+
+ char window_name[16];
+ ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", g.TooltipOverrideCount);
+ if (tooltip_flags & ImGuiTooltipFlags_OverridePreviousTooltip)
+ if (ImGuiWindow* window = FindWindowByName(window_name))
+ if (window->Active)
+ {
+ // Hide previous tooltip from being displayed. We can't easily "reset" the content of a window so we create a new one.
+ window->Hidden = true;
+ window->HiddenFramesCanSkipItems = 1;
+ ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", ++g.TooltipOverrideCount);
+ }
+ ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip|ImGuiWindowFlags_NoInputs|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_AlwaysAutoResize;
+ Begin(window_name, NULL, flags | extra_flags);
}
-void ImGui::DestroyPlatformWindows()
+void ImGui::EndTooltip()
{
- // We call the destroy window on every viewport (including the main viewport, index 0) to give a chance to the back-end
- // to clear any data they may have stored in e.g. PlatformUserData, RendererUserData.
- // It is convenient for the platform back-end code to store something in the main viewport, in order for e.g. the mouse handling
- // code to operator a consistent manner.
- // It is expected that the back-end can handle calls to Renderer_DestroyWindow/Platform_DestroyWindow without
- // crashing if it doesn't have data stored.
- ImGuiContext& g = *GImGui;
- for (int i = 0; i < g.Viewports.Size; i++)
- DestroyPlatformWindow(g.Viewports[i]);
+ IM_ASSERT(GetCurrentWindowRead()->Flags & ImGuiWindowFlags_Tooltip); // Mismatched BeginTooltip()/EndTooltip() calls
+ End();
}
+void ImGui::SetTooltipV(const char* fmt, va_list args)
+{
+ BeginTooltipEx(0, ImGuiTooltipFlags_OverridePreviousTooltip);
+ TextV(fmt, args);
+ EndTooltip();
+}
-//-----------------------------------------------------------------------------
-// [SECTION] DOCKING
-//-----------------------------------------------------------------------------
-// Docking: Internal Types
-// Docking: Forward Declarations
-// Docking: ImGuiDockContext
-// Docking: ImGuiDockContext Docking/Undocking functions
-// Docking: ImGuiDockNode
-// Docking: ImGuiDockNode Tree manipulation functions
-// Docking: Public Functions (SetWindowDock, DockSpace, DockSpaceOverViewport)
-// Docking: Builder Functions
-// Docking: Begin/End Support Functions (called from Begin/End)
-// Docking: Settings
-//-----------------------------------------------------------------------------
+void ImGui::SetTooltip(const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ SetTooltipV(fmt, args);
+ va_end(args);
+}
//-----------------------------------------------------------------------------
-// Docking: Internal Types
-//-----------------------------------------------------------------------------
-// - ImGuiDockRequestType
-// - ImGuiDockRequest
-// - ImGuiDockPreviewData
-// - ImGuiDockNodeSettings
-// - ImGuiDockContext
+// [SECTION] POPUPS
//-----------------------------------------------------------------------------
-static float IMGUI_DOCK_SPLITTER_SIZE = 2.0f;
+bool ImGui::IsPopupOpen(ImGuiID id)
+{
+ ImGuiContext& g = *GImGui;
+ return g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].PopupId == id;
+}
-enum ImGuiDockRequestType
+bool ImGui::IsPopupOpen(const char* str_id)
{
- ImGuiDockRequestType_None = 0,
- ImGuiDockRequestType_Dock,
- ImGuiDockRequestType_Undock,
- ImGuiDockRequestType_Split // Split is the same as Dock but without a DockPayload
-};
+ ImGuiContext& g = *GImGui;
+ return g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].PopupId == g.CurrentWindow->GetID(str_id);
+}
-struct ImGuiDockRequest
+ImGuiWindow* ImGui::GetTopMostPopupModal()
{
- ImGuiDockRequestType Type;
- ImGuiWindow* DockTargetWindow; // Destination/Target Window to dock into (may be a loose window or a DockNode, might be NULL in which case DockTargetNode cannot be NULL)
- ImGuiDockNode* DockTargetNode; // Destination/Target Node to dock into
- ImGuiWindow* DockPayload; // Source/Payload window to dock (may be a loose window or a DockNode), [Optional]
- ImGuiDir DockSplitDir;
- float DockSplitRatio;
- bool DockSplitOuter;
- ImGuiWindow* UndockTargetWindow;
- ImGuiDockNode* UndockTargetNode;
+ ImGuiContext& g = *GImGui;
+ for (int n = g.OpenPopupStack.Size-1; n >= 0; n--)
+ if (ImGuiWindow* popup = g.OpenPopupStack.Data[n].Window)
+ if (popup->Flags & ImGuiWindowFlags_Modal)
+ return popup;
+ return NULL;
+}
- ImGuiDockRequest()
- {
- Type = ImGuiDockRequestType_None;
- DockTargetWindow = DockPayload = UndockTargetWindow = NULL;
- DockTargetNode = UndockTargetNode = NULL;
- DockSplitDir = ImGuiDir_None;
- DockSplitRatio = 0.5f;
- DockSplitOuter = false;
- }
-};
+void ImGui::OpenPopup(const char* str_id)
+{
+ ImGuiContext& g = *GImGui;
+ OpenPopupEx(g.CurrentWindow->GetID(str_id));
+}
-struct ImGuiDockPreviewData
+// Mark popup as open (toggle toward open state).
+// Popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block.
+// Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
+// One open popup per level of the popup hierarchy (NB: when assigning we reset the Window member of ImGuiPopupRef to NULL)
+void ImGui::OpenPopupEx(ImGuiID id)
{
- ImGuiDockNode FutureNode;
- bool IsDropAllowed;
- bool IsCenterAvailable;
- bool IsSidesAvailable; // Hold your breath, grammar freaks..
- bool IsSplitDirExplicit; // Set when hovered the drop rect (vs. implicit SplitDir==None when hovered the window)
- ImGuiDockNode* SplitNode;
- ImGuiDir SplitDir;
- float SplitRatio;
- ImRect DropRectsDraw[ImGuiDir_COUNT + 1]; // May be slightly different from hit-testing drop rects used in DockNodeCalcDropRects()
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* parent_window = g.CurrentWindow;
+ int current_stack_size = g.BeginPopupStack.Size;
+ ImGuiPopupData popup_ref; // Tagged as new ref as Window will be set back to NULL if we write this into OpenPopupStack.
+ popup_ref.PopupId = id;
+ popup_ref.Window = NULL;
+ popup_ref.SourceWindow = g.NavWindow;
+ popup_ref.OpenFrameCount = g.FrameCount;
+ popup_ref.OpenParentId = parent_window->IDStack.back();
+ popup_ref.OpenPopupPos = NavCalcPreferredRefPos();
+ popup_ref.OpenMousePos = IsMousePosValid(&g.IO.MousePos) ? g.IO.MousePos : popup_ref.OpenPopupPos;
- ImGuiDockPreviewData() : FutureNode(0) { IsDropAllowed = IsCenterAvailable = IsSidesAvailable = IsSplitDirExplicit = false; SplitNode = NULL; SplitDir = ImGuiDir_None; SplitRatio = 0.f; }
-};
+ //IMGUI_DEBUG_LOG("OpenPopupEx(0x%08X)\n", g.FrameCount, id);
+ if (g.OpenPopupStack.Size < current_stack_size + 1)
+ {
+ g.OpenPopupStack.push_back(popup_ref);
+ }
+ else
+ {
+ // Gently handle the user mistakenly calling OpenPopup() every frame. It is a programming mistake! However, if we were to run the regular code path, the ui
+ // would become completely unusable because the popup will always be in hidden-while-calculating-size state _while_ claiming focus. Which would be a very confusing
+ // situation for the programmer. Instead, we silently allow the popup to proceed, it will keep reappearing and the programming error will be more obvious to understand.
+ if (g.OpenPopupStack[current_stack_size].PopupId == id && g.OpenPopupStack[current_stack_size].OpenFrameCount == g.FrameCount - 1)
+ {
+ g.OpenPopupStack[current_stack_size].OpenFrameCount = popup_ref.OpenFrameCount;
+ }
+ else
+ {
+ // Close child popups if any, then flag popup for open/reopen
+ g.OpenPopupStack.resize(current_stack_size + 1);
+ g.OpenPopupStack[current_stack_size] = popup_ref;
+ }
-// Persistent Settings data, stored contiguously in SettingsNodes (sizeof() ~32 bytes)
-struct ImGuiDockNodeSettings
-{
- ImGuiID ID;
- ImGuiID ParentNodeID;
- ImGuiID ParentWindowID;
- ImGuiID SelectedWindowID;
- signed char SplitAxis;
- char Depth;
- ImGuiDockNodeFlags Flags; // NB: We save individual flags one by one in ascii format (ImGuiDockNodeFlags_SavedFlagsMask_)
- ImVec2ih Pos;
- ImVec2ih Size;
- ImVec2ih SizeRef;
- ImGuiDockNodeSettings() { ID = ParentNodeID = ParentWindowID = SelectedWindowID = 0; SplitAxis = ImGuiAxis_None; Depth = 0; Flags = ImGuiDockNodeFlags_None; }
-};
+ // When reopening a popup we first refocus its parent, otherwise if its parent is itself a popup it would get closed by ClosePopupsOverWindow().
+ // This is equivalent to what ClosePopupToLevel() does.
+ //if (g.OpenPopupStack[current_stack_size].PopupId == id)
+ // FocusWindow(parent_window);
+ }
+}
-struct ImGuiDockContext
+void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup)
{
- ImGuiStorage Nodes; // Map ID -> ImGuiDockNode*: Active nodes
- ImVector Requests;
- ImVector SettingsNodes;
- bool WantFullRebuild;
- ImGuiDockContext() { WantFullRebuild = false; }
-};
+ ImGuiContext& g = *GImGui;
+ if (g.OpenPopupStack.empty())
+ return;
-//-----------------------------------------------------------------------------
-// Docking: Forward Declarations
-//-----------------------------------------------------------------------------
+ // When popups are stacked, clicking on a lower level popups puts focus back to it and close popups above it.
+ // Don't close our own child popup windows.
+ int popup_count_to_keep = 0;
+ if (ref_window)
+ {
+ // Find the highest popup which is a descendant of the reference window (generally reference window = NavWindow)
+ for (; popup_count_to_keep < g.OpenPopupStack.Size; popup_count_to_keep++)
+ {
+ ImGuiPopupData& popup = g.OpenPopupStack[popup_count_to_keep];
+ if (!popup.Window)
+ continue;
+ IM_ASSERT((popup.Window->Flags & ImGuiWindowFlags_Popup) != 0);
+ if (popup.Window->Flags & ImGuiWindowFlags_ChildWindow)
+ continue;
-namespace ImGui
+ // Trim the stack when popups are not direct descendant of the reference window (the reference window is often the NavWindow)
+ bool popup_or_descendent_is_ref_window = false;
+ for (int m = popup_count_to_keep; m < g.OpenPopupStack.Size && !popup_or_descendent_is_ref_window; m++)
+ if (ImGuiWindow* popup_window = g.OpenPopupStack[m].Window)
+ if (popup_window->RootWindow == ref_window->RootWindow)
+ popup_or_descendent_is_ref_window = true;
+ if (!popup_or_descendent_is_ref_window)
+ break;
+ }
+ }
+ if (popup_count_to_keep < g.OpenPopupStack.Size) // This test is not required but it allows to set a convenient breakpoint on the statement below
+ {
+ //IMGUI_DEBUG_LOG("ClosePopupsOverWindow(%s) -> ClosePopupToLevel(%d)\n", ref_window->Name, popup_count_to_keep);
+ ClosePopupToLevel(popup_count_to_keep, restore_focus_to_window_under_popup);
+ }
+}
+
+void ImGui::ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup)
{
- // ImGuiDockContext
- static ImGuiDockNode* DockContextAddNode(ImGuiContext* ctx, ImGuiID id);
- static void DockContextRemoveNode(ImGuiContext* ctx, ImGuiDockNode* node, bool merge_sibling_into_parent_node);
- static void DockContextQueueNotifyRemovedNode(ImGuiContext* ctx, ImGuiDockNode* node);
- static void DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req);
- static void DockContextProcessUndockWindow(ImGuiContext* ctx, ImGuiWindow* window, bool clear_persistent_docking_ref = true);
- static void DockContextProcessUndockNode(ImGuiContext* ctx, ImGuiDockNode* node);
- static void DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx);
- static ImGuiDockNode* DockContextFindNodeByID(ImGuiContext* ctx, ImGuiID id);
- static ImGuiDockNode* DockContextBindNodeToWindow(ImGuiContext* ctx, ImGuiWindow* window);
- static void DockContextClearNodes(ImGuiContext* ctx, ImGuiID root_id, bool clear_persistent_docking_refs); // Use root_id==0 to clear all
- static void DockContextBuildNodesFromSettings(ImGuiContext* ctx, ImGuiDockNodeSettings* node_settings_array, int node_settings_count);
- static void DockContextBuildAddWindowsToNodes(ImGuiContext* ctx, ImGuiID root_id); // Use root_id==0 to add all
-
- // ImGuiDockNode
- static void DockNodeAddWindow(ImGuiDockNode* node, ImGuiWindow* window, bool add_to_tab_bar);
- static void DockNodeMoveWindows(ImGuiDockNode* dst_node, ImGuiDockNode* src_node);
- static void DockNodeMoveChildNodes(ImGuiDockNode* dst_node, ImGuiDockNode* src_node);
- static ImGuiWindow* DockNodeFindWindowByID(ImGuiDockNode* node, ImGuiID id);
- static void DockNodeApplyPosSizeToWindows(ImGuiDockNode* node);
- static void DockNodeRemoveWindow(ImGuiDockNode* node, ImGuiWindow* window, ImGuiID save_dock_id);
- static void DockNodeHideHostWindow(ImGuiDockNode* node);
- static void DockNodeUpdate(ImGuiDockNode* node);
- static void DockNodeUpdateVisibleFlagAndInactiveChilds(ImGuiDockNode* node);
- static void DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_window);
- static void DockNodeAddTabBar(ImGuiDockNode* node);
- static void DockNodeRemoveTabBar(ImGuiDockNode* node);
- static ImGuiID DockNodeUpdateWindowMenu(ImGuiDockNode* node, ImGuiTabBar* tab_bar);
- static void DockNodeUpdateVisibleFlag(ImGuiDockNode* node);
- static void DockNodeStartMouseMovingWindow(ImGuiDockNode* node, ImGuiWindow* window);
- static bool DockNodeIsDropAllowed(ImGuiWindow* host_window, ImGuiWindow* payload_window);
- static void DockNodePreviewDockCalc(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* payload_window, ImGuiDockPreviewData* preview_data, bool is_explicit_target, bool is_outer_docking);
- static void DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* payload_window, const ImGuiDockPreviewData* preview_data);
- static void DockNodeCalcTabBarLayout(const ImGuiDockNode* node, ImRect* out_title_rect, ImRect* out_tab_bar_rect, ImVec2* out_window_menu_button_pos);
- static void DockNodeCalcSplitRects(ImVec2& pos_old, ImVec2& size_old, ImVec2& pos_new, ImVec2& size_new, ImGuiDir dir, ImVec2 size_new_desired);
- static bool DockNodeCalcDropRectsAndTestMousePos(const ImRect& parent, ImGuiDir dir, ImRect& out_draw, bool outer_docking, ImVec2* test_mouse_pos);
- static const char* DockNodeGetHostWindowTitle(ImGuiDockNode* node, char* buf, int buf_size) { ImFormatString(buf, buf_size, "##DockNode_%02X", node->ID); return buf; }
- static int DockNodeGetDepth(const ImGuiDockNode* node) { int depth = 0; while (node->ParentNode) { node = node->ParentNode; depth++; } return depth; }
- static int DockNodeGetTabOrder(ImGuiWindow* window);
-
- // ImGuiDockNode tree manipulations
- static void DockNodeTreeSplit(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiAxis split_axis, int split_first_child, float split_ratio, ImGuiDockNode* new_node);
- static void DockNodeTreeMerge(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiDockNode* merge_lead_child);
- static void DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 size, bool only_write_to_marked_nodes = false);
- static void DockNodeTreeUpdateSplitter(ImGuiDockNode* node);
- static ImGuiDockNode* DockNodeTreeFindNodeByPos(ImGuiDockNode* node, ImVec2 pos);
- static ImGuiDockNode* DockNodeTreeFindFallbackLeafNode(ImGuiDockNode* node);
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(remaining >= 0 && remaining < g.OpenPopupStack.Size);
+ ImGuiWindow* focus_window = g.OpenPopupStack[remaining].SourceWindow;
+ ImGuiWindow* popup_window = g.OpenPopupStack[remaining].Window;
+ g.OpenPopupStack.resize(remaining);
- // Settings
- static void DockSettingsRenameNodeReferences(ImGuiID old_node_id, ImGuiID new_node_id);
- static void DockSettingsRemoveNodeReferences(ImGuiID* node_ids, int node_ids_count);
- static ImGuiDockNodeSettings* DockSettingsFindNodeSettings(ImGuiContext* ctx, ImGuiID node_id);
- static void* DockSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name);
- static void DockSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line);
- static void DockSettingsHandler_WriteAll(ImGuiContext* imgui_ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf);
+ if (restore_focus_to_window_under_popup)
+ {
+ if (focus_window && !focus_window->WasActive && popup_window)
+ {
+ // Fallback
+ FocusTopMostWindowUnderOne(popup_window, NULL);
+ }
+ else
+ {
+ if (g.NavLayer == ImGuiNavLayer_Main && focus_window)
+ focus_window = NavRestoreLastChildNavWindow(focus_window);
+ FocusWindow(focus_window);
+ }
+ }
}
-//-----------------------------------------------------------------------------
-// Docking: ImGuiDockContext
-//-----------------------------------------------------------------------------
-// The lifetime model is different from the one of regular windows: we always create a ImGuiDockNode for each ImGuiDockNodeSettings,
-// or we always hold the entire docking node tree. Nodes are frequently hidden, e.g. if the window(s) or child nodes they host are not active.
-// At boot time only, we run a simple GC to remove nodes that have no references.
-// Because dock node settings (which are small, contiguous structures) are always mirrored by their corresponding dock nodes (more complete structures),
-// we can also very easily recreate the nodes from scratch given the settings data (this is what DockContextRebuild() does).
-// This is convenient as docking reconfiguration can be implemented by mostly poking at the simpler settings data.
-//-----------------------------------------------------------------------------
-// - DockContextInitialize()
-// - DockContextShutdown()
-// - DockContextOnLoadSettings()
-// - DockContextClearNodes()
-// - DockContextRebuildNodes()
-// - DockContextUpdateUndocking()
-// - DockContextUpdateDocking()
-// - DockContextFindNodeByID()
-// - DockContextBindNodeToWindow()
-// - DockContextGenNodeID()
-// - DockContextAddNode()
-// - DockContextRemoveNode()
-// - ImGuiDockContextPruneNodeData
-// - DockContextPruneUnusedSettingsNodes()
-// - DockContextBuildNodesFromSettings()
-// - DockContextBuildAddWindowsToNodes()
-//-----------------------------------------------------------------------------
-
-void ImGui::DockContextInitialize(ImGuiContext* ctx)
+// Close the popup we have begin-ed into.
+void ImGui::CloseCurrentPopup()
{
- ImGuiContext& g = *ctx;
- IM_ASSERT(g.DockContext == NULL);
- g.DockContext = IM_NEW(ImGuiDockContext)();
+ ImGuiContext& g = *GImGui;
+ int popup_idx = g.BeginPopupStack.Size - 1;
+ if (popup_idx < 0 || popup_idx >= g.OpenPopupStack.Size || g.BeginPopupStack[popup_idx].PopupId != g.OpenPopupStack[popup_idx].PopupId)
+ return;
+
+ // Closing a menu closes its top-most parent popup (unless a modal)
+ while (popup_idx > 0)
+ {
+ ImGuiWindow* popup_window = g.OpenPopupStack[popup_idx].Window;
+ ImGuiWindow* parent_popup_window = g.OpenPopupStack[popup_idx - 1].Window;
+ bool close_parent = false;
+ if (popup_window && (popup_window->Flags & ImGuiWindowFlags_ChildMenu))
+ if (parent_popup_window == NULL || !(parent_popup_window->Flags & ImGuiWindowFlags_Modal))
+ close_parent = true;
+ if (!close_parent)
+ break;
+ popup_idx--;
+ }
+ //IMGUI_DEBUG_LOG("CloseCurrentPopup %d -> %d\n", g.BeginPopupStack.Size - 1, popup_idx);
+ ClosePopupToLevel(popup_idx, true);
- // Add .ini handle for persistent docking data
- ImGuiSettingsHandler ini_handler;
- ini_handler.TypeName = "Docking";
- ini_handler.TypeHash = ImHashStr("Docking");
- ini_handler.ReadOpenFn = DockSettingsHandler_ReadOpen;
- ini_handler.ReadLineFn = DockSettingsHandler_ReadLine;
- ini_handler.WriteAllFn = DockSettingsHandler_WriteAll;
- g.SettingsHandlers.push_back(ini_handler);
+ // A common pattern is to close a popup when selecting a menu item/selectable that will open another window.
+ // To improve this usage pattern, we avoid nav highlight for a single frame in the parent window.
+ // Similarly, we could avoid mouse hover highlight in this window but it is less visually problematic.
+ if (ImGuiWindow* window = g.NavWindow)
+ window->DC.NavHideHighlightOneFrame = true;
}
-void ImGui::DockContextShutdown(ImGuiContext* ctx)
+bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags flags)
{
- ImGuiContext& g = *ctx;
- ImGuiDockContext* dc = ctx->DockContext;
- for (int n = 0; n < dc->Nodes.Data.Size; n++)
- if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
- IM_DELETE(node);
- IM_DELETE(g.DockContext);
- g.DockContext = NULL;
-}
+ ImGuiContext& g = *GImGui;
+ if (!IsPopupOpen(id))
+ {
+ g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
+ return false;
+ }
-void ImGui::DockContextOnLoadSettings(ImGuiContext* ctx)
-{
- ImGuiDockContext* dc = ctx->DockContext;
- DockContextPruneUnusedSettingsNodes(ctx);
- DockContextBuildNodesFromSettings(ctx, dc->SettingsNodes.Data, dc->SettingsNodes.Size);
-}
+ char name[20];
+ if (flags & ImGuiWindowFlags_ChildMenu)
+ ImFormatString(name, IM_ARRAYSIZE(name), "##Menu_%02d", g.BeginPopupStack.Size); // Recycle windows based on depth
+ else
+ ImFormatString(name, IM_ARRAYSIZE(name), "##Popup_%08x", id); // Not recycling, so we can close/open during the same frame
-void ImGui::DockContextClearNodes(ImGuiContext* ctx, ImGuiID root_id, bool clear_persistent_docking_references)
-{
- IM_UNUSED(ctx);
- IM_ASSERT(ctx == GImGui);
- DockBuilderRemoveNodeDockedWindows(root_id, clear_persistent_docking_references);
- DockBuilderRemoveNodeChildNodes(root_id);
-}
+ flags |= ImGuiWindowFlags_Popup;
+ bool is_open = Begin(name, NULL, flags);
+ if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display)
+ EndPopup();
-// This function also acts as a defacto test to make sure we can rebuild from scratch without a glitch
-void ImGui::DockContextRebuildNodes(ImGuiContext* ctx)
-{
- IMGUI_DEBUG_LOG_DOCKING("DockContextRebuild()\n");
- ImGuiDockContext* dc = ctx->DockContext;
- SaveIniSettingsToMemory();
- ImGuiID root_id = 0; // Rebuild all
- DockContextClearNodes(ctx, root_id, false);
- DockContextBuildNodesFromSettings(ctx, dc->SettingsNodes.Data, dc->SettingsNodes.Size);
- DockContextBuildAddWindowsToNodes(ctx, root_id);
+ return is_open;
}
-// Docking context update function, called by NewFrame()
-void ImGui::DockContextUpdateUndocking(ImGuiContext* ctx)
+bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags)
{
- ImGuiContext& g = *ctx;
- ImGuiDockContext* dc = ctx->DockContext;
- if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable))
+ ImGuiContext& g = *GImGui;
+ if (g.OpenPopupStack.Size <= g.BeginPopupStack.Size) // Early out for performance
{
- if (dc->Nodes.Data.Size > 0 || dc->Requests.Size > 0)
- DockContextClearNodes(ctx, 0, true);
- return;
+ g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
+ return false;
}
+ flags |= ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings;
+ return BeginPopupEx(g.CurrentWindow->GetID(str_id), flags);
+}
- // Setting NoSplit at runtime merges all nodes
- if (g.IO.ConfigDockingNoSplit)
- for (int n = 0; n < dc->Nodes.Data.Size; n++)
- if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
- if (node->IsRootNode() && node->IsSplitNode())
- {
- DockBuilderRemoveNodeChildNodes(node->ID);
- //dc->WantFullRebuild = true;
- }
-
- // Process full rebuild
-#if 0
- if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_C)))
- dc->WantFullRebuild = true;
-#endif
- if (dc->WantFullRebuild)
+// If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup.
+// Note that popup visibility status is owned by Dear ImGui (and manipulated with e.g. OpenPopup) so the actual value of *p_open is meaningless here.
+bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ const ImGuiID id = window->GetID(name);
+ if (!IsPopupOpen(id))
{
- DockContextRebuildNodes(ctx);
- dc->WantFullRebuild = false;
+ g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
+ return false;
}
- // Process Undocking requests (we need to process them _before_ the UpdateMouseMovingWindowNewFrame call in NewFrame)
- for (int n = 0; n < dc->Requests.Size; n++)
+ // Center modal windows by default
+ // FIXME: Should test for (PosCond & window->SetWindowPosAllowFlags) with the upcoming window.
+ if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) == 0)
+ SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
+
+ flags |= ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings;
+ const bool is_open = Begin(name, p_open, flags);
+ if (!is_open || (p_open && !*p_open)) // NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
{
- ImGuiDockRequest* req = &dc->Requests[n];
- if (req->Type == ImGuiDockRequestType_Undock && req->UndockTargetWindow)
- DockContextProcessUndockWindow(ctx, req->UndockTargetWindow);
- else if (req->Type == ImGuiDockRequestType_Undock && req->UndockTargetNode)
- DockContextProcessUndockNode(ctx, req->UndockTargetNode);
+ EndPopup();
+ if (is_open)
+ ClosePopupToLevel(g.BeginPopupStack.Size, true);
+ return false;
}
+ return is_open;
}
-// Docking context update function, called by NewFrame()
-void ImGui::DockContextUpdateDocking(ImGuiContext* ctx)
+void ImGui::EndPopup()
{
- ImGuiContext& g = *ctx;
- ImGuiDockContext* dc = ctx->DockContext;
- if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable))
- return;
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ IM_ASSERT(window->Flags & ImGuiWindowFlags_Popup); // Mismatched BeginPopup()/EndPopup() calls
+ IM_ASSERT(g.BeginPopupStack.Size > 0);
- // Process Docking requests
- for (int n = 0; n < dc->Requests.Size; n++)
- if (dc->Requests[n].Type == ImGuiDockRequestType_Dock)
- DockContextProcessDock(ctx, &dc->Requests[n]);
- dc->Requests.resize(0);
+ // Make all menus and popups wrap around for now, may need to expose that policy.
+ NavMoveRequestTryWrapping(window, ImGuiNavMoveFlags_LoopY);
- // Create windows for each automatic docking nodes
- // We can have NULL pointers when we delete nodes, but because ID are recycled this should amortize nicely (and our node count will never be very high)
- for (int n = 0; n < dc->Nodes.Data.Size; n++)
- if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
- if (node->IsFloatingNode())
- DockNodeUpdate(node);
+ // Child-popups don't need to be layed out
+ IM_ASSERT(g.WithinEndChild == false);
+ if (window->Flags & ImGuiWindowFlags_ChildWindow)
+ g.WithinEndChild = true;
+ End();
+ g.WithinEndChild = false;
}
-static ImGuiDockNode* ImGui::DockContextFindNodeByID(ImGuiContext* ctx, ImGuiID id)
+bool ImGui::OpenPopupOnItemClick(const char* str_id, ImGuiMouseButton mouse_button)
{
- return (ImGuiDockNode*)ctx->DockContext->Nodes.GetVoidPtr(id);
+ ImGuiWindow* window = GImGui->CurrentWindow;
+ if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
+ {
+ ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
+ IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
+ OpenPopupEx(id);
+ return true;
+ }
+ return false;
}
-ImGuiID ImGui::DockContextGenNodeID(ImGuiContext* ctx)
+// This is a helper to handle the simplest case of associating one named popup to one given widget.
+// You may want to handle this on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters).
+// You can pass a NULL str_id to use the identifier of the last item.
+bool ImGui::BeginPopupContextItem(const char* str_id, ImGuiMouseButton mouse_button)
{
- // Generate an ID for new node (the exact ID value doesn't matter as long as it is not already used)
- // FIXME-OPT FIXME-DOCKING: This is suboptimal, even if the node count is small enough not to be a worry. We should poke in ctx->Nodes to find a suitable ID faster.
- ImGuiID id = 0x0001;
- while (DockContextFindNodeByID(ctx, id) != NULL)
- id++;
- return id;
+ ImGuiWindow* window = GImGui->CurrentWindow;
+ if (window->SkipItems)
+ return false;
+ ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
+ IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
+ if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
+ OpenPopupEx(id);
+ return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
}
-static ImGuiDockNode* ImGui::DockContextAddNode(ImGuiContext* ctx, ImGuiID id)
+bool ImGui::BeginPopupContextWindow(const char* str_id, ImGuiMouseButton mouse_button, bool also_over_items)
{
- // Generate an ID for the new node (the exact ID value doesn't matter as long as it is not already used) and add the first window.
- if (id == 0)
- id = DockContextGenNodeID(ctx);
- else
- IM_ASSERT(DockContextFindNodeByID(ctx, id) == NULL);
-
- // We don't set node->LastFrameAlive on construction. Nodes are always created at all time to reflect .ini settings!
- IMGUI_DEBUG_LOG_DOCKING("DockContextAddNode 0x%08X\n", id);
- ImGuiDockNode* node = IM_NEW(ImGuiDockNode)(id);
- ctx->DockContext->Nodes.SetVoidPtr(node->ID, node);
- return node;
+ if (!str_id)
+ str_id = "window_context";
+ ImGuiID id = GImGui->CurrentWindow->GetID(str_id);
+ if (IsMouseReleased(mouse_button) && IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
+ if (also_over_items || !IsAnyItemHovered())
+ OpenPopupEx(id);
+ return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
}
-static void ImGui::DockContextRemoveNode(ImGuiContext* ctx, ImGuiDockNode* node, bool merge_sibling_into_parent_node)
+bool ImGui::BeginPopupContextVoid(const char* str_id, ImGuiMouseButton mouse_button)
{
- ImGuiContext& g = *ctx;
- ImGuiDockContext* dc = ctx->DockContext;
-
- IMGUI_DEBUG_LOG_DOCKING("DockContextRemoveNode 0x%08X\n", node->ID);
- IM_ASSERT(DockContextFindNodeByID(ctx, node->ID) == node);
- IM_ASSERT(node->ChildNodes[0] == NULL && node->ChildNodes[1] == NULL);
- IM_ASSERT(node->Windows.Size == 0);
+ if (!str_id)
+ str_id = "void_context";
+ ImGuiID id = GImGui->CurrentWindow->GetID(str_id);
+ if (IsMouseReleased(mouse_button) && !IsWindowHovered(ImGuiHoveredFlags_AnyWindow))
+ OpenPopupEx(id);
+ return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
+}
- if (node->HostWindow)
- node->HostWindow->DockNodeAsHost = NULL;
+// r_avoid = the rectangle to avoid (e.g. for tooltip it is a rectangle around the mouse cursor which we want to avoid. for popups it's a small point around the cursor.)
+// r_outer = the visible area rectangle, minus safe area padding. If our popup size won't fit because of safe area padding we ignore it.
+ImVec2 ImGui::FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy)
+{
+ ImVec2 base_pos_clamped = ImClamp(ref_pos, r_outer.Min, r_outer.Max - size);
+ //GetForegroundDrawList()->AddRect(r_avoid.Min, r_avoid.Max, IM_COL32(255,0,0,255));
+ //GetForegroundDrawList()->AddRect(r_outer.Min, r_outer.Max, IM_COL32(0,255,0,255));
- ImGuiDockNode* parent_node = node->ParentNode;
- const bool merge = (merge_sibling_into_parent_node && parent_node != NULL);
- if (merge)
+ // Combo Box policy (we want a connecting edge)
+ if (policy == ImGuiPopupPositionPolicy_ComboBox)
{
- IM_ASSERT(parent_node->ChildNodes[0] == node || parent_node->ChildNodes[1] == node);
- ImGuiDockNode* sibling_node = (parent_node->ChildNodes[0] == node ? parent_node->ChildNodes[1] : parent_node->ChildNodes[0]);
- DockNodeTreeMerge(&g, parent_node, sibling_node);
+ const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Down, ImGuiDir_Right, ImGuiDir_Left, ImGuiDir_Up };
+ for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++)
+ {
+ const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n];
+ if (n != -1 && dir == *last_dir) // Already tried this direction?
+ continue;
+ ImVec2 pos;
+ if (dir == ImGuiDir_Down) pos = ImVec2(r_avoid.Min.x, r_avoid.Max.y); // Below, Toward Right (default)
+ if (dir == ImGuiDir_Right) pos = ImVec2(r_avoid.Min.x, r_avoid.Min.y - size.y); // Above, Toward Right
+ if (dir == ImGuiDir_Left) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Max.y); // Below, Toward Left
+ if (dir == ImGuiDir_Up) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Min.y - size.y); // Above, Toward Left
+ if (!r_outer.Contains(ImRect(pos, pos + size)))
+ continue;
+ *last_dir = dir;
+ return pos;
+ }
}
- else
+
+ // Default popup policy
+ const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Right, ImGuiDir_Down, ImGuiDir_Up, ImGuiDir_Left };
+ for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++)
{
- for (int n = 0; parent_node && n < IM_ARRAYSIZE(parent_node->ChildNodes); n++)
- if (parent_node->ChildNodes[n] == node)
- node->ParentNode->ChildNodes[n] = NULL;
- dc->Nodes.SetVoidPtr(node->ID, NULL);
- IM_DELETE(node);
+ const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n];
+ if (n != -1 && dir == *last_dir) // Already tried this direction?
+ continue;
+ float avail_w = (dir == ImGuiDir_Left ? r_avoid.Min.x : r_outer.Max.x) - (dir == ImGuiDir_Right ? r_avoid.Max.x : r_outer.Min.x);
+ float avail_h = (dir == ImGuiDir_Up ? r_avoid.Min.y : r_outer.Max.y) - (dir == ImGuiDir_Down ? r_avoid.Max.y : r_outer.Min.y);
+ if (avail_w < size.x || avail_h < size.y)
+ continue;
+ ImVec2 pos;
+ pos.x = (dir == ImGuiDir_Left) ? r_avoid.Min.x - size.x : (dir == ImGuiDir_Right) ? r_avoid.Max.x : base_pos_clamped.x;
+ pos.y = (dir == ImGuiDir_Up) ? r_avoid.Min.y - size.y : (dir == ImGuiDir_Down) ? r_avoid.Max.y : base_pos_clamped.y;
+ *last_dir = dir;
+ return pos;
}
-}
-static int IMGUI_CDECL DockNodeComparerDepthMostFirst(const void* lhs, const void* rhs)
-{
- const ImGuiDockNode* a = *(const ImGuiDockNode* const*)lhs;
- const ImGuiDockNode* b = *(const ImGuiDockNode* const*)rhs;
- return ImGui::DockNodeGetDepth(b) - ImGui::DockNodeGetDepth(a);
+ // Fallback, try to keep within display
+ *last_dir = ImGuiDir_None;
+ ImVec2 pos = ref_pos;
+ pos.x = ImMax(ImMin(pos.x + size.x, r_outer.Max.x) - size.x, r_outer.Min.x);
+ pos.y = ImMax(ImMin(pos.y + size.y, r_outer.Max.y) - size.y, r_outer.Min.y);
+ return pos;
}
-// Pre C++0x doesn't allow us to use a function-local type (without linkage) as template parameter, so we moved this here.
-struct ImGuiDockContextPruneNodeData
+ImRect ImGui::GetWindowAllowedExtentRect(ImGuiWindow* window)
{
- int CountWindows, CountChildWindows, CountChildNodes;
- ImGuiID RootID;
- ImGuiDockContextPruneNodeData() { CountWindows = CountChildWindows = CountChildNodes = 0; RootID = 0; }
-};
+ IM_UNUSED(window);
+ ImVec2 padding = GImGui->Style.DisplaySafeAreaPadding;
+ ImRect r_screen = GetViewportRect();
+ r_screen.Expand(ImVec2((r_screen.GetWidth() > padding.x * 2) ? -padding.x : 0.0f, (r_screen.GetHeight() > padding.y * 2) ? -padding.y : 0.0f));
+ return r_screen;
+}
-// Garbage collect unused nodes (run once at init time)
-static void ImGui::DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx)
+ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window)
{
- ImGuiContext& g = *ctx;
- ImGuiDockContext* dc = ctx->DockContext;
- IM_ASSERT(g.Windows.Size == 0);
-
- ImPool pool;
- pool.Reserve(dc->SettingsNodes.Size);
-
- // Count child nodes and compute RootID
- for (int settings_n = 0; settings_n < dc->SettingsNodes.Size; settings_n++)
- {
- ImGuiDockNodeSettings* settings = &dc->SettingsNodes[settings_n];
- ImGuiDockContextPruneNodeData* parent_data = settings->ParentNodeID ? pool.GetByKey(settings->ParentNodeID) : 0;
- pool.GetOrAddByKey(settings->ID)->RootID = parent_data ? parent_data->RootID : settings->ID;
- if (settings->ParentNodeID)
- pool.GetOrAddByKey(settings->ParentNodeID)->CountChildNodes++;
- }
+ ImGuiContext& g = *GImGui;
- // Count reference to dock ids from dockspaces
- // We track the 'auto-DockNode <- manual-Window <- manual-DockSpace' in order to avoid 'auto-DockNode' being ditched by DockContextPruneUnusedSettingsNodes()
- for (int settings_n = 0; settings_n < dc->SettingsNodes.Size; settings_n++)
+ ImRect r_outer = GetWindowAllowedExtentRect(window);
+ if (window->Flags & ImGuiWindowFlags_ChildMenu)
{
- ImGuiDockNodeSettings* settings = &dc->SettingsNodes[settings_n];
- if (settings->ParentWindowID != 0)
- if (ImGuiWindowSettings* window_settings = FindWindowSettings(settings->ParentWindowID))
- if (window_settings->DockId)
- if (ImGuiDockContextPruneNodeData* data = pool.GetByKey(window_settings->DockId))
- data->CountChildNodes++;
+ // Child menus typically request _any_ position within the parent menu item, and then we move the new menu outside the parent bounds.
+ // This is how we end up with child menus appearing (most-commonly) on the right of the parent menu.
+ IM_ASSERT(g.CurrentWindow == window);
+ ImGuiWindow* parent_window = g.CurrentWindowStack[g.CurrentWindowStack.Size - 2];
+ float horizontal_overlap = g.Style.ItemInnerSpacing.x; // We want some overlap to convey the relative depth of each menu (currently the amount of overlap is hard-coded to style.ItemSpacing.x).
+ ImRect r_avoid;
+ if (parent_window->DC.MenuBarAppending)
+ r_avoid = ImRect(-FLT_MAX, parent_window->ClipRect.Min.y, FLT_MAX, parent_window->ClipRect.Max.y); // Avoid parent menu-bar. If we wanted multi-line menu-bar, we may instead want to have the calling window setup e.g. a NextWindowData.PosConstraintAvoidRect field
+ else
+ r_avoid = ImRect(parent_window->Pos.x + horizontal_overlap, -FLT_MAX, parent_window->Pos.x + parent_window->Size.x - horizontal_overlap - parent_window->ScrollbarSizes.x, FLT_MAX);
+ return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
}
-
- // Count reference to dock ids from window settings
- // We guard against the possibility of an invalid .ini file (RootID may point to a missing node)
- for (int settings_n = 0; settings_n < g.SettingsWindows.Size; settings_n++)
- if (ImGuiID dock_id = g.SettingsWindows[settings_n].DockId)
- if (ImGuiDockContextPruneNodeData* data = pool.GetByKey(dock_id))
- {
- data->CountWindows++;
- if (ImGuiDockContextPruneNodeData* data_root = (data->RootID == dock_id) ? data : pool.GetByKey(data->RootID))
- data_root->CountChildWindows++;
- }
-
- // Prune
- for (int settings_n = 0; settings_n < dc->SettingsNodes.Size; settings_n++)
+ if (window->Flags & ImGuiWindowFlags_Popup)
{
- ImGuiDockNodeSettings* settings = &dc->SettingsNodes[settings_n];
- ImGuiDockContextPruneNodeData* data = pool.GetByKey(settings->ID);
- if (data->CountWindows > 1)
- continue;
- ImGuiDockContextPruneNodeData* data_root = (data->RootID == settings->ID) ? data : pool.GetByKey(data->RootID);
-
- bool remove = false;
- remove |= (data->CountWindows == 1 && settings->ParentNodeID == 0 && data->CountChildNodes == 0 && !(settings->Flags & ImGuiDockNodeFlags_CentralNode)); // Floating root node with only 1 window
- remove |= (data->CountWindows == 0 && settings->ParentNodeID == 0 && data->CountChildNodes == 0); // Leaf nodes with 0 window
- remove |= (data_root->CountChildWindows == 0);
- if (remove)
- {
- IMGUI_DEBUG_LOG_DOCKING("DockContextPruneUnusedSettingsNodes: Prune 0x%08X\n", settings->ID);
- DockSettingsRemoveNodeReferences(&settings->ID, 1);
- settings->ID = 0;
- }
+ ImRect r_avoid = ImRect(window->Pos.x - 1, window->Pos.y - 1, window->Pos.x + 1, window->Pos.y + 1);
+ return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
}
-}
-
-static void ImGui::DockContextBuildNodesFromSettings(ImGuiContext* ctx, ImGuiDockNodeSettings* node_settings_array, int node_settings_count)
-{
- // Build nodes
- for (int node_n = 0; node_n < node_settings_count; node_n++)
- {
- ImGuiDockNodeSettings* settings = &node_settings_array[node_n];
- if (settings->ID == 0)
- continue;
- ImGuiDockNode* node = DockContextAddNode(ctx, settings->ID);
- node->ParentNode = settings->ParentNodeID ? DockContextFindNodeByID(ctx, settings->ParentNodeID) : NULL;
- node->Pos = ImVec2(settings->Pos.x, settings->Pos.y);
- node->Size = ImVec2(settings->Size.x, settings->Size.y);
- node->SizeRef = ImVec2(settings->SizeRef.x, settings->SizeRef.y);
- node->AuthorityForPos = node->AuthorityForSize = node->AuthorityForViewport = ImGuiDataAuthority_DockNode;
- if (node->ParentNode && node->ParentNode->ChildNodes[0] == NULL)
- node->ParentNode->ChildNodes[0] = node;
- else if (node->ParentNode && node->ParentNode->ChildNodes[1] == NULL)
- node->ParentNode->ChildNodes[1] = node;
- node->SelectedTabID = settings->SelectedWindowID;
- node->SplitAxis = settings->SplitAxis;
- node->LocalFlags |= (settings->Flags & ImGuiDockNodeFlags_SavedFlagsMask_);
-
- // Bind host window immediately if it already exist (in case of a rebuild)
- // This is useful as the RootWindowForTitleBarHighlight links necessary to highlight the currently focused node requires node->HostWindow to be set.
- char host_window_title[20];
- ImGuiDockNode* root_node = DockNodeGetRootNode(node);
- node->HostWindow = FindWindowByName(DockNodeGetHostWindowTitle(root_node, host_window_title, IM_ARRAYSIZE(host_window_title)));
- }
-}
-
-void ImGui::DockContextBuildAddWindowsToNodes(ImGuiContext* ctx, ImGuiID root_id)
-{
- // Rebind all windows to nodes (they can also lazily rebind but we'll have a visible glitch during the first frame)
- ImGuiContext& g = *ctx;
- for (int n = 0; n < g.Windows.Size; n++)
+ if (window->Flags & ImGuiWindowFlags_Tooltip)
{
- ImGuiWindow* window = g.Windows[n];
- if (window->DockId == 0 || window->LastFrameActive < g.FrameCount - 1)
- continue;
- if (window->DockNode != NULL)
- continue;
-
- ImGuiDockNode* node = DockContextFindNodeByID(ctx, window->DockId);
- IM_ASSERT(node != NULL); // This should have been called after DockContextBuildNodesFromSettings()
- if (root_id == 0 || DockNodeGetRootNode(node)->ID == root_id)
- DockNodeAddWindow(node, window, true);
+ // Position tooltip (always follows mouse)
+ float sc = g.Style.MouseCursorScale;
+ ImVec2 ref_pos = NavCalcPreferredRefPos();
+ ImRect r_avoid;
+ if (!g.NavDisableHighlight && g.NavDisableMouseHover && !(g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos))
+ r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 16, ref_pos.y + 8);
+ else
+ r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 24 * sc, ref_pos.y + 24 * sc); // FIXME: Hard-coded based on mouse cursor shape expectation. Exact dimension not very important.
+ ImVec2 pos = FindBestWindowPosForPopupEx(ref_pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
+ if (window->AutoPosLastDirection == ImGuiDir_None)
+ pos = ref_pos + ImVec2(2, 2); // If there's not enough room, for tooltip we prefer avoiding the cursor at all cost even if it means that part of the tooltip won't be visible.
+ return pos;
}
+ IM_ASSERT(0);
+ return window->Pos;
}
//-----------------------------------------------------------------------------
-// Docking: ImGuiDockContext Docking/Undocking functions
-//-----------------------------------------------------------------------------
-// - DockContextQueueDock()
-// - DockContextQueueUndockWindow()
-// - DockContextQueueUndockNode()
-// - DockContextQueueNotifyRemovedNode()
-// - DockContextProcessDock()
-// - DockContextProcessUndockWindow()
-// - DockContextProcessUndockNode()
-// - DockContextCalcDropPosForDocking()
+// [SECTION] KEYBOARD/GAMEPAD NAVIGATION
//-----------------------------------------------------------------------------
-void ImGui::DockContextQueueDock(ImGuiContext* ctx, ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload, ImGuiDir split_dir, float split_ratio, bool split_outer)
+// FIXME-NAV: The existence of SetNavID vs SetNavIDWithRectRel vs SetFocusID is incredibly messy and confusing,
+// and needs some explanation or serious refactoring.
+void ImGui::SetNavID(ImGuiID id, int nav_layer, ImGuiID focus_scope_id)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(g.NavWindow);
+ IM_ASSERT(nav_layer == 0 || nav_layer == 1);
+ g.NavId = id;
+ g.NavFocusScopeId = focus_scope_id;
+ g.NavWindow->NavLastIds[nav_layer] = id;
+}
+
+void ImGui::SetNavIDWithRectRel(ImGuiID id, int nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel)
{
- IM_ASSERT(target != payload);
- ImGuiDockRequest req;
- req.Type = ImGuiDockRequestType_Dock;
- req.DockTargetWindow = target;
- req.DockTargetNode = target_node;
- req.DockPayload = payload;
- req.DockSplitDir = split_dir;
- req.DockSplitRatio = split_ratio;
- req.DockSplitOuter = split_outer;
- ctx->DockContext->Requests.push_back(req);
+ ImGuiContext& g = *GImGui;
+ SetNavID(id, nav_layer, focus_scope_id);
+ g.NavWindow->NavRectRel[nav_layer] = rect_rel;
+ g.NavMousePosDirty = true;
+ g.NavDisableHighlight = false;
+ g.NavDisableMouseHover = true;
}
-void ImGui::DockContextQueueUndockWindow(ImGuiContext* ctx, ImGuiWindow* window)
-{
- ImGuiDockRequest req;
- req.Type = ImGuiDockRequestType_Undock;
- req.UndockTargetWindow = window;
- ctx->DockContext->Requests.push_back(req);
+void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(id != 0);
+
+ // Assume that SetFocusID() is called in the context where its window->DC.NavLayerCurrent and window->DC.NavFocusScopeIdCurrent are valid.
+ // Note that window may be != g.CurrentWindow (e.g. SetFocusID call in InputTextEx for multi-line text)
+ const ImGuiNavLayer nav_layer = window->DC.NavLayerCurrent;
+ if (g.NavWindow != window)
+ g.NavInitRequest = false;
+ g.NavWindow = window;
+ g.NavId = id;
+ g.NavLayer = nav_layer;
+ g.NavFocusScopeId = window->DC.NavFocusScopeIdCurrent;
+ window->NavLastIds[nav_layer] = id;
+ if (window->DC.LastItemId == id)
+ window->NavRectRel[nav_layer] = ImRect(window->DC.LastItemRect.Min - window->Pos, window->DC.LastItemRect.Max - window->Pos);
+
+ if (g.ActiveIdSource == ImGuiInputSource_Nav)
+ g.NavDisableMouseHover = true;
+ else
+ g.NavDisableHighlight = true;
}
-void ImGui::DockContextQueueUndockNode(ImGuiContext* ctx, ImGuiDockNode* node)
+ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy)
{
- ImGuiDockRequest req;
- req.Type = ImGuiDockRequestType_Undock;
- req.UndockTargetNode = node;
- ctx->DockContext->Requests.push_back(req);
+ if (ImFabs(dx) > ImFabs(dy))
+ return (dx > 0.0f) ? ImGuiDir_Right : ImGuiDir_Left;
+ return (dy > 0.0f) ? ImGuiDir_Down : ImGuiDir_Up;
}
-void ImGui::DockContextQueueNotifyRemovedNode(ImGuiContext* ctx, ImGuiDockNode* node)
+static float inline NavScoreItemDistInterval(float a0, float a1, float b0, float b1)
{
- ImGuiDockContext* dc = ctx->DockContext;
- for (int n = 0; n < dc->Requests.Size; n++)
- if (dc->Requests[n].DockTargetNode == node)
- dc->Requests[n].Type = ImGuiDockRequestType_None;
+ if (a1 < b0)
+ return a1 - b0;
+ if (b1 < a0)
+ return a0 - b1;
+ return 0.0f;
}
-void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req)
+static void inline NavClampRectToVisibleAreaForMoveDir(ImGuiDir move_dir, ImRect& r, const ImRect& clip_rect)
{
- IM_ASSERT((req->Type == ImGuiDockRequestType_Dock && req->DockPayload != NULL) || (req->Type == ImGuiDockRequestType_Split && req->DockPayload == NULL));
- IM_ASSERT(req->DockTargetWindow != NULL || req->DockTargetNode != NULL);
-
- ImGuiContext& g = *ctx;
- IM_UNUSED(g);
-
- ImGuiWindow* payload_window = req->DockPayload; // Optional
- ImGuiWindow* target_window = req->DockTargetWindow;
- ImGuiDockNode* node = req->DockTargetNode;
- if (payload_window)
- IMGUI_DEBUG_LOG_DOCKING("DockContextProcessDock node 0x%08X target '%s' dock window '%s', split_dir %d\n", node ? node->ID : 0, target_window ? target_window->Name : "NULL", payload_window ? payload_window->Name : "NULL", req->DockSplitDir);
- else
- IMGUI_DEBUG_LOG_DOCKING("DockContextProcessDock node 0x%08X, split_dir %d\n", node ? node->ID : 0, req->DockSplitDir);
-
- // Decide which Tab will be selected at the end of the operation
- ImGuiID next_selected_id = 0;
- ImGuiDockNode* payload_node = NULL;
- if (payload_window)
- {
- payload_node = payload_window->DockNodeAsHost;
- payload_window->DockNodeAsHost = NULL; // Important to clear this as the node will have its life as a child which might be merged/deleted later.
- if (payload_node && payload_node->IsLeafNode())
- next_selected_id = payload_node->TabBar->NextSelectedTabId ? payload_node->TabBar->NextSelectedTabId : payload_node->TabBar->SelectedTabId;
- if (payload_node == NULL)
- next_selected_id = payload_window->ID;
- }
-
- // FIXME-DOCK: When we are trying to dock an existing single-window node into a loose window, transfer Node ID as well
- // When processing an interactive split, usually LastFrameAlive will be < g.FrameCount. But DockBuilder operations can make it ==.
- if (node)
- IM_ASSERT(node->LastFrameAlive <= g.FrameCount);
- if (node && target_window && node == target_window->DockNodeAsHost)
- IM_ASSERT(node->Windows.Size > 0 || node->IsSplitNode() || node->IsCentralNode());
-
- // Create new node and add existing window to it
- if (node == NULL)
+ if (move_dir == ImGuiDir_Left || move_dir == ImGuiDir_Right)
{
- node = DockContextAddNode(ctx, 0);
- node->Pos = target_window->Pos;
- node->Size = target_window->Size;
- if (target_window->DockNodeAsHost == NULL)
- {
- DockNodeAddWindow(node, target_window, true);
- node->TabBar->Tabs[0].Flags &= ~ImGuiTabItemFlags_Unsorted;
- target_window->DockIsActive = true;
- }
+ r.Min.y = ImClamp(r.Min.y, clip_rect.Min.y, clip_rect.Max.y);
+ r.Max.y = ImClamp(r.Max.y, clip_rect.Min.y, clip_rect.Max.y);
}
-
- ImGuiDir split_dir = req->DockSplitDir;
- if (split_dir != ImGuiDir_None)
+ else
{
- // Split into one, one side will be our payload node unless we are dropping a loose window
- const ImGuiAxis split_axis = (split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Right) ? ImGuiAxis_X : ImGuiAxis_Y;
- const int split_inheritor_child_idx = (split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Up) ? 1 : 0; // Current contents will be moved to the opposite side
- const float split_ratio = req->DockSplitRatio;
- DockNodeTreeSplit(ctx, node, split_axis, split_inheritor_child_idx, split_ratio, payload_node); // payload_node may be NULL here!
- ImGuiDockNode* new_node = node->ChildNodes[split_inheritor_child_idx ^ 1];
- new_node->HostWindow = node->HostWindow;
- node = new_node;
+ r.Min.x = ImClamp(r.Min.x, clip_rect.Min.x, clip_rect.Max.x);
+ r.Max.x = ImClamp(r.Max.x, clip_rect.Min.x, clip_rect.Max.x);
}
- node->LocalFlags &= ~ImGuiDockNodeFlags_HiddenTabBar;
+}
- if (node != payload_node)
- {
- // Create tab bar before we call DockNodeMoveWindows (which would attempt to move the old tab-bar, which would lead us to payload tabs wrongly appearing before target tabs!)
- if (node->Windows.Size > 0 && node->TabBar == NULL)
- {
- DockNodeAddTabBar(node);
- for (int n = 0; n < node->Windows.Size; n++)
- TabBarAddTab(node->TabBar, ImGuiTabItemFlags_None, node->Windows[n]);
- }
+// Scoring function for gamepad/keyboard directional navigation. Based on https://gist.github.com/rygorous/6981057
+static bool ImGui::NavScoreItem(ImGuiNavMoveResult* result, ImRect cand)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ if (g.NavLayer != window->DC.NavLayerCurrent)
+ return false;
- if (payload_node != NULL)
- {
- // Transfer full payload node (with 1+ child windows or child nodes)
- if (payload_node->IsSplitNode())
- {
- if (node->Windows.Size > 0)
- {
- // We can dock a split payload into a node that already has windows _only_ if our payload is a node tree with a single visible node.
- // In this situation, we move the windows of the target node into the currently visible node of the payload.
- // This allows us to preserve some of the underlying dock tree settings nicely.
- IM_ASSERT(payload_node->OnlyNodeWithWindows != NULL); // The docking should have been blocked by DockNodePreviewDockCalc() early on and never submitted.
- ImGuiDockNode* visible_node = payload_node->OnlyNodeWithWindows;
- if (visible_node->TabBar)
- IM_ASSERT(visible_node->TabBar->Tabs.Size > 0);
- DockNodeMoveWindows(node, visible_node);
- DockNodeMoveWindows(visible_node, node);
- DockSettingsRenameNodeReferences(node->ID, visible_node->ID);
- }
- if (node->IsCentralNode())
- {
- // Central node property needs to be moved to a leaf node, pick the last focused one.
- // FIXME-DOCKING: If we had to transfer other flags here, what would the policy be?
- ImGuiDockNode* last_focused_node = DockContextFindNodeByID(ctx, payload_node->LastFocusedNodeID);
- IM_ASSERT(last_focused_node != NULL);
- ImGuiDockNode* last_focused_root_node = DockNodeGetRootNode(last_focused_node);
- IM_ASSERT(last_focused_root_node == DockNodeGetRootNode(payload_node));
- last_focused_node->LocalFlags |= ImGuiDockNodeFlags_CentralNode;
- node->LocalFlags &= ~ImGuiDockNodeFlags_CentralNode;
- last_focused_root_node->CentralNode = last_focused_node;
- }
+ const ImRect& curr = g.NavScoringRect; // Current modified source rect (NB: we've applied Max.x = Min.x in NavUpdate() to inhibit the effect of having varied item width)
+ g.NavScoringCount++;
- IM_ASSERT(node->Windows.Size == 0);
- DockNodeMoveChildNodes(node, payload_node);
- }
- else
- {
- const ImGuiID payload_dock_id = payload_node->ID;
- DockNodeMoveWindows(node, payload_node);
- DockSettingsRenameNodeReferences(payload_dock_id, node->ID);
- }
- DockContextRemoveNode(ctx, payload_node, true);
- }
- else if (payload_window)
- {
- // Transfer single window
- const ImGuiID payload_dock_id = payload_window->DockId;
- node->VisibleWindow = payload_window;
- DockNodeAddWindow(node, payload_window, true);
- if (payload_dock_id != 0)
- DockSettingsRenameNodeReferences(payload_dock_id, node->ID);
- }
- }
- else
+ // When entering through a NavFlattened border, we consider child window items as fully clipped for scoring
+ if (window->ParentWindow == g.NavWindow)
{
- // When docking a floating single window node we want to reevaluate auto-hiding of the tab bar
- node->WantHiddenTabBarUpdate = true;
+ IM_ASSERT((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened);
+ if (!window->ClipRect.Overlaps(cand))
+ return false;
+ cand.ClipWithFull(window->ClipRect); // This allows the scored item to not overlap other candidates in the parent window
}
- // Update selection immediately
- if (ImGuiTabBar* tab_bar = node->TabBar)
- tab_bar->NextSelectedTabId = next_selected_id;
- MarkIniSettingsDirty();
-}
+ // We perform scoring on items bounding box clipped by the current clipping rectangle on the other axis (clipping on our movement axis would give us equal scores for all clipped items)
+ // For example, this ensure that items in one column are not reached when moving vertically from items in another column.
+ NavClampRectToVisibleAreaForMoveDir(g.NavMoveClipDir, cand, window->ClipRect);
-void ImGui::DockContextProcessUndockWindow(ImGuiContext* ctx, ImGuiWindow* window, bool clear_persistent_docking_ref)
-{
- (void)ctx;
- if (window->DockNode)
- DockNodeRemoveWindow(window->DockNode, window, clear_persistent_docking_ref ? 0 : window->DockId);
- else
- window->DockId = 0;
- window->Collapsed = false;
- window->DockIsActive = false;
- window->DockTabIsVisible = false;
- MarkIniSettingsDirty();
-}
+ // Compute distance between boxes
+ // FIXME-NAV: Introducing biases for vertical navigation, needs to be removed.
+ float dbx = NavScoreItemDistInterval(cand.Min.x, cand.Max.x, curr.Min.x, curr.Max.x);
+ float dby = NavScoreItemDistInterval(ImLerp(cand.Min.y, cand.Max.y, 0.2f), ImLerp(cand.Min.y, cand.Max.y, 0.8f), ImLerp(curr.Min.y, curr.Max.y, 0.2f), ImLerp(curr.Min.y, curr.Max.y, 0.8f)); // Scale down on Y to keep using box-distance for vertically touching items
+ if (dby != 0.0f && dbx != 0.0f)
+ dbx = (dbx/1000.0f) + ((dbx > 0.0f) ? +1.0f : -1.0f);
+ float dist_box = ImFabs(dbx) + ImFabs(dby);
-void ImGui::DockContextProcessUndockNode(ImGuiContext* ctx, ImGuiDockNode* node)
-{
- IM_ASSERT(node->IsLeafNode());
- IM_ASSERT(node->Windows.Size >= 1);
+ // Compute distance between centers (this is off by a factor of 2, but we only compare center distances with each other so it doesn't matter)
+ float dcx = (cand.Min.x + cand.Max.x) - (curr.Min.x + curr.Max.x);
+ float dcy = (cand.Min.y + cand.Max.y) - (curr.Min.y + curr.Max.y);
+ float dist_center = ImFabs(dcx) + ImFabs(dcy); // L1 metric (need this for our connectedness guarantee)
- if (node->IsRootNode() || node->IsCentralNode())
- {
- // In the case of a root node or central node, the node will have to stay in place. Create a new node to receive the payload.
- ImGuiDockNode* new_node = DockContextAddNode(ctx, 0);
- DockNodeMoveWindows(new_node, node);
- DockSettingsRenameNodeReferences(node->ID, new_node->ID);
- for (int n = 0; n < new_node->Windows.Size; n++)
- UpdateWindowParentAndRootLinks(new_node->Windows[n], new_node->Windows[n]->Flags, NULL);
- new_node->AuthorityForPos = new_node->AuthorityForSize = ImGuiDataAuthority_Window;
- new_node->WantMouseMove = true;
- }
- else
+ // Determine which quadrant of 'curr' our candidate item 'cand' lies in based on distance
+ ImGuiDir quadrant;
+ float dax = 0.0f, day = 0.0f, dist_axial = 0.0f;
+ if (dbx != 0.0f || dby != 0.0f)
{
- // Otherwise extract our node and merging our sibling back into the parent node.
- IM_ASSERT(node->ParentNode->ChildNodes[0] == node || node->ParentNode->ChildNodes[1] == node);
- int index_in_parent = (node->ParentNode->ChildNodes[0] == node) ? 0 : 1;
- node->ParentNode->ChildNodes[index_in_parent] = NULL;
- DockNodeTreeMerge(ctx, node->ParentNode, node->ParentNode->ChildNodes[index_in_parent ^ 1]);
- node->ParentNode->AuthorityForViewport = ImGuiDataAuthority_Window; // The node that stays in place keeps the viewport, so our newly dragged out node will create a new viewport
- node->ParentNode = NULL;
- node->AuthorityForPos = node->AuthorityForSize = ImGuiDataAuthority_Window;
- node->WantMouseMove = true;
+ // For non-overlapping boxes, use distance between boxes
+ dax = dbx;
+ day = dby;
+ dist_axial = dist_box;
+ quadrant = ImGetDirQuadrantFromDelta(dbx, dby);
}
- MarkIniSettingsDirty();
-}
-
-// This is mostly used for automation.
-bool ImGui::DockContextCalcDropPosForDocking(ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload, ImGuiDir split_dir, bool split_outer, ImVec2* out_pos)
-{
- if (split_outer)
+ else if (dcx != 0.0f || dcy != 0.0f)
{
- IM_ASSERT(0);
+ // For overlapping boxes with different centers, use distance between centers
+ dax = dcx;
+ day = dcy;
+ dist_axial = dist_center;
+ quadrant = ImGetDirQuadrantFromDelta(dcx, dcy);
}
else
{
- ImGuiDockPreviewData split_data;
- DockNodePreviewDockCalc(target, target_node, payload, &split_data, false, split_outer);
- if (split_data.DropRectsDraw[split_dir+1].IsInverted())
- return false;
- *out_pos = split_data.DropRectsDraw[split_dir+1].GetCenter();
- return true;
- }
- return false;
-}
-
-//-----------------------------------------------------------------------------
-// Docking: ImGuiDockNode
-//-----------------------------------------------------------------------------
-// - DockNodeGetTabOrder()
-// - DockNodeAddWindow()
-// - DockNodeRemoveWindow()
-// - DockNodeMoveChildNodes()
-// - DockNodeMoveWindows()
-// - DockNodeApplyPosSizeToWindows()
-// - DockNodeHideHostWindow()
-// - ImGuiDockNodeFindInfoResults
-// - DockNodeFindInfo()
-// - DockNodeFindWindowByID()
-// - DockNodeUpdateVisibleFlagAndInactiveChilds()
-// - DockNodeUpdateVisibleFlag()
-// - DockNodeStartMouseMovingWindow()
-// - DockNodeUpdate()
-// - DockNodeUpdateWindowMenu()
-// - DockNodeUpdateTabBar()
-// - DockNodeAddTabBar()
-// - DockNodeRemoveTabBar()
-// - DockNodeIsDropAllowedOne()
-// - DockNodeIsDropAllowed()
-// - DockNodeCalcTabBarLayout()
-// - DockNodeCalcSplitRects()
-// - DockNodeCalcDropRectsAndTestMousePos()
-// - DockNodePreviewDockCalc()
-// - DockNodePreviewDockRender()
-//-----------------------------------------------------------------------------
-
-ImGuiDockNode::ImGuiDockNode(ImGuiID id)
-{
- ID = id;
- SharedFlags = LocalFlags = ImGuiDockNodeFlags_None;
- ParentNode = ChildNodes[0] = ChildNodes[1] = NULL;
- TabBar = NULL;
- SplitAxis = ImGuiAxis_None;
-
- State = ImGuiDockNodeState_Unknown;
- HostWindow = VisibleWindow = NULL;
- CentralNode = OnlyNodeWithWindows = NULL;
- LastFrameAlive = LastFrameActive = LastFrameFocused = -1;
- LastFocusedNodeID = 0;
- SelectedTabID = 0;
- WantCloseTabID = 0;
- AuthorityForPos = AuthorityForSize = ImGuiDataAuthority_DockNode;
- AuthorityForViewport = ImGuiDataAuthority_Auto;
- IsVisible = true;
- IsFocused = HasCloseButton = HasWindowMenuButton = EnableCloseButton = false;
- WantCloseAll = WantLockSizeOnce = WantMouseMove = WantHiddenTabBarUpdate = WantHiddenTabBarToggle = false;
- MarkedForPosSizeWrite = false;
-}
-
-ImGuiDockNode::~ImGuiDockNode()
-{
- IM_DELETE(TabBar);
- TabBar = NULL;
- ChildNodes[0] = ChildNodes[1] = NULL;
-}
-
-int ImGui::DockNodeGetTabOrder(ImGuiWindow* window)
-{
- ImGuiTabBar* tab_bar = window->DockNode->TabBar;
- if (tab_bar == NULL)
- return -1;
- ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, window->ID);
- return tab ? tab_bar->GetTabOrder(tab) : -1;
-}
-
-static void ImGui::DockNodeAddWindow(ImGuiDockNode* node, ImGuiWindow* window, bool add_to_tab_bar)
-{
- ImGuiContext& g = *GImGui; (void)g;
- if (window->DockNode)
- {
- // Can overwrite an existing window->DockNode (e.g. pointing to a disabled DockSpace node)
- IM_ASSERT(window->DockNode->ID != node->ID);
- DockNodeRemoveWindow(window->DockNode, window, 0);
+ // Degenerate case: two overlapping buttons with same center, break ties arbitrarily (note that LastItemId here is really the _previous_ item order, but it doesn't matter)
+ quadrant = (window->DC.LastItemId < g.NavId) ? ImGuiDir_Left : ImGuiDir_Right;
}
- IM_ASSERT(window->DockNode == NULL || window->DockNodeAsHost == NULL);
- IMGUI_DEBUG_LOG_DOCKING("DockNodeAddWindow node 0x%08X window '%s'\n", node->ID, window->Name);
-
- node->Windows.push_back(window);
- node->WantHiddenTabBarUpdate = true;
- window->DockNode = node;
- window->DockId = node->ID;
- window->DockIsActive = (node->Windows.Size > 1);
- window->DockTabWantClose = false;
- // If more than 2 windows appeared on the same frame, we'll create a new hosting DockNode from the point of the second window submission.
- // Then we need to hide the first window (after its been output) otherwise it would be visible as a standalone window for one frame.
- if (node->HostWindow == NULL && node->Windows.Size == 2 && node->Windows[0]->WasActive == false)
+#if IMGUI_DEBUG_NAV_SCORING
+ char buf[128];
+ if (IsMouseHoveringRect(cand.Min, cand.Max))
{
- node->Windows[0]->Hidden = true;
- node->Windows[0]->HiddenFramesCanSkipItems = 1;
+ ImFormatString(buf, IM_ARRAYSIZE(buf), "dbox (%.2f,%.2f->%.4f)\ndcen (%.2f,%.2f->%.4f)\nd (%.2f,%.2f->%.4f)\nnav %c, quadrant %c", dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial, "WENS"[g.NavMoveDir], "WENS"[quadrant]);
+ ImDrawList* draw_list = GetForegroundDrawList(window);
+ draw_list->AddRect(curr.Min, curr.Max, IM_COL32(255,200,0,100));
+ draw_list->AddRect(cand.Min, cand.Max, IM_COL32(255,255,0,200));
+ draw_list->AddRectFilled(cand.Max - ImVec2(4,4), cand.Max + CalcTextSize(buf) + ImVec2(4,4), IM_COL32(40,0,0,150));
+ draw_list->AddText(g.IO.FontDefault, 13.0f, cand.Max, ~0U, buf);
}
-
- // When reactivating a node with one or two loose window, the window pos/size/viewport are authoritative over the node storage.
- // In particular it is important we init the viewport from the first window so we don't create two viewports and drop one.
- if (node->HostWindow == NULL && node->IsFloatingNode())
+ else if (g.IO.KeyCtrl) // Hold to preview score in matching quadrant. Press C to rotate.
{
- if (node->AuthorityForPos == ImGuiDataAuthority_Auto)
- node->AuthorityForPos = ImGuiDataAuthority_Window;
- if (node->AuthorityForSize == ImGuiDataAuthority_Auto)
- node->AuthorityForSize = ImGuiDataAuthority_Window;
- if (node->AuthorityForViewport == ImGuiDataAuthority_Auto)
- node->AuthorityForViewport = ImGuiDataAuthority_Window;
+ if (IsKeyPressedMap(ImGuiKey_C)) { g.NavMoveDirLast = (ImGuiDir)((g.NavMoveDirLast + 1) & 3); g.IO.KeysDownDuration[g.IO.KeyMap[ImGuiKey_C]] = 0.01f; }
+ if (quadrant == g.NavMoveDir)
+ {
+ ImFormatString(buf, IM_ARRAYSIZE(buf), "%.0f/%.0f", dist_box, dist_center);
+ ImDrawList* draw_list = GetForegroundDrawList(window);
+ draw_list->AddRectFilled(cand.Min, cand.Max, IM_COL32(255, 0, 0, 200));
+ draw_list->AddText(g.IO.FontDefault, 13.0f, cand.Min, IM_COL32(255, 255, 255, 255), buf);
+ }
}
+ #endif
- // Add to tab bar if requested
- if (add_to_tab_bar)
+ // Is it in the quadrant we're interesting in moving to?
+ bool new_best = false;
+ if (quadrant == g.NavMoveDir)
{
- if (node->TabBar == NULL)
+ // Does it beat the current best candidate?
+ if (dist_box < result->DistBox)
{
- DockNodeAddTabBar(node);
- node->TabBar->SelectedTabId = node->TabBar->NextSelectedTabId = node->SelectedTabID;
-
- // Add existing windows
- for (int n = 0; n < node->Windows.Size - 1; n++)
- TabBarAddTab(node->TabBar, ImGuiTabItemFlags_None, node->Windows[n]);
+ result->DistBox = dist_box;
+ result->DistCenter = dist_center;
+ return true;
+ }
+ if (dist_box == result->DistBox)
+ {
+ // Try using distance between center points to break ties
+ if (dist_center < result->DistCenter)
+ {
+ result->DistCenter = dist_center;
+ new_best = true;
+ }
+ else if (dist_center == result->DistCenter)
+ {
+ // Still tied! we need to be extra-careful to make sure everything gets linked properly. We consistently break ties by symbolically moving "later" items
+ // (with higher index) to the right/downwards by an infinitesimal amount since we the current "best" button already (so it must have a lower index),
+ // this is fairly easy. This rule ensures that all buttons with dx==dy==0 will end up being linked in order of appearance along the x axis.
+ if (((g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? dby : dbx) < 0.0f) // moving bj to the right/down decreases distance
+ new_best = true;
+ }
}
- TabBarAddTab(node->TabBar, ImGuiTabItemFlags_Unsorted, window);
}
- DockNodeUpdateVisibleFlag(node);
+ // Axial check: if 'curr' has no link at all in some direction and 'cand' lies roughly in that direction, add a tentative link. This will only be kept if no "real" matches
+ // are found, so it only augments the graph produced by the above method using extra links. (important, since it doesn't guarantee strong connectedness)
+ // This is just to avoid buttons having no links in a particular direction when there's a suitable neighbor. you get good graphs without this too.
+ // 2017/09/29: FIXME: This now currently only enabled inside menu bars, ideally we'd disable it everywhere. Menus in particular need to catch failure. For general navigation it feels awkward.
+ // Disabling it may lead to disconnected graphs when nodes are very spaced out on different axis. Perhaps consider offering this as an option?
+ if (result->DistBox == FLT_MAX && dist_axial < result->DistAxial) // Check axial match
+ if (g.NavLayer == ImGuiNavLayer_Menu && !(g.NavWindow->Flags & ImGuiWindowFlags_ChildMenu))
+ if ((g.NavMoveDir == ImGuiDir_Left && dax < 0.0f) || (g.NavMoveDir == ImGuiDir_Right && dax > 0.0f) || (g.NavMoveDir == ImGuiDir_Up && day < 0.0f) || (g.NavMoveDir == ImGuiDir_Down && day > 0.0f))
+ {
+ result->DistAxial = dist_axial;
+ new_best = true;
+ }
- // Update this without waiting for the next time we Begin() in the window, so our host window will have the proper title bar color on its first frame.
- if (node->HostWindow)
- UpdateWindowParentAndRootLinks(window, window->Flags | ImGuiWindowFlags_ChildWindow, node->HostWindow);
+ return new_best;
}
-static void ImGui::DockNodeRemoveWindow(ImGuiDockNode* node, ImGuiWindow* window, ImGuiID save_dock_id)
+// We get there when either NavId == id, or when g.NavAnyRequest is set (which is updated by NavUpdateAnyRequestFlag above)
+static void ImGui::NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, const ImGuiID id)
{
ImGuiContext& g = *GImGui;
- IM_ASSERT(window->DockNode == node);
- //IM_ASSERT(window->RootWindow == node->HostWindow);
- //IM_ASSERT(window->LastFrameActive < g.FrameCount); // We may call this from Begin()
- IM_ASSERT(save_dock_id == 0 || save_dock_id == node->ID);
- IMGUI_DEBUG_LOG_DOCKING("DockNodeRemoveWindow node 0x%08X window '%s'\n", node->ID, window->Name);
+ //if (!g.IO.NavActive) // [2017/10/06] Removed this possibly redundant test but I am not sure of all the side-effects yet. Some of the feature here will need to work regardless of using a _NoNavInputs flag.
+ // return;
- window->DockNode = NULL;
- window->DockIsActive = window->DockTabWantClose = false;
- window->DockId = save_dock_id;
- UpdateWindowParentAndRootLinks(window, window->Flags & ~ImGuiWindowFlags_ChildWindow, NULL); // Update immediately
+ const ImGuiItemFlags item_flags = window->DC.ItemFlags;
+ const ImRect nav_bb_rel(nav_bb.Min - window->Pos, nav_bb.Max - window->Pos);
- // Remove window
- bool erased = false;
- for (int n = 0; n < node->Windows.Size; n++)
- if (node->Windows[n] == window)
+ // Process Init Request
+ if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent)
+ {
+ // Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback
+ if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus) || g.NavInitResultId == 0)
{
- node->Windows.erase(node->Windows.Data + n);
- erased = true;
- break;
+ g.NavInitResultId = id;
+ g.NavInitResultRectRel = nav_bb_rel;
+ }
+ if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus))
+ {
+ g.NavInitRequest = false; // Found a match, clear request
+ NavUpdateAnyRequestFlag();
}
- IM_ASSERT(erased);
- if (node->VisibleWindow == window)
- node->VisibleWindow = NULL;
-
- // Remove tab and possibly tab bar
- node->WantHiddenTabBarUpdate = true;
- if (node->TabBar)
- {
- TabBarRemoveTab(node->TabBar, window->ID);
- const int tab_count_threshold_for_tab_bar = node->IsCentralNode() ? 1 : 2;
- if (node->Windows.Size < tab_count_threshold_for_tab_bar)
- DockNodeRemoveTabBar(node);
}
- if (node->Windows.Size == 0 && !node->IsCentralNode() && !node->IsDockSpace() && window->DockId != node->ID)
+ // Process Move Request (scoring for navigation)
+ // FIXME-NAV: Consider policy for double scoring (scoring from NavScoringRectScreen + scoring from a rect wrapped according to current wrapping policy)
+ if ((g.NavId != id || (g.NavMoveRequestFlags & ImGuiNavMoveFlags_AllowCurrentNavId)) && !(item_flags & (ImGuiItemFlags_Disabled|ImGuiItemFlags_NoNav)))
{
- // Automatic dock node delete themselves if they are not holding at least one tab
- DockContextRemoveNode(&g, node, true);
- return;
+ ImGuiNavMoveResult* result = (window == g.NavWindow) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;
+#if IMGUI_DEBUG_NAV_SCORING
+ // [DEBUG] Score all items in NavWindow at all times
+ if (!g.NavMoveRequest)
+ g.NavMoveDir = g.NavMoveDirLast;
+ bool new_best = NavScoreItem(result, nav_bb) && g.NavMoveRequest;
+#else
+ bool new_best = g.NavMoveRequest && NavScoreItem(result, nav_bb);
+#endif
+ if (new_best)
+ {
+ result->Window = window;
+ result->ID = id;
+ result->FocusScopeId = window->DC.NavFocusScopeIdCurrent;
+ result->RectRel = nav_bb_rel;
+ }
+
+ // Features like PageUp/PageDown need to maintain a separate score for the visible set of items.
+ const float VISIBLE_RATIO = 0.70f;
+ if ((g.NavMoveRequestFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb))
+ if (ImClamp(nav_bb.Max.y, window->ClipRect.Min.y, window->ClipRect.Max.y) - ImClamp(nav_bb.Min.y, window->ClipRect.Min.y, window->ClipRect.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO)
+ if (NavScoreItem(&g.NavMoveResultLocalVisibleSet, nav_bb))
+ {
+ result = &g.NavMoveResultLocalVisibleSet;
+ result->Window = window;
+ result->ID = id;
+ result->FocusScopeId = window->DC.NavFocusScopeIdCurrent;
+ result->RectRel = nav_bb_rel;
+ }
}
- if (node->Windows.Size == 1 && !node->IsCentralNode() && node->HostWindow)
+ // Update window-relative bounding box of navigated item
+ if (g.NavId == id)
{
- ImGuiWindow* remaining_window = node->Windows[0];
- if (node->HostWindow->ViewportOwned && node->IsRootNode())
- {
- // Transfer viewport back to the remaining loose window
- IM_ASSERT(node->HostWindow->Viewport->Window == node->HostWindow);
- node->HostWindow->Viewport->Window = remaining_window;
- node->HostWindow->Viewport->ID = remaining_window->ID;
- }
- remaining_window->Collapsed = node->HostWindow->Collapsed;
+ g.NavWindow = window; // Always refresh g.NavWindow, because some operations such as FocusItem() don't have a window.
+ g.NavLayer = window->DC.NavLayerCurrent;
+ g.NavFocusScopeId = window->DC.NavFocusScopeIdCurrent;
+ g.NavIdIsAlive = true;
+ g.NavIdTabCounter = window->DC.FocusCounterTabStop;
+ window->NavRectRel[window->DC.NavLayerCurrent] = nav_bb_rel; // Store item bounding box (relative to window position)
}
+}
- // Update visibility immediately is required so the DockNodeUpdateRemoveInactiveChilds() processing can reflect changes up the tree
- DockNodeUpdateVisibleFlag(node);
+bool ImGui::NavMoveRequestButNoResultYet()
+{
+ ImGuiContext& g = *GImGui;
+ return g.NavMoveRequest && g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0;
}
-static void ImGui::DockNodeMoveChildNodes(ImGuiDockNode* dst_node, ImGuiDockNode* src_node)
+void ImGui::NavMoveRequestCancel()
{
- IM_ASSERT(dst_node->Windows.Size == 0);
- dst_node->ChildNodes[0] = src_node->ChildNodes[0];
- dst_node->ChildNodes[1] = src_node->ChildNodes[1];
- if (dst_node->ChildNodes[0])
- dst_node->ChildNodes[0]->ParentNode = dst_node;
- if (dst_node->ChildNodes[1])
- dst_node->ChildNodes[1]->ParentNode = dst_node;
- dst_node->SplitAxis = src_node->SplitAxis;
- dst_node->SizeRef = src_node->SizeRef;
- src_node->ChildNodes[0] = src_node->ChildNodes[1] = NULL;
+ ImGuiContext& g = *GImGui;
+ g.NavMoveRequest = false;
+ NavUpdateAnyRequestFlag();
}
-static void ImGui::DockNodeMoveWindows(ImGuiDockNode* dst_node, ImGuiDockNode* src_node)
+void ImGui::NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, const ImRect& bb_rel, ImGuiNavMoveFlags move_flags)
{
- // Insert tabs in the same orders as currently ordered (node->Windows isn't ordered)
- IM_ASSERT(src_node && dst_node && dst_node != src_node);
- ImGuiTabBar* src_tab_bar = src_node->TabBar;
- if (src_tab_bar != NULL)
- IM_ASSERT(src_node->Windows.Size == src_node->TabBar->Tabs.Size);
-
- // If the dst_node is empty we can just move the entire tab bar (to preserve selection, scrolling, etc.)
- bool move_tab_bar = (src_tab_bar != NULL) && (dst_node->TabBar == NULL);
- if (move_tab_bar)
- {
- dst_node->TabBar = src_node->TabBar;
- src_node->TabBar = NULL;
- }
-
- for (int n = 0; n < src_node->Windows.Size; n++)
- {
- ImGuiWindow* window = src_tab_bar ? src_tab_bar->Tabs[n].Window : src_node->Windows[n];
- window->DockNode = NULL;
- window->DockIsActive = false;
- DockNodeAddWindow(dst_node, window, move_tab_bar ? false : true);
- }
- src_node->Windows.clear();
-
- if (!move_tab_bar && src_node->TabBar)
- {
- if (dst_node->TabBar)
- dst_node->TabBar->SelectedTabId = src_node->TabBar->SelectedTabId;
- DockNodeRemoveTabBar(src_node);
- }
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(g.NavMoveRequestForward == ImGuiNavForward_None);
+ NavMoveRequestCancel();
+ g.NavMoveDir = move_dir;
+ g.NavMoveClipDir = clip_dir;
+ g.NavMoveRequestForward = ImGuiNavForward_ForwardQueued;
+ g.NavMoveRequestFlags = move_flags;
+ g.NavWindow->NavRectRel[g.NavLayer] = bb_rel;
}
-static void ImGui::DockNodeApplyPosSizeToWindows(ImGuiDockNode* node)
+void ImGui::NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags)
{
- for (int n = 0; n < node->Windows.Size; n++)
- {
- SetWindowPos(node->Windows[n], node->Pos, ImGuiCond_Always); // We don't assign directly to Pos because it can break the calculation of SizeContents on next frame
- SetWindowSize(node->Windows[n], node->Size, ImGuiCond_Always);
- }
-}
+ ImGuiContext& g = *GImGui;
+ if (g.NavWindow != window || !NavMoveRequestButNoResultYet() || g.NavMoveRequestForward != ImGuiNavForward_None || g.NavLayer != ImGuiNavLayer_Main)
+ return;
+ IM_ASSERT(move_flags != 0); // No points calling this with no wrapping
+ ImRect bb_rel = window->NavRectRel[0];
-static void ImGui::DockNodeHideHostWindow(ImGuiDockNode* node)
-{
- if (node->HostWindow)
+ ImGuiDir clip_dir = g.NavMoveDir;
+ if (g.NavMoveDir == ImGuiDir_Left && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX)))
{
- if (node->HostWindow->DockNodeAsHost == node)
- node->HostWindow->DockNodeAsHost = NULL;
- node->HostWindow = NULL;
+ bb_rel.Min.x = bb_rel.Max.x = ImMax(window->SizeFull.x, window->ContentSize.x + window->WindowPadding.x * 2.0f) - window->Scroll.x;
+ if (move_flags & ImGuiNavMoveFlags_WrapX) { bb_rel.TranslateY(-bb_rel.GetHeight()); clip_dir = ImGuiDir_Up; }
+ NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags);
}
-
- if (node->Windows.Size == 1)
+ if (g.NavMoveDir == ImGuiDir_Right && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX)))
{
- node->VisibleWindow = node->Windows[0];
- node->Windows[0]->DockIsActive = false;
+ bb_rel.Min.x = bb_rel.Max.x = -window->Scroll.x;
+ if (move_flags & ImGuiNavMoveFlags_WrapX) { bb_rel.TranslateY(+bb_rel.GetHeight()); clip_dir = ImGuiDir_Down; }
+ NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags);
}
-
- if (node->TabBar)
- DockNodeRemoveTabBar(node);
-}
-
-// Search function called once by root node in DockNodeUpdate()
-struct ImGuiDockNodeFindInfoResults
-{
- ImGuiDockNode* CentralNode;
- ImGuiDockNode* FirstNodeWithWindows;
- int CountNodesWithWindows;
- //ImGuiWindowClass WindowClassForMerges;
-
- ImGuiDockNodeFindInfoResults() { CentralNode = FirstNodeWithWindows = NULL; CountNodesWithWindows = 0; }
-};
-
-static void DockNodeFindInfo(ImGuiDockNode* node, ImGuiDockNodeFindInfoResults* results)
-{
- if (node->Windows.Size > 0)
+ if (g.NavMoveDir == ImGuiDir_Up && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY)))
{
- if (results->FirstNodeWithWindows == NULL)
- results->FirstNodeWithWindows = node;
- results->CountNodesWithWindows++;
+ bb_rel.Min.y = bb_rel.Max.y = ImMax(window->SizeFull.y, window->ContentSize.y + window->WindowPadding.y * 2.0f) - window->Scroll.y;
+ if (move_flags & ImGuiNavMoveFlags_WrapY) { bb_rel.TranslateX(-bb_rel.GetWidth()); clip_dir = ImGuiDir_Left; }
+ NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags);
}
- if (node->IsCentralNode())
+ if (g.NavMoveDir == ImGuiDir_Down && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY)))
{
- IM_ASSERT(results->CentralNode == NULL); // Should be only one
- IM_ASSERT(node->IsLeafNode() && "If you get this assert: please submit .ini file + repro of actions leading to this.");
- results->CentralNode = node;
+ bb_rel.Min.y = bb_rel.Max.y = -window->Scroll.y;
+ if (move_flags & ImGuiNavMoveFlags_WrapY) { bb_rel.TranslateX(+bb_rel.GetWidth()); clip_dir = ImGuiDir_Right; }
+ NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags);
}
- if (results->CountNodesWithWindows > 1 && results->CentralNode != NULL)
- return;
- if (node->ChildNodes[0])
- DockNodeFindInfo(node->ChildNodes[0], results);
- if (node->ChildNodes[1])
- DockNodeFindInfo(node->ChildNodes[1], results);
}
-static ImGuiWindow* ImGui::DockNodeFindWindowByID(ImGuiDockNode* node, ImGuiID id)
+// FIXME: This could be replaced by updating a frame number in each window when (window == NavWindow) and (NavLayer == 0).
+// This way we could find the last focused window among our children. It would be much less confusing this way?
+static void ImGui::NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_window)
{
- IM_ASSERT(id != 0);
- for (int n = 0; n < node->Windows.Size; n++)
- if (node->Windows[n]->ID == id)
- return node->Windows[n];
- return NULL;
+ ImGuiWindow* parent_window = nav_window;
+ while (parent_window && (parent_window->Flags & ImGuiWindowFlags_ChildWindow) != 0 && (parent_window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0)
+ parent_window = parent_window->ParentWindow;
+ if (parent_window && parent_window != nav_window)
+ parent_window->NavLastChildNavWindow = nav_window;
}
-// - Remove inactive windows/nodes.
-// - Update visibility flag.
-static void ImGui::DockNodeUpdateVisibleFlagAndInactiveChilds(ImGuiDockNode* node)
+// Restore the last focused child.
+// Call when we are expected to land on the Main Layer (0) after FocusWindow()
+static ImGuiWindow* ImGui::NavRestoreLastChildNavWindow(ImGuiWindow* window)
{
- ImGuiContext& g = *GImGui;
-
- IM_ASSERT(node->ParentNode == NULL || node->ParentNode->ChildNodes[0] == node || node->ParentNode->ChildNodes[1] == node);
-
- // Inherit most flags
- if (node->ParentNode)
- node->SharedFlags = node->ParentNode->SharedFlags & ImGuiDockNodeFlags_SharedFlagsInheritMask_;
-
- // Recurse into children
- // There is the possibility that one of our child becoming empty will delete itself and moving its sibling contents into 'node'.
- // If 'node->ChildNode[0]' delete itself, then 'node->ChildNode[1]->Windows' will be moved into 'node'
- // If 'node->ChildNode[1]' delete itself, then 'node->ChildNode[0]->Windows' will be moved into 'node' and the "remove inactive windows" loop will have run twice on those windows (harmless)
- if (node->ChildNodes[0])
- DockNodeUpdateVisibleFlagAndInactiveChilds(node->ChildNodes[0]);
- if (node->ChildNodes[1])
- DockNodeUpdateVisibleFlagAndInactiveChilds(node->ChildNodes[1]);
-
- // Remove inactive windows
- for (int window_n = 0; window_n < node->Windows.Size; window_n++)
- {
- ImGuiWindow* window = node->Windows[window_n];
- IM_ASSERT(window->DockNode == node);
-
- bool node_was_active = (node->LastFrameActive + 1 == g.FrameCount);
- bool remove = false;
- remove |= node_was_active && (window->LastFrameActive + 1 < g.FrameCount);
- remove |= node_was_active && (node->WantCloseAll || node->WantCloseTabID == window->ID) && window->HasCloseButton && !(window->Flags & ImGuiWindowFlags_UnsavedDocument); // Submit all _expected_ closure from last frame
- remove |= (window->DockTabWantClose);
- if (!remove)
- continue;
- window->DockTabWantClose = false;
- if (node->Windows.Size == 1 && !node->IsCentralNode())
- {
- DockNodeHideHostWindow(node);
- node->State = ImGuiDockNodeState_HostWindowHiddenBecauseSingleWindow;
- DockNodeRemoveWindow(node, window, node->ID); // Will delete the node so it'll be invalid on return
- return;
- }
- DockNodeRemoveWindow(node, window, node->ID);
- window_n--;
- }
-
- // Auto-hide tab bar option
- ImGuiDockNodeFlags node_flags = node->GetMergedFlags();
- if (node->WantHiddenTabBarUpdate && node->Windows.Size == 1 && (node_flags & ImGuiDockNodeFlags_AutoHideTabBar) && !node->IsHiddenTabBar())
- node->WantHiddenTabBarToggle = true;
- node->WantHiddenTabBarUpdate = false;
-
- // Apply toggles at a single point of the frame (here!)
- if (node->Windows.Size > 1)
- node->LocalFlags &= ~ImGuiDockNodeFlags_HiddenTabBar;
- else if (node->WantHiddenTabBarToggle)
- node->LocalFlags ^= ImGuiDockNodeFlags_HiddenTabBar;
- node->WantHiddenTabBarToggle = false;
-
- DockNodeUpdateVisibleFlag(node);
+ return window->NavLastChildNavWindow ? window->NavLastChildNavWindow : window;
}
-static void ImGui::DockNodeUpdateVisibleFlag(ImGuiDockNode* node)
+static void NavRestoreLayer(ImGuiNavLayer layer)
{
- // Update visibility flag
- bool is_visible = (node->ParentNode == NULL) ? node->IsDockSpace() : node->IsCentralNode();
- is_visible |= (node->Windows.Size > 0);
- is_visible |= (node->ChildNodes[0] && node->ChildNodes[0]->IsVisible);
- is_visible |= (node->ChildNodes[1] && node->ChildNodes[1]->IsVisible);
- node->IsVisible = is_visible;
+ ImGuiContext& g = *GImGui;
+ g.NavLayer = layer;
+ if (layer == 0)
+ g.NavWindow = ImGui::NavRestoreLastChildNavWindow(g.NavWindow);
+ ImGuiWindow* window = g.NavWindow;
+ if (layer == 0 && window->NavLastIds[0] != 0)
+ ImGui::SetNavIDWithRectRel(window->NavLastIds[0], layer, 0, window->NavRectRel[0]);
+ else
+ ImGui::NavInitWindow(window, true);
}
-static void ImGui::DockNodeStartMouseMovingWindow(ImGuiDockNode* node, ImGuiWindow* window)
+static inline void ImGui::NavUpdateAnyRequestFlag()
{
ImGuiContext& g = *GImGui;
- IM_ASSERT(node->WantMouseMove == true);
- ImVec2 backup_active_click_offset = g.ActiveIdClickOffset;
- StartMouseMovingWindow(window);
- g.MovingWindow = window; // If we are docked into a non moveable root window, StartMouseMovingWindow() won't set g.MovingWindow. Override that decision.
- node->WantMouseMove = false;
- g.ActiveIdClickOffset = backup_active_click_offset;
+ g.NavAnyRequest = g.NavMoveRequest || g.NavInitRequest || (IMGUI_DEBUG_NAV_SCORING && g.NavWindow != NULL);
+ if (g.NavAnyRequest)
+ IM_ASSERT(g.NavWindow != NULL);
}
-static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
+// This needs to be called before we submit any widget (aka in or before Begin)
+void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit)
{
ImGuiContext& g = *GImGui;
- IM_ASSERT(node->LastFrameActive != g.FrameCount);
- node->LastFrameAlive = g.FrameCount;
- node->MarkedForPosSizeWrite = false;
-
- node->CentralNode = node->OnlyNodeWithWindows = NULL;
- if (node->IsRootNode())
+ IM_ASSERT(window == g.NavWindow);
+ bool init_for_nav = false;
+ if (!(window->Flags & ImGuiWindowFlags_NoNavInputs))
+ if (!(window->Flags & ImGuiWindowFlags_ChildWindow) || (window->Flags & ImGuiWindowFlags_Popup) || (window->NavLastIds[0] == 0) || force_reinit)
+ init_for_nav = true;
+ //IMGUI_DEBUG_LOG("[Nav] NavInitWindow() init_for_nav=%d, window=\"%s\", layer=%d\n", init_for_nav, window->Name, g.NavLayer);
+ if (init_for_nav)
{
- DockNodeUpdateVisibleFlagAndInactiveChilds(node);
-
- // FIXME-DOCK: Merge this scan into the one above.
- // - Setup central node pointers
- // - Find if there's only a single visible window in the hierarchy (in which case we need to display a regular title bar -> FIXME-DOCK: that last part is not done yet!)
- ImGuiDockNodeFindInfoResults results;
- DockNodeFindInfo(node, &results);
- node->CentralNode = results.CentralNode;
- node->OnlyNodeWithWindows = (results.CountNodesWithWindows == 1) ? results.FirstNodeWithWindows : NULL;
- if (node->LastFocusedNodeID == 0 && results.FirstNodeWithWindows != NULL)
- node->LastFocusedNodeID = results.FirstNodeWithWindows->ID;
-
- // Copy the window class from of our first window so it can be used for proper dock filtering.
- // When node has mixed windows, prioritize the class with the most constraint (DockingAllowUnclassed = false) as the reference to copy.
- // FIXME-DOCK: We don't recurse properly, this code could be reworked to work from DockNodeUpdateScanRec.
- if (ImGuiDockNode* first_node_with_windows = results.FirstNodeWithWindows)
- {
- node->WindowClass = first_node_with_windows->Windows[0]->WindowClass;
- for (int n = 1; n < first_node_with_windows->Windows.Size; n++)
- if (first_node_with_windows->Windows[n]->WindowClass.DockingAllowUnclassed == false)
- {
- node->WindowClass = first_node_with_windows->Windows[n]->WindowClass;
- break;
- }
- }
+ SetNavID(0, g.NavLayer, 0);
+ g.NavInitRequest = true;
+ g.NavInitRequestFromMove = false;
+ g.NavInitResultId = 0;
+ g.NavInitResultRectRel = ImRect();
+ NavUpdateAnyRequestFlag();
}
-
- // Remove tab bar if not needed
- if (node->TabBar && node->IsNoTabBar())
- DockNodeRemoveTabBar(node);
-
- // Early out for hidden root dock nodes (when all DockId references are in inactive windows, or there is only 1 floating window holding on the DockId)
- bool want_to_hide_host_window = false;
- if (node->Windows.Size <= 1 && node->IsFloatingNode() && node->IsLeafNode())
- if (!g.IO.ConfigDockingAlwaysTabBar && (node->Windows.Size == 0 || !node->Windows[0]->WindowClass.DockingAlwaysTabBar))
- want_to_hide_host_window = true;
- if (want_to_hide_host_window)
+ else
{
- if (node->Windows.Size == 1)
- {
- // Floating window pos/size is authoritative
- ImGuiWindow* single_window = node->Windows[0];
- node->Pos = single_window->Pos;
- node->Size = single_window->SizeFull;
- node->AuthorityForPos = node->AuthorityForSize = node->AuthorityForViewport = ImGuiDataAuthority_Window;
-
- // Transfer focus immediately so when we revert to a regular window it is immediately selected
- if (node->HostWindow && g.NavWindow == node->HostWindow)
- FocusWindow(single_window);
- if (node->HostWindow)
- {
- single_window->Viewport = node->HostWindow->Viewport;
- single_window->ViewportId = node->HostWindow->ViewportId;
- if (node->HostWindow->ViewportOwned)
- {
- single_window->Viewport->Window = single_window;
- single_window->ViewportOwned = true;
- }
- }
- }
-
- DockNodeHideHostWindow(node);
- node->State = ImGuiDockNodeState_HostWindowHiddenBecauseSingleWindow;
- node->WantCloseAll = false;
- node->WantCloseTabID = 0;
- node->HasCloseButton = node->HasWindowMenuButton = node->EnableCloseButton = false;
- node->LastFrameActive = g.FrameCount;
-
- if (node->WantMouseMove && node->Windows.Size == 1)
- DockNodeStartMouseMovingWindow(node, node->Windows[0]);
- return;
- }
-
- // In some circumstance we will defer creating the host window (so everything will be kept hidden),
- // while the expected visible window is resizing itself.
- // This is important for first-time (no ini settings restored) single window when io.ConfigDockingAlwaysTabBar is enabled,
- // otherwise the node ends up using the minimum window size. Effectively those windows will take an extra frame to show up:
- // N+0: Begin(): window created (with no known size), node is created
- // N+1: DockNodeUpdate(): node skip creating host window / Begin(): window size applied, not visible
- // N+2: DockNodeUpdate(): node can create host window / Begin(): window becomes visible
- // We could remove this frame if we could reliably calculate the expected window size during node update, before the Begin() code.
- // It would require a generalization of CalcWindowExpectedSize(), probably extracting code away from Begin().
- // In reality it isn't very important as user quickly ends up with size data in .ini file.
- if (node->IsVisible && node->HostWindow == NULL && node->IsFloatingNode() && node->IsLeafNode())
- {
- IM_ASSERT(node->Windows.Size > 0);
- ImGuiWindow* ref_window = NULL;
- if (node->SelectedTabID != 0) // Note that we prune single-window-node settings on .ini loading, so this is generally 0 for them!
- ref_window = DockNodeFindWindowByID(node, node->SelectedTabID);
- if (ref_window == NULL)
- ref_window = node->Windows[0];
- if (ref_window->AutoFitFramesX > 0 || ref_window->AutoFitFramesY > 0)
- {
- node->State = ImGuiDockNodeState_HostWindowHiddenBecauseWindowsAreResizing;
- return;
- }
+ g.NavId = window->NavLastIds[0];
+ g.NavFocusScopeId = 0;
}
+}
- const ImGuiDockNodeFlags node_flags = node->GetMergedFlags();
-
- // Bind or create host window
- ImGuiWindow* host_window = NULL;
- bool beginned_into_host_window = false;
- if (node->IsDockSpace())
+static ImVec2 ImGui::NavCalcPreferredRefPos()
+{
+ ImGuiContext& g = *GImGui;
+ if (g.NavDisableHighlight || !g.NavDisableMouseHover || !g.NavWindow)
{
- // [Explicit root dockspace node]
- IM_ASSERT(node->HostWindow);
- node->EnableCloseButton = false;
- node->HasCloseButton = (node_flags & ImGuiDockNodeFlags_NoCloseButton) == 0;
- node->HasWindowMenuButton = (node_flags & ImGuiDockNodeFlags_NoWindowMenuButton) == 0;
- host_window = node->HostWindow;
+ // Mouse (we need a fallback in case the mouse becomes invalid after being used)
+ if (IsMousePosValid(&g.IO.MousePos))
+ return g.IO.MousePos;
+ return g.LastValidMousePos;
}
else
{
- // [Automatic root or child nodes]
- node->EnableCloseButton = false;
- node->HasCloseButton = (node->Windows.Size > 0) && (node_flags & ImGuiDockNodeFlags_NoWindowMenuButton) == 0;
- node->HasWindowMenuButton = (node->Windows.Size > 0) && (node_flags & ImGuiDockNodeFlags_NoWindowMenuButton) == 0;
- for (int window_n = 0; window_n < node->Windows.Size; window_n++)
- {
- // FIXME-DOCK: Setting DockIsActive here means that for single active window in a leaf node, DockIsActive will be cleared until the next Begin() call.
- ImGuiWindow* window = node->Windows[window_n];
- window->DockIsActive = (node->Windows.Size > 1);
- node->EnableCloseButton |= window->HasCloseButton;
- }
-
- if (node->IsRootNode() && node->IsVisible)
- {
- ImGuiWindow* ref_window = (node->Windows.Size > 0) ? node->Windows[0] : NULL;
-
- // Sync Pos
- if (node->AuthorityForPos == ImGuiDataAuthority_Window && ref_window)
- SetNextWindowPos(ref_window->Pos);
- else if (node->AuthorityForPos == ImGuiDataAuthority_DockNode)
- SetNextWindowPos(node->Pos);
-
- // Sync Size
- if (node->AuthorityForSize == ImGuiDataAuthority_Window && ref_window)
- SetNextWindowSize(ref_window->SizeFull);
- else if (node->AuthorityForSize == ImGuiDataAuthority_DockNode)
- SetNextWindowSize(node->Size);
-
- // Sync Collapsed
- if (node->AuthorityForSize == ImGuiDataAuthority_Window && ref_window)
- SetNextWindowCollapsed(ref_window->Collapsed);
-
- // Sync Viewport
- if (node->AuthorityForViewport == ImGuiDataAuthority_Window && ref_window)
- SetNextWindowViewport(ref_window->ViewportId);
-
- SetNextWindowClass(&node->WindowClass);
-
- // Begin into the host window
- char window_label[20];
- DockNodeGetHostWindowTitle(node, window_label, IM_ARRAYSIZE(window_label));
- ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_DockNodeHost;
- window_flags |= ImGuiWindowFlags_NoFocusOnAppearing;
- window_flags |= ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_NoCollapse;
- window_flags |= ImGuiWindowFlags_NoTitleBar;
-
- PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
- Begin(window_label, NULL, window_flags);
- PopStyleVar();
- beginned_into_host_window = true;
-
- node->HostWindow = host_window = g.CurrentWindow;
- host_window->DockNodeAsHost = node;
- host_window->DC.CursorPos = host_window->Pos;
- node->Pos = host_window->Pos;
- node->Size = host_window->Size;
-
- // We set ImGuiWindowFlags_NoFocusOnAppearing because we don't want the host window to take full focus (e.g. steal NavWindow)
- // But we still it bring it to the front of display. There's no way to choose this precise behavior via window flags.
- // One simple case to ponder if: window A has a toggle to create windows B/C/D. Dock B/C/D together, clear the toggle and enable it again.
- // When reappearing B/C/D will request focus and be moved to the top of the display pile, but they are not linked to the dock host window
- // during the frame they appear. The dock host window would keep its old display order, and the sorting in EndFrame would move B/C/D back
- // after the dock host window, losing their top-most status.
- if (node->HostWindow->Appearing)
- BringWindowToDisplayFront(node->HostWindow);
-
- node->AuthorityForPos = node->AuthorityForSize = node->AuthorityForViewport = ImGuiDataAuthority_Auto;
- }
- else if (node->ParentNode)
- {
- node->HostWindow = host_window = node->ParentNode->HostWindow;
- node->AuthorityForPos = node->AuthorityForSize = node->AuthorityForViewport = ImGuiDataAuthority_Auto;
- }
- if (node->WantMouseMove && node->HostWindow)
- DockNodeStartMouseMovingWindow(node, node->HostWindow);
+ // When navigation is active and mouse is disabled, decide on an arbitrary position around the bottom left of the currently navigated item.
+ const ImRect& rect_rel = g.NavWindow->NavRectRel[g.NavLayer];
+ ImVec2 pos = g.NavWindow->Pos + ImVec2(rect_rel.Min.x + ImMin(g.Style.FramePadding.x * 4, rect_rel.GetWidth()), rect_rel.Max.y - ImMin(g.Style.FramePadding.y, rect_rel.GetHeight()));
+ ImRect visible_rect = GetViewportRect();
+ return ImFloor(ImClamp(pos, visible_rect.Min, visible_rect.Max)); // ImFloor() is important because non-integer mouse position application in back-end might be lossy and result in undesirable non-zero delta.
}
+}
- // Update focused node (the one whose title bar is highlight) within a node tree
- if (node->IsSplitNode())
- IM_ASSERT(node->TabBar == NULL);
- if (node->IsRootNode())
- if (g.NavWindow && g.NavWindow->RootWindowDockStop->DockNode && g.NavWindow->RootWindowDockStop->ParentWindow == host_window)
- node->LastFocusedNodeID = g.NavWindow->RootWindowDockStop->DockNode->ID;
+float ImGui::GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode)
+{
+ ImGuiContext& g = *GImGui;
+ if (mode == ImGuiInputReadMode_Down)
+ return g.IO.NavInputs[n]; // Instant, read analog input (0.0f..1.0f, as provided by user)
- // We need to draw a background at the root level if requested by ImGuiDockNodeFlags_PassthruCentralNode, but we will only know the correct pos/size after
- // processing the resizing splitters. So we are using the DrawList channel splitting facility to submit drawing primitives out of order!
- const bool render_dockspace_bg = node->IsRootNode() && host_window && (node_flags & ImGuiDockNodeFlags_PassthruCentralNode) != 0;
- if (render_dockspace_bg)
- {
- host_window->DrawList->ChannelsSplit(2);
- host_window->DrawList->ChannelsSetCurrent(1);
- }
+ const float t = g.IO.NavInputsDownDuration[n];
+ if (t < 0.0f && mode == ImGuiInputReadMode_Released) // Return 1.0f when just released, no repeat, ignore analog input.
+ return (g.IO.NavInputsDownDurationPrev[n] >= 0.0f ? 1.0f : 0.0f);
+ if (t < 0.0f)
+ return 0.0f;
+ if (mode == ImGuiInputReadMode_Pressed) // Return 1.0f when just pressed, no repeat, ignore analog input.
+ return (t == 0.0f) ? 1.0f : 0.0f;
+ if (mode == ImGuiInputReadMode_Repeat)
+ return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 0.72f, g.IO.KeyRepeatRate * 0.80f);
+ if (mode == ImGuiInputReadMode_RepeatSlow)
+ return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 1.25f, g.IO.KeyRepeatRate * 2.00f);
+ if (mode == ImGuiInputReadMode_RepeatFast)
+ return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 0.72f, g.IO.KeyRepeatRate * 0.30f);
+ return 0.0f;
+}
- // Register a hit-test hole in the window unless we are currently dragging a window that is compatible with our dockspace
- const ImGuiDockNode* central_node = node->CentralNode;
- const bool central_node_hole = node->IsRootNode() && host_window && (node_flags & ImGuiDockNodeFlags_PassthruCentralNode) != 0 && central_node != NULL && central_node->IsEmpty();
- bool central_node_hole_register_hit_test_hole = central_node_hole;
- if (central_node_hole)
- if (const ImGuiPayload* payload = ImGui::GetDragDropPayload())
- if (payload->IsDataType(IMGUI_PAYLOAD_TYPE_WINDOW) && DockNodeIsDropAllowed(host_window, *(ImGuiWindow**)payload->Data))
- central_node_hole_register_hit_test_hole = false;
- if (central_node_hole_register_hit_test_hole)
- {
- // Add a little padding to match the "resize from edges" behavior and allow grabbing the splitter easily.
- IM_ASSERT(node->IsDockSpace()); // We cannot pass this flag without the DockSpace() api. Testing this because we also setup the hole in host_window->ParentNode
- ImRect central_hole(central_node->Pos, central_node->Pos + central_node->Size);
- central_hole.Expand(ImVec2(-WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS, -WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS));
- if (central_node_hole && !central_hole.IsInverted())
- {
- SetWindowHitTestHole(host_window, central_hole.Min, central_hole.Max - central_hole.Min);
- SetWindowHitTestHole(host_window->ParentWindow, central_hole.Min, central_hole.Max - central_hole.Min);
- }
- }
+ImVec2 ImGui::GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor, float fast_factor)
+{
+ ImVec2 delta(0.0f, 0.0f);
+ if (dir_sources & ImGuiNavDirSourceFlags_Keyboard)
+ delta += ImVec2(GetNavInputAmount(ImGuiNavInput_KeyRight_, mode) - GetNavInputAmount(ImGuiNavInput_KeyLeft_, mode), GetNavInputAmount(ImGuiNavInput_KeyDown_, mode) - GetNavInputAmount(ImGuiNavInput_KeyUp_, mode));
+ if (dir_sources & ImGuiNavDirSourceFlags_PadDPad)
+ delta += ImVec2(GetNavInputAmount(ImGuiNavInput_DpadRight, mode) - GetNavInputAmount(ImGuiNavInput_DpadLeft, mode), GetNavInputAmount(ImGuiNavInput_DpadDown, mode) - GetNavInputAmount(ImGuiNavInput_DpadUp, mode));
+ if (dir_sources & ImGuiNavDirSourceFlags_PadLStick)
+ delta += ImVec2(GetNavInputAmount(ImGuiNavInput_LStickRight, mode) - GetNavInputAmount(ImGuiNavInput_LStickLeft, mode), GetNavInputAmount(ImGuiNavInput_LStickDown, mode) - GetNavInputAmount(ImGuiNavInput_LStickUp, mode));
+ if (slow_factor != 0.0f && IsNavInputDown(ImGuiNavInput_TweakSlow))
+ delta *= slow_factor;
+ if (fast_factor != 0.0f && IsNavInputDown(ImGuiNavInput_TweakFast))
+ delta *= fast_factor;
+ return delta;
+}
- // Update position/size, process and draw resizing splitters
- if (node->IsRootNode() && host_window)
- {
- DockNodeTreeUpdatePosSize(node, host_window->Pos, host_window->Size);
- DockNodeTreeUpdateSplitter(node);
- }
+static void ImGui::NavUpdate()
+{
+ ImGuiContext& g = *GImGui;
+ g.IO.WantSetMousePos = false;
+#if 0
+ if (g.NavScoringCount > 0) IMGUI_DEBUG_LOG("NavScoringCount %d for '%s' layer %d (Init:%d, Move:%d)\n", g.FrameCount, g.NavScoringCount, g.NavWindow ? g.NavWindow->Name : "NULL", g.NavLayer, g.NavInitRequest || g.NavInitResultId != 0, g.NavMoveRequest);
+#endif
- // Draw empty node background (currently can only be the Central Node)
- if (host_window && node->IsEmpty() && node->IsVisible && !(node_flags & ImGuiDockNodeFlags_PassthruCentralNode))
- host_window->DrawList->AddRectFilled(node->Pos, node->Pos + node->Size, GetColorU32(ImGuiCol_DockingEmptyBg));
+ // Set input source as Gamepad when buttons are pressed (as some features differs when used with Gamepad vs Keyboard)
+ // (do it before we map Keyboard input!)
+ bool nav_keyboard_active = (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
+ bool nav_gamepad_active = (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (g.IO.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
+ if (nav_gamepad_active)
+ if (g.IO.NavInputs[ImGuiNavInput_Activate] > 0.0f || g.IO.NavInputs[ImGuiNavInput_Input] > 0.0f || g.IO.NavInputs[ImGuiNavInput_Cancel] > 0.0f || g.IO.NavInputs[ImGuiNavInput_Menu] > 0.0f)
+ g.NavInputSource = ImGuiInputSource_NavGamepad;
- // Draw whole dockspace background if ImGuiDockNodeFlags_PassthruCentralNode if set.
- if (render_dockspace_bg && node->IsVisible)
+ // Update Keyboard->Nav inputs mapping
+ if (nav_keyboard_active)
{
- host_window->DrawList->ChannelsSetCurrent(0);
- if (central_node_hole)
- RenderRectFilledWithHole(host_window->DrawList, node->Rect(), central_node->Rect(), GetColorU32(ImGuiCol_WindowBg), 0.0f);
- else
- host_window->DrawList->AddRectFilled(node->Pos, node->Pos + node->Size, GetColorU32(ImGuiCol_WindowBg), 0.0f);
- host_window->DrawList->ChannelsMerge();
+ #define NAV_MAP_KEY(_KEY, _NAV_INPUT) do { if (IsKeyDown(g.IO.KeyMap[_KEY])) { g.IO.NavInputs[_NAV_INPUT] = 1.0f; g.NavInputSource = ImGuiInputSource_NavKeyboard; } } while (0)
+ NAV_MAP_KEY(ImGuiKey_Space, ImGuiNavInput_Activate );
+ NAV_MAP_KEY(ImGuiKey_Enter, ImGuiNavInput_Input );
+ NAV_MAP_KEY(ImGuiKey_Escape, ImGuiNavInput_Cancel );
+ NAV_MAP_KEY(ImGuiKey_LeftArrow, ImGuiNavInput_KeyLeft_ );
+ NAV_MAP_KEY(ImGuiKey_RightArrow,ImGuiNavInput_KeyRight_);
+ NAV_MAP_KEY(ImGuiKey_UpArrow, ImGuiNavInput_KeyUp_ );
+ NAV_MAP_KEY(ImGuiKey_DownArrow, ImGuiNavInput_KeyDown_ );
+ if (g.IO.KeyCtrl)
+ g.IO.NavInputs[ImGuiNavInput_TweakSlow] = 1.0f;
+ if (g.IO.KeyShift)
+ g.IO.NavInputs[ImGuiNavInput_TweakFast] = 1.0f;
+ if (g.IO.KeyAlt && !g.IO.KeyCtrl) // AltGR is Alt+Ctrl, also even on keyboards without AltGR we don't want Alt+Ctrl to open menu.
+ g.IO.NavInputs[ImGuiNavInput_KeyMenu_] = 1.0f;
+ #undef NAV_MAP_KEY
}
+ memcpy(g.IO.NavInputsDownDurationPrev, g.IO.NavInputsDownDuration, sizeof(g.IO.NavInputsDownDuration));
+ for (int i = 0; i < IM_ARRAYSIZE(g.IO.NavInputs); i++)
+ g.IO.NavInputsDownDuration[i] = (g.IO.NavInputs[i] > 0.0f) ? (g.IO.NavInputsDownDuration[i] < 0.0f ? 0.0f : g.IO.NavInputsDownDuration[i] + g.IO.DeltaTime) : -1.0f;
- // Draw and populate Tab Bar
- if (host_window && node->Windows.Size > 0)
- {
- DockNodeUpdateTabBar(node, host_window);
- }
- else
+ // Process navigation init request (select first/default focus)
+ // In very rare cases g.NavWindow may be null (e.g. clearing focus after requesting an init request, which does happen when releasing Alt while clicking on void)
+ if (g.NavInitResultId != 0 && (!g.NavDisableHighlight || g.NavInitRequestFromMove) && g.NavWindow)
{
- node->WantCloseAll = false;
- node->WantCloseTabID = 0;
- node->IsFocused = false;
+ // Apply result from previous navigation init request (will typically select the first item, unless SetItemDefaultFocus() has been called)
+ //IMGUI_DEBUG_LOG("[Nav] Apply NavInitRequest result: 0x%08X Layer %d in \"%s\"\n", g.NavInitResultId, g.NavLayer, g.NavWindow->Name);
+ if (g.NavInitRequestFromMove)
+ SetNavIDWithRectRel(g.NavInitResultId, g.NavLayer, 0, g.NavInitResultRectRel);
+ else
+ SetNavID(g.NavInitResultId, g.NavLayer, 0);
+ g.NavWindow->NavRectRel[g.NavLayer] = g.NavInitResultRectRel;
}
- if (node->TabBar && node->TabBar->SelectedTabId)
- node->SelectedTabID = node->TabBar->SelectedTabId;
- else if (node->Windows.Size > 0)
- node->SelectedTabID = node->Windows[0]->ID;
-
- // Draw payload drop target
- if (host_window && node->IsVisible)
- if (node->IsRootNode() && (g.MovingWindow == NULL || g.MovingWindow->RootWindow != host_window))
- BeginAsDockableDragDropTarget(host_window);
+ g.NavInitRequest = false;
+ g.NavInitRequestFromMove = false;
+ g.NavInitResultId = 0;
+ g.NavJustMovedToId = 0;
- // We update this after DockNodeUpdateTabBar()
- node->LastFrameActive = g.FrameCount;
+ // Process navigation move request
+ if (g.NavMoveRequest)
+ NavUpdateMoveResult();
- // Recurse into children
- // FIXME-DOCK FIXME-OPT: Should not need to recurse into children
- if (host_window)
+ // When a forwarded move request failed, we restore the highlight that we disabled during the forward frame
+ if (g.NavMoveRequestForward == ImGuiNavForward_ForwardActive)
{
- if (node->ChildNodes[0])
- DockNodeUpdate(node->ChildNodes[0]);
- if (node->ChildNodes[1])
- DockNodeUpdate(node->ChildNodes[1]);
-
- // Render outer borders last (after the tab bar)
- if (node->IsRootNode())
- RenderWindowOuterBorders(host_window);
+ IM_ASSERT(g.NavMoveRequest);
+ if (g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0)
+ g.NavDisableHighlight = false;
+ g.NavMoveRequestForward = ImGuiNavForward_None;
}
- // End host window
- if (beginned_into_host_window) //-V1020
- End();
-}
-
-// Compare TabItem nodes given the last known DockOrder (will persist in .ini file as hint), used to sort tabs when multiple tabs are added on the same frame.
-static int IMGUI_CDECL TabItemComparerByDockOrder(const void* lhs, const void* rhs)
-{
- ImGuiWindow* a = ((const ImGuiTabItem*)lhs)->Window;
- ImGuiWindow* b = ((const ImGuiTabItem*)rhs)->Window;
- if (int d = ((a->DockOrder == -1) ? INT_MAX : a->DockOrder) - ((b->DockOrder == -1) ? INT_MAX : b->DockOrder))
- return d;
- return (a->BeginOrderWithinContext - b->BeginOrderWithinContext);
-}
-
-static ImGuiID ImGui::DockNodeUpdateWindowMenu(ImGuiDockNode* node, ImGuiTabBar* tab_bar)
-{
- // Try to position the menu so it is more likely to stays within the same viewport
- ImGuiContext& g = *GImGui;
- ImGuiID ret_tab_id = 0;
- if (g.Style.WindowMenuButtonPosition == ImGuiDir_Left)
- SetNextWindowPos(ImVec2(node->Pos.x, node->Pos.y + GetFrameHeight()), ImGuiCond_Always, ImVec2(0.0f, 0.0f));
- else
- SetNextWindowPos(ImVec2(node->Pos.x + node->Size.x, node->Pos.y + GetFrameHeight()), ImGuiCond_Always, ImVec2(1.0f, 0.0f));
- if (BeginPopup("#WindowMenu"))
+ // Apply application mouse position movement, after we had a chance to process move request result.
+ if (g.NavMousePosDirty && g.NavIdIsAlive)
{
- node->IsFocused = true;
- if (tab_bar->Tabs.Size == 1)
- {
- if (MenuItem("Hide tab bar", NULL, node->IsHiddenTabBar()))
- node->WantHiddenTabBarToggle = true;
- }
- else
+ // Set mouse position given our knowledge of the navigated item position from last frame
+ if ((g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) && (g.IO.BackendFlags & ImGuiBackendFlags_HasSetMousePos))
{
- for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
+ if (!g.NavDisableHighlight && g.NavDisableMouseHover && g.NavWindow)
{
- ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
- IM_ASSERT(tab->Window != NULL);
- if (Selectable(tab->Window->Name, tab->ID == tab_bar->SelectedTabId))
- ret_tab_id = tab->ID;
- SameLine();
- Text(" ");
+ g.IO.MousePos = g.IO.MousePosPrev = NavCalcPreferredRefPos();
+ g.IO.WantSetMousePos = true;
}
}
- EndPopup();
+ g.NavMousePosDirty = false;
}
- return ret_tab_id;
-}
+ g.NavIdIsAlive = false;
+ g.NavJustTabbedId = 0;
+ IM_ASSERT(g.NavLayer == 0 || g.NavLayer == 1);
-static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_window)
-{
- ImGuiContext& g = *GImGui;
- ImGuiStyle& style = g.Style;
+ // Store our return window (for returning from Layer 1 to Layer 0) and clear it as soon as we step back in our own Layer 0
+ if (g.NavWindow)
+ NavSaveLastChildNavWindowIntoParent(g.NavWindow);
+ if (g.NavWindow && g.NavWindow->NavLastChildNavWindow != NULL && g.NavLayer == ImGuiNavLayer_Main)
+ g.NavWindow->NavLastChildNavWindow = NULL;
- const bool node_was_active = (node->LastFrameActive + 1 == g.FrameCount);
- const bool closed_all = node->WantCloseAll && node_was_active;
- const ImGuiID closed_one = node->WantCloseTabID && node_was_active;
- node->WantCloseAll = false;
- node->WantCloseTabID = 0;
-
- // Decide if we should use a focused title bar color
- bool is_focused = false;
- ImGuiDockNode* root_node = DockNodeGetRootNode(node);
- if (g.NavWindowingTarget)
- is_focused = (g.NavWindowingTarget->DockNode == node);
- else if (g.NavWindow && g.NavWindow->RootWindowForTitleBarHighlight == host_window->RootWindow && root_node->LastFocusedNodeID == node->ID)
- is_focused = true;
-
- // Hidden tab bar will show a triangle on the upper-left (in Begin)
- if (node->IsHiddenTabBar() || node->IsNoTabBar())
- {
- node->VisibleWindow = (node->Windows.Size > 0) ? node->Windows[0] : NULL;
- node->IsFocused = is_focused;
- if (is_focused)
- node->LastFrameFocused = g.FrameCount;
- if (node->VisibleWindow)
- {
- // Notify root of visible window (used to display title in OS task bar)
- if (is_focused || root_node->VisibleWindow == NULL)
- root_node->VisibleWindow = node->VisibleWindow;
- if (node->TabBar)
- node->TabBar->VisibleTabId = node->VisibleWindow->ID;
- }
- return;
- }
+ // Update CTRL+TAB and Windowing features (hold Square to move/resize/etc.)
+ NavUpdateWindowing();
- // Move ourselves to the Menu layer (so we can be accessed by tapping Alt) + undo SkipItems flag in order to draw over the title bar even if the window is collapsed
- bool backup_skip_item = host_window->SkipItems;
- if (!node->IsDockSpace())
- {
- host_window->SkipItems = false;
- host_window->DC.NavLayerCurrent = ImGuiNavLayer_Menu;
- host_window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Menu);
- }
+ // Set output flags for user application
+ g.IO.NavActive = (nav_keyboard_active || nav_gamepad_active) && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs);
+ g.IO.NavVisible = (g.IO.NavActive && g.NavId != 0 && !g.NavDisableHighlight) || (g.NavWindowingTarget != NULL);
- // Use PushOverrideID() instead of PushID() to use the node id _without_ the host window ID.
- // This is to facilitate computing those ID from the outside, and will affect more or less only the ID of the collapse button, popup and tabs,
- // as docked windows themselves will override the stack with their own root ID.
- PushOverrideID(node->ID);
- ImGuiTabBar* tab_bar = node->TabBar;
- bool tab_bar_is_recreated = (tab_bar == NULL); // Tab bar are automatically destroyed when a node gets hidden
- if (tab_bar == NULL)
+ // Process NavCancel input (to close a popup, get back to parent, clear focus)
+ if (IsNavInputTest(ImGuiNavInput_Cancel, ImGuiInputReadMode_Pressed))
{
- DockNodeAddTabBar(node);
- tab_bar = node->TabBar;
+ if (g.ActiveId != 0)
+ {
+ if (!IsActiveIdUsingNavInput(ImGuiNavInput_Cancel))
+ ClearActiveID();
+ }
+ else if (g.NavWindow && (g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow) && !(g.NavWindow->Flags & ImGuiWindowFlags_Popup) && g.NavWindow->ParentWindow)
+ {
+ // Exit child window
+ ImGuiWindow* child_window = g.NavWindow;
+ ImGuiWindow* parent_window = g.NavWindow->ParentWindow;
+ IM_ASSERT(child_window->ChildId != 0);
+ FocusWindow(parent_window);
+ SetNavID(child_window->ChildId, 0, 0);
+ // Reassigning with same value, we're being explicit here.
+ g.NavIdIsAlive = false; // -V1048
+ if (g.NavDisableMouseHover)
+ g.NavMousePosDirty = true;
+ }
+ else if (g.OpenPopupStack.Size > 0)
+ {
+ // Close open popup/menu
+ if (!(g.OpenPopupStack.back().Window->Flags & ImGuiWindowFlags_Modal))
+ ClosePopupToLevel(g.OpenPopupStack.Size - 1, true);
+ }
+ else if (g.NavLayer != ImGuiNavLayer_Main)
+ {
+ // Leave the "menu" layer
+ NavRestoreLayer(ImGuiNavLayer_Main);
+ }
+ else
+ {
+ // Clear NavLastId for popups but keep it for regular child window so we can leave one and come back where we were
+ if (g.NavWindow && ((g.NavWindow->Flags & ImGuiWindowFlags_Popup) || !(g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow)))
+ g.NavWindow->NavLastIds[0] = 0;
+ g.NavId = g.NavFocusScopeId = 0;
+ }
}
- ImGuiID focus_tab_id = 0;
- node->IsFocused = is_focused;
-
- const ImGuiDockNodeFlags node_flags = node->GetMergedFlags();
- const bool has_window_menu_button = (node_flags & ImGuiDockNodeFlags_NoWindowMenuButton) == 0;
- const bool has_close_button = (node_flags & ImGuiDockNodeFlags_NoCloseButton) == 0;
-
- // In a dock node, the Collapse Button turns into the Window Menu button.
- // FIXME-DOCK FIXME-OPT: Could we recycle popups id accross multiple dock nodes?
- if (has_window_menu_button && IsPopupOpen("#WindowMenu"))
+ // Process manual activation request
+ g.NavActivateId = g.NavActivateDownId = g.NavActivatePressedId = g.NavInputId = 0;
+ if (g.NavId != 0 && !g.NavDisableHighlight && !g.NavWindowingTarget && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs))
{
- if (ImGuiID tab_id = DockNodeUpdateWindowMenu(node, tab_bar))
- focus_tab_id = tab_bar->NextSelectedTabId = tab_id;
- is_focused |= node->IsFocused;
+ bool activate_down = IsNavInputDown(ImGuiNavInput_Activate);
+ bool activate_pressed = activate_down && IsNavInputTest(ImGuiNavInput_Activate, ImGuiInputReadMode_Pressed);
+ if (g.ActiveId == 0 && activate_pressed)
+ g.NavActivateId = g.NavId;
+ if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && activate_down)
+ g.NavActivateDownId = g.NavId;
+ if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && activate_pressed)
+ g.NavActivatePressedId = g.NavId;
+ if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && IsNavInputTest(ImGuiNavInput_Input, ImGuiInputReadMode_Pressed))
+ g.NavInputId = g.NavId;
}
+ if (g.NavWindow && (g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs))
+ g.NavDisableHighlight = true;
+ if (g.NavActivateId != 0)
+ IM_ASSERT(g.NavActivateDownId == g.NavActivateId);
+ g.NavMoveRequest = false;
- // Layout
- ImRect title_bar_rect, tab_bar_rect;
- ImVec2 window_menu_button_pos;
- DockNodeCalcTabBarLayout(node, &title_bar_rect, &tab_bar_rect, &window_menu_button_pos);
-
- // Title bar
- if (is_focused)
- node->LastFrameFocused = g.FrameCount;
- ImU32 title_bar_col = GetColorU32(host_window->Collapsed ? ImGuiCol_TitleBgCollapsed : is_focused ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg);
- host_window->DrawList->AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, host_window->WindowRounding, ImDrawCornerFlags_Top);
+ // Process programmatic activation request
+ if (g.NavNextActivateId != 0)
+ g.NavActivateId = g.NavActivateDownId = g.NavActivatePressedId = g.NavInputId = g.NavNextActivateId;
+ g.NavNextActivateId = 0;
- // Docking/Collapse button
- if (has_window_menu_button)
+ // Initiate directional inputs request
+ if (g.NavMoveRequestForward == ImGuiNavForward_None)
{
- if (CollapseButton(host_window->GetID("#COLLAPSE"), window_menu_button_pos, node))
- OpenPopup("#WindowMenu");
- if (IsItemActive())
- focus_tab_id = tab_bar->SelectedTabId;
+ g.NavMoveDir = ImGuiDir_None;
+ g.NavMoveRequestFlags = ImGuiNavMoveFlags_None;
+ if (g.NavWindow && !g.NavWindowingTarget && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs))
+ {
+ const ImGuiInputReadMode read_mode = ImGuiInputReadMode_Repeat;
+ if (!IsActiveIdUsingNavDir(ImGuiDir_Left) && (IsNavInputTest(ImGuiNavInput_DpadLeft, read_mode) || IsNavInputTest(ImGuiNavInput_KeyLeft_, read_mode))) { g.NavMoveDir = ImGuiDir_Left; }
+ if (!IsActiveIdUsingNavDir(ImGuiDir_Right) && (IsNavInputTest(ImGuiNavInput_DpadRight, read_mode) || IsNavInputTest(ImGuiNavInput_KeyRight_, read_mode))) { g.NavMoveDir = ImGuiDir_Right; }
+ if (!IsActiveIdUsingNavDir(ImGuiDir_Up) && (IsNavInputTest(ImGuiNavInput_DpadUp, read_mode) || IsNavInputTest(ImGuiNavInput_KeyUp_, read_mode))) { g.NavMoveDir = ImGuiDir_Up; }
+ if (!IsActiveIdUsingNavDir(ImGuiDir_Down) && (IsNavInputTest(ImGuiNavInput_DpadDown, read_mode) || IsNavInputTest(ImGuiNavInput_KeyDown_, read_mode))) { g.NavMoveDir = ImGuiDir_Down; }
+ }
+ g.NavMoveClipDir = g.NavMoveDir;
}
-
- // Submit new tabs and apply NavWindow focus back to the tab bar. They will be added as Unsorted and sorted below based on relative DockOrder value.
- const int tabs_count_old = tab_bar->Tabs.Size;
- for (int window_n = 0; window_n < node->Windows.Size; window_n++)
+ else
{
- ImGuiWindow* window = node->Windows[window_n];
- if (g.NavWindow && g.NavWindow->RootWindowDockStop == window)
- tab_bar->SelectedTabId = window->ID;
- if (TabBarFindTabByID(tab_bar, window->ID) == NULL)
- TabBarAddTab(tab_bar, ImGuiTabItemFlags_Unsorted, window);
+ // Forwarding previous request (which has been modified, e.g. wrap around menus rewrite the requests with a starting rectangle at the other side of the window)
+ // (Preserve g.NavMoveRequestFlags, g.NavMoveClipDir which were set by the NavMoveRequestForward() function)
+ IM_ASSERT(g.NavMoveDir != ImGuiDir_None && g.NavMoveClipDir != ImGuiDir_None);
+ IM_ASSERT(g.NavMoveRequestForward == ImGuiNavForward_ForwardQueued);
+ g.NavMoveRequestForward = ImGuiNavForward_ForwardActive;
}
- // If multiple tabs are appearing on the same frame, sort them based on their persistent DockOrder value
- int tabs_unsorted_start = tab_bar->Tabs.Size;
- for (int tab_n = tab_bar->Tabs.Size - 1; tab_n >= 0 && (tab_bar->Tabs[tab_n].Flags & ImGuiTabItemFlags_Unsorted); tab_n--)
+ // Update PageUp/PageDown/Home/End scroll
+ // FIXME-NAV: Consider enabling those keys even without the master ImGuiConfigFlags_NavEnableKeyboard flag?
+ float nav_scoring_rect_offset_y = 0.0f;
+ if (nav_keyboard_active)
+ nav_scoring_rect_offset_y = NavUpdatePageUpPageDown();
+
+ // If we initiate a movement request and have no current NavId, we initiate a InitDefautRequest that will be used as a fallback if the direction fails to find a match
+ if (g.NavMoveDir != ImGuiDir_None)
{
- // FIXME-DOCKING: Consider only clearing the flag after the tab has been alive for a few consecutive frames, allowing late comers to not break sorting?
- tab_bar->Tabs[tab_n].Flags &= ~ImGuiTabItemFlags_Unsorted;
- tabs_unsorted_start = tab_n;
+ g.NavMoveRequest = true;
+ g.NavMoveRequestKeyMods = g.IO.KeyMods;
+ g.NavMoveDirLast = g.NavMoveDir;
}
- if (tab_bar->Tabs.Size > tabs_unsorted_start)
+ if (g.NavMoveRequest && g.NavId == 0)
{
- IMGUI_DEBUG_LOG_DOCKING("In node 0x%08X: %d new appearing tabs:%s\n", node->ID, tab_bar->Tabs.Size - tabs_unsorted_start, (tab_bar->Tabs.Size > tabs_unsorted_start + 1) ? " (will sort)" : "");
- for (int tab_n = tabs_unsorted_start; tab_n < tab_bar->Tabs.Size; tab_n++)
- IMGUI_DEBUG_LOG_DOCKING(" - Tab '%s' Order %d\n", tab_bar->Tabs[tab_n].Window->Name, tab_bar->Tabs[tab_n].Window->DockOrder);
- if (tab_bar->Tabs.Size > tabs_unsorted_start + 1)
- ImQsort(tab_bar->Tabs.Data + tabs_unsorted_start, tab_bar->Tabs.Size - tabs_unsorted_start, sizeof(ImGuiTabItem), TabItemComparerByDockOrder);
+ //IMGUI_DEBUG_LOG("[Nav] NavInitRequest from move, window \"%s\", layer=%d\n", g.NavWindow->Name, g.NavLayer);
+ g.NavInitRequest = g.NavInitRequestFromMove = true;
+ // Reassigning with same value, we're being explicit here.
+ g.NavInitResultId = 0; // -V1048
+ g.NavDisableHighlight = false;
}
+ NavUpdateAnyRequestFlag();
- // Selected newly added tabs, or persistent tab ID if the tab bar was just recreated
- if (tab_bar_is_recreated && TabBarFindTabByID(tab_bar, node->SelectedTabID) != NULL)
- tab_bar->SelectedTabId = tab_bar->NextSelectedTabId = node->SelectedTabID;
- else if (tab_bar->Tabs.Size > tabs_count_old)
- tab_bar->SelectedTabId = tab_bar->NextSelectedTabId = tab_bar->Tabs.back().Window->ID;
-
- // Begin tab bar
- ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_AutoSelectNewTabs; // | ImGuiTabBarFlags_NoTabListScrollingButtons);
- tab_bar_flags |= ImGuiTabBarFlags_SaveSettings | ImGuiTabBarFlags_DockNode;
- if (!host_window->Collapsed && is_focused)
- tab_bar_flags |= ImGuiTabBarFlags_IsFocused;
- BeginTabBarEx(tab_bar, tab_bar_rect, tab_bar_flags, node);
- //host_window->DrawList->AddRect(tab_bar_rect.Min, tab_bar_rect.Max, IM_COL32(255,0,255,255));
-
- // Submit actual tabs
- node->VisibleWindow = NULL;
- for (int window_n = 0; window_n < node->Windows.Size; window_n++)
+ // Scrolling
+ if (g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.NavWindowingTarget)
{
- ImGuiWindow* window = node->Windows[window_n];
- if ((closed_all || closed_one == window->ID) && window->HasCloseButton && !(window->Flags & ImGuiWindowFlags_UnsavedDocument))
- continue;
- if (window->LastFrameActive + 1 >= g.FrameCount || !node_was_active)
+ // *Fallback* manual-scroll with Nav directional keys when window has no navigable item
+ ImGuiWindow* window = g.NavWindow;
+ const float scroll_speed = IM_ROUND(window->CalcFontSize() * 100 * g.IO.DeltaTime); // We need round the scrolling speed because sub-pixel scroll isn't reliably supported.
+ if (window->DC.NavLayerActiveMask == 0x00 && window->DC.NavHasScroll && g.NavMoveRequest)
{
- ImGuiTabItemFlags tab_item_flags = 0;
- if (window->Flags & ImGuiWindowFlags_UnsavedDocument)
- tab_item_flags |= ImGuiTabItemFlags_UnsavedDocument;
- if (tab_bar->Flags & ImGuiTabBarFlags_NoCloseWithMiddleMouseButton)
- tab_item_flags |= ImGuiTabItemFlags_NoCloseWithMiddleMouseButton;
-
- bool tab_open = true;
- TabItemEx(tab_bar, window->Name, window->HasCloseButton ? &tab_open : NULL, tab_item_flags, window);
- if (!tab_open)
- node->WantCloseTabID = window->ID;
- if (tab_bar->VisibleTabId == window->ID)
- node->VisibleWindow = window;
-
- // Store last item data so it can be queried with IsItemXXX functions after the user Begin() call
- window->DockTabItemStatusFlags = host_window->DC.LastItemStatusFlags;
- window->DockTabItemRect = host_window->DC.LastItemRect;
-
- // Update navigation ID on menu layer
- if (g.NavWindow && g.NavWindow->RootWindowDockStop == window && (window->DC.NavLayerActiveMask & (1 << 1)) == 0)
- host_window->NavLastIds[1] = window->ID;
+ if (g.NavMoveDir == ImGuiDir_Left || g.NavMoveDir == ImGuiDir_Right)
+ SetScrollX(window, ImFloor(window->Scroll.x + ((g.NavMoveDir == ImGuiDir_Left) ? -1.0f : +1.0f) * scroll_speed));
+ if (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down)
+ SetScrollY(window, ImFloor(window->Scroll.y + ((g.NavMoveDir == ImGuiDir_Up) ? -1.0f : +1.0f) * scroll_speed));
}
- }
-
- // Notify root of visible window (used to display title in OS task bar)
- if (node->VisibleWindow)
- if (is_focused || root_node->VisibleWindow == NULL)
- root_node->VisibleWindow = node->VisibleWindow;
- // Close button (after VisibleWindow was updated)
- // Note that VisibleWindow may have been overrided by CTRL+Tabbing, so VisibleWindow->ID may be != from tab_bar->SelectedTabId
- if (has_close_button && node->VisibleWindow)
- {
- if (!node->VisibleWindow->HasCloseButton)
+ // *Normal* Manual scroll with NavScrollXXX keys
+ // Next movement request will clamp the NavId reference rectangle to the visible area, so navigation will resume within those bounds.
+ ImVec2 scroll_dir = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down, 1.0f/10.0f, 10.0f);
+ if (scroll_dir.x != 0.0f && window->ScrollbarX)
{
- PushItemFlag(ImGuiItemFlags_Disabled, true);
- PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_Text] * ImVec4(1.0f,1.0f,1.0f,0.5f));
+ SetScrollX(window, ImFloor(window->Scroll.x + scroll_dir.x * scroll_speed));
+ g.NavMoveFromClampedRefRect = true;
}
- const float button_sz = g.FontSize;
- if (CloseButton(host_window->GetID("#CLOSE"), title_bar_rect.GetTR() + ImVec2(-style.FramePadding.x * 2.0f - button_sz, 0.0f)))
- if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_bar->VisibleTabId))
- {
- node->WantCloseTabID = tab->ID;
- TabBarCloseTab(tab_bar, tab);
- }
- //if (IsItemActive())
- // focus_tab_id = tab_bar->SelectedTabId;
- if (!node->VisibleWindow->HasCloseButton)
+ if (scroll_dir.y != 0.0f)
{
- PopStyleColor();
- PopItemFlag();
+ SetScrollY(window, ImFloor(window->Scroll.y + scroll_dir.y * scroll_speed));
+ g.NavMoveFromClampedRefRect = true;
}
}
- // When clicking on the title bar outside of tabs, we still focus the selected tab for that node
- // FIXME: TabItem use AllowItemOverlap so we manually perform a more specific test for now (hovered || held)
- ImGuiID title_bar_id = host_window->GetID("#TITLEBAR");
- if (g.HoveredId == 0 || g.HoveredId == title_bar_id || g.ActiveId == title_bar_id)
+ // Reset search results
+ g.NavMoveResultLocal.Clear();
+ g.NavMoveResultLocalVisibleSet.Clear();
+ g.NavMoveResultOther.Clear();
+
+ // When we have manually scrolled (without using navigation) and NavId becomes out of bounds, we project its bounding box to the visible area to restart navigation within visible items
+ if (g.NavMoveRequest && g.NavMoveFromClampedRefRect && g.NavLayer == ImGuiNavLayer_Main)
{
- bool held;
- ButtonBehavior(title_bar_rect, title_bar_id, NULL, &held);
- if (held)
+ ImGuiWindow* window = g.NavWindow;
+ ImRect window_rect_rel(window->InnerRect.Min - window->Pos - ImVec2(1,1), window->InnerRect.Max - window->Pos + ImVec2(1,1));
+ if (!window_rect_rel.Contains(window->NavRectRel[g.NavLayer]))
{
- if (IsMouseClicked(0))
- focus_tab_id = tab_bar->SelectedTabId;
-
- // Forward moving request to selected window
- if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_bar->SelectedTabId))
- StartMouseDragFromTitleBar(tab->Window, node, false);
+ float pad = window->CalcFontSize() * 0.5f;
+ window_rect_rel.Expand(ImVec2(-ImMin(window_rect_rel.GetWidth(), pad), -ImMin(window_rect_rel.GetHeight(), pad))); // Terrible approximation for the intent of starting navigation from first fully visible item
+ window->NavRectRel[g.NavLayer].ClipWith(window_rect_rel);
+ g.NavId = g.NavFocusScopeId = 0;
}
+ g.NavMoveFromClampedRefRect = false;
}
- // Forward focus from host node to selected window
- //if (is_focused && g.NavWindow == host_window && !g.NavWindowingTarget)
- // focus_tab_id = tab_bar->SelectedTabId;
-
- // When clicked on a tab we requested focus to the docked child
- // This overrides the value set by "forward focus from host node to selected window".
- if (tab_bar->NextSelectedTabId)
- focus_tab_id = tab_bar->NextSelectedTabId;
+ // For scoring we use a single segment on the left side our current item bounding box (not touching the edge to avoid box overlap with zero-spaced items)
+ ImRect nav_rect_rel = (g.NavWindow && !g.NavWindow->NavRectRel[g.NavLayer].IsInverted()) ? g.NavWindow->NavRectRel[g.NavLayer] : ImRect(0,0,0,0);
+ g.NavScoringRect = g.NavWindow ? ImRect(g.NavWindow->Pos + nav_rect_rel.Min, g.NavWindow->Pos + nav_rect_rel.Max) : GetViewportRect();
+ g.NavScoringRect.TranslateY(nav_scoring_rect_offset_y);
+ g.NavScoringRect.Min.x = ImMin(g.NavScoringRect.Min.x + 1.0f, g.NavScoringRect.Max.x);
+ g.NavScoringRect.Max.x = g.NavScoringRect.Min.x;
+ IM_ASSERT(!g.NavScoringRect.IsInverted()); // Ensure if we have a finite, non-inverted bounding box here will allows us to remove extraneous ImFabs() calls in NavScoreItem().
+ //GetForegroundDrawList()->AddRect(g.NavScoringRectScreen.Min, g.NavScoringRectScreen.Max, IM_COL32(255,200,0,255)); // [DEBUG]
+ g.NavScoringCount = 0;
+#if IMGUI_DEBUG_NAV_RECTS
+ if (g.NavWindow)
+ {
+ ImDrawList* draw_list = GetForegroundDrawList(g.NavWindow);
+ if (1) { for (int layer = 0; layer < 2; layer++) draw_list->AddRect(g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Min, g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Max, IM_COL32(255,200,0,255)); } // [DEBUG]
+ if (1) { ImU32 col = (!g.NavWindow->Hidden) ? IM_COL32(255,0,255,255) : IM_COL32(255,0,0,255); ImVec2 p = NavCalcPreferredRefPos(); char buf[32]; ImFormatString(buf, 32, "%d", g.NavLayer); draw_list->AddCircleFilled(p, 3.0f, col); draw_list->AddText(NULL, 13.0f, p + ImVec2(8,-4), col, buf); }
+ }
+#endif
+}
- // Apply navigation focus
- if (focus_tab_id != 0)
- if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, focus_tab_id))
+// Apply result from previous frame navigation directional move request
+static void ImGui::NavUpdateMoveResult()
+{
+ ImGuiContext& g = *GImGui;
+ if (g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0)
+ {
+ // In a situation when there is no results but NavId != 0, re-enable the Navigation highlight (because g.NavId is not considered as a possible result)
+ if (g.NavId != 0)
{
- FocusWindow(tab->Window);
- NavInitWindow(tab->Window, false);
+ g.NavDisableHighlight = false;
+ g.NavDisableMouseHover = true;
}
+ return;
+ }
- EndTabBar();
- PopID();
+ // Select which result to use
+ ImGuiNavMoveResult* result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;
- // Restore SkipItems flag
- if (!node->IsDockSpace())
- {
- host_window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
- host_window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
- host_window->SkipItems = backup_skip_item;
- }
-}
+ // PageUp/PageDown behavior first jumps to the bottom/top mostly visible item, _otherwise_ use the result from the previous/next page.
+ if (g.NavMoveRequestFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet)
+ if (g.NavMoveResultLocalVisibleSet.ID != 0 && g.NavMoveResultLocalVisibleSet.ID != g.NavId)
+ result = &g.NavMoveResultLocalVisibleSet;
-static void ImGui::DockNodeAddTabBar(ImGuiDockNode* node)
-{
- IM_ASSERT(node->TabBar == NULL);
- node->TabBar = IM_NEW(ImGuiTabBar);
-}
+ // Maybe entering a flattened child from the outside? In this case solve the tie using the regular scoring rules.
+ if (result != &g.NavMoveResultOther && g.NavMoveResultOther.ID != 0 && g.NavMoveResultOther.Window->ParentWindow == g.NavWindow)
+ if ((g.NavMoveResultOther.DistBox < result->DistBox) || (g.NavMoveResultOther.DistBox == result->DistBox && g.NavMoveResultOther.DistCenter < result->DistCenter))
+ result = &g.NavMoveResultOther;
+ IM_ASSERT(g.NavWindow && result->Window);
-static void ImGui::DockNodeRemoveTabBar(ImGuiDockNode* node)
-{
- if (node->TabBar == NULL)
- return;
- IM_DELETE(node->TabBar);
- node->TabBar = NULL;
-}
+ // Scroll to keep newly navigated item fully into view.
+ if (g.NavLayer == ImGuiNavLayer_Main)
+ {
+ ImVec2 delta_scroll;
+ if (g.NavMoveRequestFlags & ImGuiNavMoveFlags_ScrollToEdge)
+ {
+ float scroll_target = (g.NavMoveDir == ImGuiDir_Up) ? result->Window->ScrollMax.y : 0.0f;
+ delta_scroll.y = result->Window->Scroll.y - scroll_target;
+ SetScrollY(result->Window, scroll_target);
+ }
+ else
+ {
+ ImRect rect_abs = ImRect(result->RectRel.Min + result->Window->Pos, result->RectRel.Max + result->Window->Pos);
+ delta_scroll = ScrollToBringRectIntoView(result->Window, rect_abs);
+ }
-static bool DockNodeIsDropAllowedOne(ImGuiWindow* payload, ImGuiWindow* host_window)
-{
- if (host_window->DockNodeAsHost && host_window->DockNodeAsHost->IsDockSpace() && payload->BeginOrderWithinContext < host_window->BeginOrderWithinContext)
- return false;
+ // Offset our result position so mouse position can be applied immediately after in NavUpdate()
+ result->RectRel.TranslateX(-delta_scroll.x);
+ result->RectRel.TranslateY(-delta_scroll.y);
+ }
- ImGuiWindowClass* host_class = host_window->DockNodeAsHost ? &host_window->DockNodeAsHost->WindowClass : &host_window->WindowClass;
- ImGuiWindowClass* payload_class = &payload->WindowClass;
- if (host_class->ClassId != payload_class->ClassId)
+ ClearActiveID();
+ g.NavWindow = result->Window;
+ if (g.NavId != result->ID)
{
- if (host_class->ClassId != 0 && host_class->DockingAllowUnclassed && payload_class->ClassId == 0)
- return true;
- if (payload_class->ClassId != 0 && payload_class->DockingAllowUnclassed && host_class->ClassId == 0)
- return true;
- return false;
+ // Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId)
+ g.NavJustMovedToId = result->ID;
+ g.NavJustMovedToFocusScopeId = result->FocusScopeId;
+ g.NavJustMovedToKeyMods = g.NavMoveRequestKeyMods;
}
-
- return true;
+ SetNavIDWithRectRel(result->ID, g.NavLayer, result->FocusScopeId, result->RectRel);
+ g.NavMoveFromClampedRefRect = false;
}
-static bool ImGui::DockNodeIsDropAllowed(ImGuiWindow* host_window, ImGuiWindow* root_payload)
+// Handle PageUp/PageDown/Home/End keys
+static float ImGui::NavUpdatePageUpPageDown()
{
- if (root_payload->DockNodeAsHost && root_payload->DockNodeAsHost->IsSplitNode())
- return true;
+ ImGuiContext& g = *GImGui;
+ if (g.NavMoveDir != ImGuiDir_None || g.NavWindow == NULL)
+ return 0.0f;
+ if ((g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) || g.NavWindowingTarget != NULL || g.NavLayer != ImGuiNavLayer_Main)
+ return 0.0f;
- const int payload_count = root_payload->DockNodeAsHost ? root_payload->DockNodeAsHost->Windows.Size : 1;
- for (int payload_n = 0; payload_n < payload_count; payload_n++)
+ ImGuiWindow* window = g.NavWindow;
+ const bool page_up_held = IsKeyDown(g.IO.KeyMap[ImGuiKey_PageUp]) && !IsActiveIdUsingKey(ImGuiKey_PageUp);
+ const bool page_down_held = IsKeyDown(g.IO.KeyMap[ImGuiKey_PageDown]) && !IsActiveIdUsingKey(ImGuiKey_PageDown);
+ const bool home_pressed = IsKeyPressed(g.IO.KeyMap[ImGuiKey_Home]) && !IsActiveIdUsingKey(ImGuiKey_Home);
+ const bool end_pressed = IsKeyPressed(g.IO.KeyMap[ImGuiKey_End]) && !IsActiveIdUsingKey(ImGuiKey_End);
+ if (page_up_held != page_down_held || home_pressed != end_pressed) // If either (not both) are pressed
{
- ImGuiWindow* payload = root_payload->DockNodeAsHost ? root_payload->DockNodeAsHost->Windows[payload_n] : root_payload;
- if (DockNodeIsDropAllowedOne(payload, host_window))
- return true;
+ if (window->DC.NavLayerActiveMask == 0x00 && window->DC.NavHasScroll)
+ {
+ // Fallback manual-scroll when window has no navigable item
+ if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageUp], true))
+ SetScrollY(window, window->Scroll.y - window->InnerRect.GetHeight());
+ else if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageDown], true))
+ SetScrollY(window, window->Scroll.y + window->InnerRect.GetHeight());
+ else if (home_pressed)
+ SetScrollY(window, 0.0f);
+ else if (end_pressed)
+ SetScrollY(window, window->ScrollMax.y);
+ }
+ else
+ {
+ ImRect& nav_rect_rel = window->NavRectRel[g.NavLayer];
+ const float page_offset_y = ImMax(0.0f, window->InnerRect.GetHeight() - window->CalcFontSize() * 1.0f + nav_rect_rel.GetHeight());
+ float nav_scoring_rect_offset_y = 0.0f;
+ if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageUp], true))
+ {
+ nav_scoring_rect_offset_y = -page_offset_y;
+ g.NavMoveDir = ImGuiDir_Down; // Because our scoring rect is offset up, we request the down direction (so we can always land on the last item)
+ g.NavMoveClipDir = ImGuiDir_Up;
+ g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
+ }
+ else if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageDown], true))
+ {
+ nav_scoring_rect_offset_y = +page_offset_y;
+ g.NavMoveDir = ImGuiDir_Up; // Because our scoring rect is offset down, we request the up direction (so we can always land on the last item)
+ g.NavMoveClipDir = ImGuiDir_Down;
+ g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
+ }
+ else if (home_pressed)
+ {
+ // FIXME-NAV: handling of Home/End is assuming that the top/bottom most item will be visible with Scroll.y == 0/ScrollMax.y
+ // Scrolling will be handled via the ImGuiNavMoveFlags_ScrollToEdge flag, we don't scroll immediately to avoid scrolling happening before nav result.
+ // Preserve current horizontal position if we have any.
+ nav_rect_rel.Min.y = nav_rect_rel.Max.y = -window->Scroll.y;
+ if (nav_rect_rel.IsInverted())
+ nav_rect_rel.Min.x = nav_rect_rel.Max.x = 0.0f;
+ g.NavMoveDir = ImGuiDir_Down;
+ g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_ScrollToEdge;
+ }
+ else if (end_pressed)
+ {
+ nav_rect_rel.Min.y = nav_rect_rel.Max.y = window->ScrollMax.y + window->SizeFull.y - window->Scroll.y;
+ if (nav_rect_rel.IsInverted())
+ nav_rect_rel.Min.x = nav_rect_rel.Max.x = 0.0f;
+ g.NavMoveDir = ImGuiDir_Up;
+ g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_ScrollToEdge;
+ }
+ return nav_scoring_rect_offset_y;
+ }
}
- return false;
+ return 0.0f;
}
-// window menu button == collapse button when not in a dock node.
-// FIXME: This is similar to RenderWindowTitleBarContents, may want to share code.
-static void ImGui::DockNodeCalcTabBarLayout(const ImGuiDockNode* node, ImRect* out_title_rect, ImRect* out_tab_bar_rect, ImVec2* out_window_menu_button_pos)
+static int ImGui::FindWindowFocusIndex(ImGuiWindow* window) // FIXME-OPT O(N)
{
ImGuiContext& g = *GImGui;
- ImRect r = ImRect(node->Pos.x, node->Pos.y, node->Pos.x + node->Size.x, node->Pos.y + g.FontSize + g.Style.FramePadding.y * 2.0f);
- if (out_title_rect) { *out_title_rect = r; }
-
- ImVec2 window_menu_button_pos = r.Min;
- r.Min.x += g.Style.FramePadding.x;
- r.Max.x -= g.Style.FramePadding.x;
- if (node->HasCloseButton)
- {
- r.Max.x -= g.FontSize;// +1.0f; // In DockNodeUpdateTabBar() we currently display a disabled close button even if there is none.
- }
- if (node->HasWindowMenuButton && g.Style.WindowMenuButtonPosition == ImGuiDir_Left)
- {
- r.Min.x += g.FontSize; // + g.Style.ItemInnerSpacing.x; // <-- Adding ItemInnerSpacing makes the title text moves slightly when in a docking tab bar. Instead we adjusted RenderArrowDockMenu()
- }
- else if (node->HasWindowMenuButton && g.Style.WindowMenuButtonPosition == ImGuiDir_Right)
- {
- r.Max.x -= g.FontSize + g.Style.FramePadding.x;
- window_menu_button_pos = ImVec2(r.Max.x, r.Min.y);
- }
- if (out_tab_bar_rect) { *out_tab_bar_rect = r; }
- if (out_window_menu_button_pos) { *out_window_menu_button_pos = window_menu_button_pos; }
+ for (int i = g.WindowsFocusOrder.Size-1; i >= 0; i--)
+ if (g.WindowsFocusOrder[i] == window)
+ return i;
+ return -1;
}
-void ImGui::DockNodeCalcSplitRects(ImVec2& pos_old, ImVec2& size_old, ImVec2& pos_new, ImVec2& size_new, ImGuiDir dir, ImVec2 size_new_desired)
+static ImGuiWindow* FindWindowNavFocusable(int i_start, int i_stop, int dir) // FIXME-OPT O(N)
{
ImGuiContext& g = *GImGui;
- const float dock_spacing = g.Style.ItemInnerSpacing.x;
- const ImGuiAxis axis = (dir == ImGuiDir_Left || dir == ImGuiDir_Right) ? ImGuiAxis_X : ImGuiAxis_Y;
- pos_new[axis ^ 1] = pos_old[axis ^ 1];
- size_new[axis ^ 1] = size_old[axis ^ 1];
+ for (int i = i_start; i >= 0 && i < g.WindowsFocusOrder.Size && i != i_stop; i += dir)
+ if (ImGui::IsWindowNavFocusable(g.WindowsFocusOrder[i]))
+ return g.WindowsFocusOrder[i];
+ return NULL;
+}
- // Distribute size on given axis (with a desired size or equally)
- const float w_avail = size_old[axis] - dock_spacing;
- if (size_new_desired[axis] > 0.0f && size_new_desired[axis] <= w_avail * 0.5f)
- {
- size_new[axis] = size_new_desired[axis];
- size_old[axis] = IM_FLOOR(w_avail - size_new[axis]);
- }
- else
- {
- size_new[axis] = IM_FLOOR(w_avail * 0.5f);
- size_old[axis] = IM_FLOOR(w_avail - size_new[axis]);
- }
+static void NavUpdateWindowingHighlightWindow(int focus_change_dir)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(g.NavWindowingTarget);
+ if (g.NavWindowingTarget->Flags & ImGuiWindowFlags_Modal)
+ return;
- // Position each node
- if (dir == ImGuiDir_Right || dir == ImGuiDir_Down)
- {
- pos_new[axis] = pos_old[axis] + size_old[axis] + dock_spacing;
- }
- else if (dir == ImGuiDir_Left || dir == ImGuiDir_Up)
- {
- pos_new[axis] = pos_old[axis];
- pos_old[axis] = pos_new[axis] + size_new[axis] + dock_spacing;
- }
+ const int i_current = ImGui::FindWindowFocusIndex(g.NavWindowingTarget);
+ ImGuiWindow* window_target = FindWindowNavFocusable(i_current + focus_change_dir, -INT_MAX, focus_change_dir);
+ if (!window_target)
+ window_target = FindWindowNavFocusable((focus_change_dir < 0) ? (g.WindowsFocusOrder.Size - 1) : 0, i_current, focus_change_dir);
+ if (window_target) // Don't reset windowing target if there's a single window in the list
+ g.NavWindowingTarget = g.NavWindowingTargetAnim = window_target;
+ g.NavWindowingToggleLayer = false;
}
-// Retrieve the drop rectangles for a given direction or for the center + perform hit testing.
-bool ImGui::DockNodeCalcDropRectsAndTestMousePos(const ImRect& parent, ImGuiDir dir, ImRect& out_r, bool outer_docking, ImVec2* test_mouse_pos)
+// Windowing management mode
+// Keyboard: CTRL+Tab (change focus/move/resize), Alt (toggle menu layer)
+// Gamepad: Hold Menu/Square (change focus/move/resize), Tap Menu/Square (toggle menu layer)
+static void ImGui::NavUpdateWindowing()
{
ImGuiContext& g = *GImGui;
+ ImGuiWindow* apply_focus_window = NULL;
+ bool apply_toggle_layer = false;
- const float parent_smaller_axis = ImMin(parent.GetWidth(), parent.GetHeight());
- const float hs_for_central_nodes = ImMin(g.FontSize * 1.5f, ImMax(g.FontSize * 0.5f, parent_smaller_axis / 8.0f));
- float hs_w; // Half-size, longer axis
- float hs_h; // Half-size, smaller axis
- ImVec2 off; // Distance from edge or center
- if (outer_docking)
+ ImGuiWindow* modal_window = GetTopMostPopupModal();
+ if (modal_window != NULL)
{
- //hs_w = ImFloor(ImClamp(parent_smaller_axis - hs_for_central_nodes * 4.0f, g.FontSize * 0.5f, g.FontSize * 8.0f));
- //hs_h = ImFloor(hs_w * 0.15f);
- //off = ImVec2(ImFloor(parent.GetWidth() * 0.5f - GetFrameHeightWithSpacing() * 1.4f - hs_h), ImFloor(parent.GetHeight() * 0.5f - GetFrameHeightWithSpacing() * 1.4f - hs_h));
- hs_w = ImFloor(hs_for_central_nodes * 1.50f);
- hs_h = ImFloor(hs_for_central_nodes * 0.80f);
- off = ImVec2(ImFloor(parent.GetWidth() * 0.5f - GetFrameHeightWithSpacing() * 0.0f - hs_h), ImFloor(parent.GetHeight() * 0.5f - GetFrameHeightWithSpacing() * 0.0f - hs_h));
+ g.NavWindowingTarget = NULL;
+ return;
}
- else
+
+ // Fade out
+ if (g.NavWindowingTargetAnim && g.NavWindowingTarget == NULL)
{
- hs_w = ImFloor(hs_for_central_nodes);
- hs_h = ImFloor(hs_for_central_nodes * 0.90f);
- off = ImVec2(ImFloor(hs_w * 2.40f), ImFloor(hs_w * 2.40f));
+ g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha - g.IO.DeltaTime * 10.0f, 0.0f);
+ if (g.DimBgRatio <= 0.0f && g.NavWindowingHighlightAlpha <= 0.0f)
+ g.NavWindowingTargetAnim = NULL;
}
- ImVec2 c = ImFloor(parent.GetCenter());
- if (dir == ImGuiDir_None) { out_r = ImRect(c.x - hs_w, c.y - hs_w, c.x + hs_w, c.y + hs_w); }
- else if (dir == ImGuiDir_Up) { out_r = ImRect(c.x - hs_w, c.y - off.y - hs_h, c.x + hs_w, c.y - off.y + hs_h); }
- else if (dir == ImGuiDir_Down) { out_r = ImRect(c.x - hs_w, c.y + off.y - hs_h, c.x + hs_w, c.y + off.y + hs_h); }
- else if (dir == ImGuiDir_Left) { out_r = ImRect(c.x - off.x - hs_h, c.y - hs_w, c.x - off.x + hs_h, c.y + hs_w); }
- else if (dir == ImGuiDir_Right) { out_r = ImRect(c.x + off.x - hs_h, c.y - hs_w, c.x + off.x + hs_h, c.y + hs_w); }
-
- if (test_mouse_pos == NULL)
- return false;
-
- ImRect hit_r = out_r;
- if (!outer_docking)
- {
- // Custom hit testing for the 5-way selection, designed to reduce flickering when moving diagonally between sides
- hit_r.Expand(ImFloor(hs_w * 0.30f));
- ImVec2 mouse_delta = (*test_mouse_pos - c);
- float mouse_delta_len2 = ImLengthSqr(mouse_delta);
- float r_threshold_center = hs_w * 1.4f;
- float r_threshold_sides = hs_w * (1.4f + 1.2f);
- if (mouse_delta_len2 < r_threshold_center * r_threshold_center)
- return (dir == ImGuiDir_None);
- if (mouse_delta_len2 < r_threshold_sides * r_threshold_sides)
- return (dir == ImGetDirQuadrantFromDelta(mouse_delta.x, mouse_delta.y));
- }
- return hit_r.Contains(*test_mouse_pos);
-}
-
-// host_node may be NULL if the window doesn't have a DockNode already.
-static void ImGui::DockNodePreviewDockCalc(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* root_payload, ImGuiDockPreviewData* data, bool is_explicit_target, bool is_outer_docking)
-{
- ImGuiContext& g = *GImGui;
-
- // There is an edge case when docking into a dockspace which only has inactive nodes.
- // In this case DockNodeTreeFindNodeByPos() will have selected a leaf node which is inactive.
- // Because the inactive leaf node doesn't have proper pos/size yet, we'll use the root node as reference.
- ImGuiDockNode* ref_node_for_rect = (host_node && !host_node->IsVisible) ? DockNodeGetRootNode(host_node) : host_node;
- if (ref_node_for_rect)
- IM_ASSERT(ref_node_for_rect->IsVisible);
-
- // Build a tentative future node (reuse same structure because it is practical)
- data->FutureNode.HasCloseButton = (host_node ? host_node->HasCloseButton : host_window->HasCloseButton) || (root_payload->HasCloseButton);
- data->FutureNode.HasWindowMenuButton = host_node ? true : ((host_window->Flags & ImGuiWindowFlags_NoCollapse) == 0);
- data->FutureNode.Pos = host_node ? ref_node_for_rect->Pos : host_window->Pos;
- data->FutureNode.Size = host_node ? ref_node_for_rect->Size : host_window->Size;
-
- // Figure out here we are allowed to dock
- ImGuiDockNodeFlags host_node_flags = host_node ? host_node->GetMergedFlags() : 0;
- const bool src_is_visibly_splitted = root_payload->DockNodeAsHost && root_payload->DockNodeAsHost->IsSplitNode() && (root_payload->DockNodeAsHost->OnlyNodeWithWindows == NULL);
- data->IsCenterAvailable = !is_outer_docking;
- if (src_is_visibly_splitted && (!host_node || !host_node->IsEmpty()))
- data->IsCenterAvailable = false;
- if (host_node && (host_node_flags & ImGuiDockNodeFlags_NoDocking))
- data->IsCenterAvailable = false;
- if (host_node && (host_node_flags & ImGuiDockNodeFlags_NoDockingInCentralNode) && host_node->IsCentralNode())
- data->IsCenterAvailable = false;
-
- data->IsSidesAvailable = true;
- if ((host_node && (host_node_flags & ImGuiDockNodeFlags_NoSplit)) || g.IO.ConfigDockingNoSplit)
- data->IsSidesAvailable = false;
- if (!is_outer_docking && host_node && host_node->ParentNode == NULL && host_node->IsCentralNode())
- data->IsSidesAvailable = false;
-
- // Calculate drop shapes geometry for allowed splitting directions
- IM_ASSERT(ImGuiDir_None == -1);
- data->SplitNode = host_node;
- data->SplitDir = ImGuiDir_None;
- data->IsSplitDirExplicit = false;
- if (!host_window->Collapsed)
- for (int dir = ImGuiDir_None; dir < ImGuiDir_COUNT; dir++)
- {
- if (dir == ImGuiDir_None && !data->IsCenterAvailable)
- continue;
- if (dir != ImGuiDir_None && !data->IsSidesAvailable)
- continue;
- if (DockNodeCalcDropRectsAndTestMousePos(data->FutureNode.Rect(), (ImGuiDir)dir, data->DropRectsDraw[dir+1], is_outer_docking, &g.IO.MousePos))
- {
- data->SplitDir = (ImGuiDir)dir;
- data->IsSplitDirExplicit = true;
- }
+ // Start CTRL-TAB or Square+L/R window selection
+ bool start_windowing_with_gamepad = !g.NavWindowingTarget && IsNavInputTest(ImGuiNavInput_Menu, ImGuiInputReadMode_Pressed);
+ bool start_windowing_with_keyboard = !g.NavWindowingTarget && g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab) && (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard);
+ if (start_windowing_with_gamepad || start_windowing_with_keyboard)
+ if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1))
+ {
+ g.NavWindowingTarget = g.NavWindowingTargetAnim = window->RootWindow; // FIXME-DOCK: Will need to use RootWindowDockStop
+ g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f;
+ g.NavWindowingToggleLayer = start_windowing_with_keyboard ? false : true;
+ g.NavInputSource = start_windowing_with_keyboard ? ImGuiInputSource_NavKeyboard : ImGuiInputSource_NavGamepad;
}
- // When docking without holding Shift, we only allow and preview docking when hovering over a drop rect or over the title bar
- data->IsDropAllowed = (data->SplitDir != ImGuiDir_None) || (data->IsCenterAvailable);
- if (!is_explicit_target && !data->IsSplitDirExplicit && !g.IO.ConfigDockingWithShift)
- data->IsDropAllowed = false;
-
- // Calculate split area
- data->SplitRatio = 0.0f;
- if (data->SplitDir != ImGuiDir_None)
+ // Gamepad update
+ g.NavWindowingTimer += g.IO.DeltaTime;
+ if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_NavGamepad)
{
- ImGuiDir split_dir = data->SplitDir;
- ImGuiAxis split_axis = (split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Right) ? ImGuiAxis_X : ImGuiAxis_Y;
- ImVec2 pos_new, pos_old = data->FutureNode.Pos;
- ImVec2 size_new, size_old = data->FutureNode.Size;
- DockNodeCalcSplitRects(pos_old, size_old, pos_new, size_new, split_dir, root_payload->Size);
-
- // Calculate split ratio so we can pass it down the docking request
- float split_ratio = ImSaturate(size_new[split_axis] / data->FutureNode.Size[split_axis]);
- data->FutureNode.Pos = pos_new;
- data->FutureNode.Size = size_new;
- data->SplitRatio = (split_dir == ImGuiDir_Right || split_dir == ImGuiDir_Down) ? (1.0f - split_ratio) : (split_ratio);
- }
-}
-
-static void ImGui::DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* root_payload, const ImGuiDockPreviewData* data)
-{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(g.CurrentWindow == host_window); // Because we rely on font size to calculate tab sizes
-
- // With this option, we only display the preview on the target viewport, and the payload viewport is made transparent.
- // To compensate for the single layer obstructed by the payload, we'll increase the alpha of the preview nodes.
- const bool is_transparent_payload = g.IO.ConfigDockingTransparentPayload;
+ // Highlight only appears after a brief time holding the button, so that a fast tap on PadMenu (to toggle NavLayer) doesn't add visual noise
+ g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f));
- // In case the two windows involved are on different viewports, we will draw the overlay on each of them.
- int overlay_draw_lists_count = 0;
- ImDrawList* overlay_draw_lists[2];
- overlay_draw_lists[overlay_draw_lists_count++] = GetForegroundDrawList(host_window->Viewport);
- if (host_window->Viewport != root_payload->Viewport && !is_transparent_payload)
- overlay_draw_lists[overlay_draw_lists_count++] = GetForegroundDrawList(root_payload->Viewport);
+ // Select window to focus
+ const int focus_change_dir = (int)IsNavInputTest(ImGuiNavInput_FocusPrev, ImGuiInputReadMode_RepeatSlow) - (int)IsNavInputTest(ImGuiNavInput_FocusNext, ImGuiInputReadMode_RepeatSlow);
+ if (focus_change_dir != 0)
+ {
+ NavUpdateWindowingHighlightWindow(focus_change_dir);
+ g.NavWindowingHighlightAlpha = 1.0f;
+ }
- // Draw main preview rectangle
- const ImU32 overlay_col_tabs = GetColorU32(ImGuiCol_TabActive);
- const ImU32 overlay_col_main = GetColorU32(ImGuiCol_DockingPreview, is_transparent_payload ? 0.60f : 0.40f);
- const ImU32 overlay_col_drop = GetColorU32(ImGuiCol_DockingPreview, is_transparent_payload ? 0.90f : 0.70f);
- const ImU32 overlay_col_drop_hovered = GetColorU32(ImGuiCol_DockingPreview, is_transparent_payload ? 1.20f : 1.00f);
- const ImU32 overlay_col_lines = GetColorU32(ImGuiCol_NavWindowingHighlight, is_transparent_payload ? 0.80f : 0.60f);
+ // Single press toggles NavLayer, long press with L/R apply actual focus on release (until then the window was merely rendered top-most)
+ if (!IsNavInputDown(ImGuiNavInput_Menu))
+ {
+ g.NavWindowingToggleLayer &= (g.NavWindowingHighlightAlpha < 1.0f); // Once button was held long enough we don't consider it a tap-to-toggle-layer press anymore.
+ if (g.NavWindowingToggleLayer && g.NavWindow)
+ apply_toggle_layer = true;
+ else if (!g.NavWindowingToggleLayer)
+ apply_focus_window = g.NavWindowingTarget;
+ g.NavWindowingTarget = NULL;
+ }
+ }
- // Display area preview
- const bool can_preview_tabs = (root_payload->DockNodeAsHost == NULL || root_payload->DockNodeAsHost->Windows.Size > 0);
- if (data->IsDropAllowed)
+ // Keyboard: Focus
+ if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_NavKeyboard)
{
- ImRect overlay_rect = data->FutureNode.Rect();
- if (data->SplitDir == ImGuiDir_None && can_preview_tabs)
- overlay_rect.Min.y += GetFrameHeight();
- if (data->SplitDir != ImGuiDir_None || data->IsCenterAvailable)
- for (int overlay_n = 0; overlay_n < overlay_draw_lists_count; overlay_n++)
- overlay_draw_lists[overlay_n]->AddRectFilled(overlay_rect.Min, overlay_rect.Max, overlay_col_main, host_window->WindowRounding);
+ // Visuals only appears after a brief time after pressing TAB the first time, so that a fast CTRL+TAB doesn't add visual noise
+ g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f)); // 1.0f
+ if (IsKeyPressedMap(ImGuiKey_Tab, true))
+ NavUpdateWindowingHighlightWindow(g.IO.KeyShift ? +1 : -1);
+ if (!g.IO.KeyCtrl)
+ apply_focus_window = g.NavWindowingTarget;
}
- // Display tab shape/label preview unless we are splitting node (it generally makes the situation harder to read)
- if (data->IsDropAllowed && can_preview_tabs && data->SplitDir == ImGuiDir_None && data->IsCenterAvailable)
+ // Keyboard: Press and Release ALT to toggle menu layer
+ // FIXME: We lack an explicit IO variable for "is the imgui window focused", so compare mouse validity to detect the common case of back-end clearing releases all keys on ALT-TAB
+ if (IsNavInputTest(ImGuiNavInput_KeyMenu_, ImGuiInputReadMode_Pressed))
+ g.NavWindowingToggleLayer = true;
+ if ((g.ActiveId == 0 || g.ActiveIdAllowOverlap) && g.NavWindowingToggleLayer && IsNavInputTest(ImGuiNavInput_KeyMenu_, ImGuiInputReadMode_Released))
+ if (IsMousePosValid(&g.IO.MousePos) == IsMousePosValid(&g.IO.MousePosPrev))
+ apply_toggle_layer = true;
+
+ // Move window
+ if (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoMove))
{
- // Compute target tab bar geometry so we can locate our preview tabs
- ImRect tab_bar_rect;
- DockNodeCalcTabBarLayout(&data->FutureNode, NULL, &tab_bar_rect, NULL);
- ImVec2 tab_pos = tab_bar_rect.Min;
- if (host_node && host_node->TabBar)
- {
- if (!host_node->IsHiddenTabBar() && !host_node->IsNoTabBar())
- tab_pos.x += host_node->TabBar->OffsetMax + g.Style.ItemInnerSpacing.x; // We don't use OffsetNewTab because when using non-persistent-order tab bar it is incremented with each Tab submission.
- else
- tab_pos.x += g.Style.ItemInnerSpacing.x + TabItemCalcSize(host_node->Windows[0]->Name, host_node->Windows[0]->HasCloseButton).x;
- }
- else if (!(host_window->Flags & ImGuiWindowFlags_DockNodeHost))
+ ImVec2 move_delta;
+ if (g.NavInputSource == ImGuiInputSource_NavKeyboard && !g.IO.KeyShift)
+ move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard, ImGuiInputReadMode_Down);
+ if (g.NavInputSource == ImGuiInputSource_NavGamepad)
+ move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down);
+ if (move_delta.x != 0.0f || move_delta.y != 0.0f)
{
- tab_pos.x += g.Style.ItemInnerSpacing.x + TabItemCalcSize(host_window->Name, host_window->HasCloseButton).x; // Account for slight offset which will be added when changing from title bar to tab bar
+ const float NAV_MOVE_SPEED = 800.0f;
+ const float move_speed = ImFloor(NAV_MOVE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y)); // FIXME: Doesn't code variable framerate very well
+ SetWindowPos(g.NavWindowingTarget->RootWindow, g.NavWindowingTarget->RootWindow->Pos + move_delta * move_speed, ImGuiCond_Always);
+ g.NavDisableMouseHover = true;
+ MarkIniSettingsDirty(g.NavWindowingTarget);
}
+ }
- // Draw tab shape/label preview (payload may be a loose window or a host window carrying multiple tabbed windows)
- if (root_payload->DockNodeAsHost)
- IM_ASSERT(root_payload->DockNodeAsHost->Windows.Size == root_payload->DockNodeAsHost->TabBar->Tabs.Size);
- const int payload_count = root_payload->DockNodeAsHost ? root_payload->DockNodeAsHost->TabBar->Tabs.Size : 1;
- for (int payload_n = 0; payload_n < payload_count; payload_n++)
- {
- // Calculate the tab bounding box for each payload window
- ImGuiWindow* payload = root_payload->DockNodeAsHost ? root_payload->DockNodeAsHost->TabBar->Tabs[payload_n].Window : root_payload;
- if (!DockNodeIsDropAllowedOne(payload, host_window))
- continue;
+ // Apply final focus
+ if (apply_focus_window && (g.NavWindow == NULL || apply_focus_window != g.NavWindow->RootWindow))
+ {
+ ClearActiveID();
+ g.NavDisableHighlight = false;
+ g.NavDisableMouseHover = true;
+ apply_focus_window = NavRestoreLastChildNavWindow(apply_focus_window);
+ ClosePopupsOverWindow(apply_focus_window, false);
+ FocusWindow(apply_focus_window);
+ if (apply_focus_window->NavLastIds[0] == 0)
+ NavInitWindow(apply_focus_window, false);
- ImVec2 tab_size = TabItemCalcSize(payload->Name, payload->HasCloseButton);
- ImRect tab_bb(tab_pos.x, tab_pos.y, tab_pos.x + tab_size.x, tab_pos.y + tab_size.y);
- tab_pos.x += tab_size.x + g.Style.ItemInnerSpacing.x;
- for (int overlay_n = 0; overlay_n < overlay_draw_lists_count; overlay_n++)
- {
- ImGuiTabItemFlags tab_flags = ImGuiTabItemFlags_Preview | ((payload->Flags & ImGuiWindowFlags_UnsavedDocument) ? ImGuiTabItemFlags_UnsavedDocument : 0);
- if (!tab_bar_rect.Contains(tab_bb))
- overlay_draw_lists[overlay_n]->PushClipRect(tab_bar_rect.Min, tab_bar_rect.Max);
- TabItemBackground(overlay_draw_lists[overlay_n], tab_bb, tab_flags, overlay_col_tabs);
- TabItemLabelAndCloseButton(overlay_draw_lists[overlay_n], tab_bb, tab_flags, g.Style.FramePadding, payload->Name, 0, 0);
- if (!tab_bar_rect.Contains(tab_bb))
- overlay_draw_lists[overlay_n]->PopClipRect();
- }
- }
+ // If the window only has a menu layer, select it directly
+ if (apply_focus_window->DC.NavLayerActiveMask == (1 << ImGuiNavLayer_Menu))
+ g.NavLayer = ImGuiNavLayer_Menu;
}
+ if (apply_focus_window)
+ g.NavWindowingTarget = NULL;
- // Display drop boxes
- const float overlay_rounding = ImMax(3.0f, g.Style.FrameRounding);
- for (int dir = ImGuiDir_None; dir < ImGuiDir_COUNT; dir++)
+ // Apply menu/layer toggle
+ if (apply_toggle_layer && g.NavWindow)
{
- if (!data->DropRectsDraw[dir + 1].IsInverted())
+ // Move to parent menu if necessary
+ ImGuiWindow* new_nav_window = g.NavWindow;
+ while (new_nav_window->ParentWindow
+ && (new_nav_window->DC.NavLayerActiveMask & (1 << ImGuiNavLayer_Menu)) == 0
+ && (new_nav_window->Flags & ImGuiWindowFlags_ChildWindow) != 0
+ && (new_nav_window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0)
+ new_nav_window = new_nav_window->ParentWindow;
+ if (new_nav_window != g.NavWindow)
{
- ImRect draw_r = data->DropRectsDraw[dir + 1];
- ImRect draw_r_in = draw_r;
- draw_r_in.Expand(-2.0f);
- ImU32 overlay_col = (data->SplitDir == (ImGuiDir)dir && data->IsSplitDirExplicit) ? overlay_col_drop_hovered : overlay_col_drop;
- for (int overlay_n = 0; overlay_n < overlay_draw_lists_count; overlay_n++)
- {
- ImVec2 center = ImFloor(draw_r_in.GetCenter());
- overlay_draw_lists[overlay_n]->AddRectFilled(draw_r.Min, draw_r.Max, overlay_col, overlay_rounding);
- overlay_draw_lists[overlay_n]->AddRect(draw_r_in.Min, draw_r_in.Max, overlay_col_lines, overlay_rounding);
- if (dir == ImGuiDir_Left || dir == ImGuiDir_Right)
- overlay_draw_lists[overlay_n]->AddLine(ImVec2(center.x, draw_r_in.Min.y), ImVec2(center.x, draw_r_in.Max.y), overlay_col_lines);
- if (dir == ImGuiDir_Up || dir == ImGuiDir_Down)
- overlay_draw_lists[overlay_n]->AddLine(ImVec2(draw_r_in.Min.x, center.y), ImVec2(draw_r_in.Max.x, center.y), overlay_col_lines);
- }
+ ImGuiWindow* old_nav_window = g.NavWindow;
+ FocusWindow(new_nav_window);
+ new_nav_window->NavLastChildNavWindow = old_nav_window;
}
+ g.NavDisableHighlight = false;
+ g.NavDisableMouseHover = true;
- // Stop after ImGuiDir_None
- if ((host_node && (host_node->GetMergedFlags() & ImGuiDockNodeFlags_NoSplit)) || g.IO.ConfigDockingNoSplit)
- return;
+ // When entering a regular menu bar with the Alt key, we always reinitialize the navigation ID.
+ const ImGuiNavLayer new_nav_layer = (g.NavWindow->DC.NavLayerActiveMask & (1 << ImGuiNavLayer_Menu)) ? (ImGuiNavLayer)((int)g.NavLayer ^ 1) : ImGuiNavLayer_Main;
+ NavRestoreLayer(new_nav_layer);
}
}
-//-----------------------------------------------------------------------------
-// Docking: ImGuiDockNode Tree manipulation functions
-//-----------------------------------------------------------------------------
-// - DockNodeTreeSplit()
-// - DockNodeTreeMerge()
-// - DockNodeTreeUpdatePosSize()
-// - DockNodeTreeUpdateSplitterFindTouchingNode()
-// - DockNodeTreeUpdateSplitter()
-// - DockNodeTreeFindFallbackLeafNode()
-// - DockNodeTreeFindNodeByPos()
-//-----------------------------------------------------------------------------
+// Window has already passed the IsWindowNavFocusable()
+static const char* GetFallbackWindowNameForWindowingList(ImGuiWindow* window)
+{
+ if (window->Flags & ImGuiWindowFlags_Popup)
+ return "(Popup)";
+ if ((window->Flags & ImGuiWindowFlags_MenuBar) && strcmp(window->Name, "##MainMenuBar") == 0)
+ return "(Main menu bar)";
+ return "(Untitled)";
+}
-void ImGui::DockNodeTreeSplit(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiAxis split_axis, int split_inheritor_child_idx, float split_ratio, ImGuiDockNode* new_node)
+// Overlay displayed when using CTRL+TAB. Called by EndFrame().
+void ImGui::NavUpdateWindowingOverlay()
{
ImGuiContext& g = *GImGui;
- IM_ASSERT(split_axis != ImGuiAxis_None);
-
- ImGuiDockNode* child_0 = (new_node && split_inheritor_child_idx != 0) ? new_node : DockContextAddNode(ctx, 0);
- child_0->ParentNode = parent_node;
-
- ImGuiDockNode* child_1 = (new_node && split_inheritor_child_idx != 1) ? new_node : DockContextAddNode(ctx, 0);
- child_1->ParentNode = parent_node;
-
- ImGuiDockNode* child_inheritor = (split_inheritor_child_idx == 0) ? child_0 : child_1;
- DockNodeMoveChildNodes(child_inheritor, parent_node);
- parent_node->ChildNodes[0] = child_0;
- parent_node->ChildNodes[1] = child_1;
- parent_node->ChildNodes[split_inheritor_child_idx]->VisibleWindow = parent_node->VisibleWindow;
- parent_node->SplitAxis = split_axis;
- parent_node->VisibleWindow = NULL;
- parent_node->AuthorityForPos = parent_node->AuthorityForSize = ImGuiDataAuthority_DockNode;
-
- float size_avail = (parent_node->Size[split_axis] - IMGUI_DOCK_SPLITTER_SIZE);
- size_avail = ImMax(size_avail, g.Style.WindowMinSize[split_axis] * 2.0f);
- IM_ASSERT(size_avail > 0.0f); // If you created a node manually with DockBuilderAddNode(), you need to also call DockBuilderSetNodeSize() before splitting.
- child_0->SizeRef = child_1->SizeRef = parent_node->Size;
- child_0->SizeRef[split_axis] = ImFloor(size_avail * split_ratio);
- child_1->SizeRef[split_axis] = ImFloor(size_avail - child_0->SizeRef[split_axis]);
-
- DockNodeMoveWindows(parent_node->ChildNodes[split_inheritor_child_idx], parent_node);
- DockNodeTreeUpdatePosSize(parent_node, parent_node->Pos, parent_node->Size);
+ IM_ASSERT(g.NavWindowingTarget != NULL);
- // Flags transfer (e.g. this is where we transfer the ImGuiDockNodeFlags_CentralNode property)
- child_0->SharedFlags = parent_node->SharedFlags & ImGuiDockNodeFlags_SharedFlagsInheritMask_;
- child_1->SharedFlags = parent_node->SharedFlags & ImGuiDockNodeFlags_SharedFlagsInheritMask_;
- child_inheritor->LocalFlags = parent_node->LocalFlags & ImGuiDockNodeFlags_LocalFlagsTransferMask_;
- parent_node->LocalFlags &= ~ImGuiDockNodeFlags_LocalFlagsTransferMask_;
- if (child_inheritor->IsCentralNode())
- DockNodeGetRootNode(parent_node)->CentralNode = child_inheritor;
-}
+ if (g.NavWindowingTimer < NAV_WINDOWING_LIST_APPEAR_DELAY)
+ return;
-void ImGui::DockNodeTreeMerge(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiDockNode* merge_lead_child)
-{
- // When called from DockContextProcessUndockNode() it is possible that one of the child is NULL.
- ImGuiDockNode* child_0 = parent_node->ChildNodes[0];
- ImGuiDockNode* child_1 = parent_node->ChildNodes[1];
- IM_ASSERT(child_0 || child_1);
- IM_ASSERT(merge_lead_child == child_0 || merge_lead_child == child_1);
- if ((child_0 && child_0->Windows.Size > 0) || (child_1 && child_1->Windows.Size > 0))
+ if (g.NavWindowingList == NULL)
+ g.NavWindowingList = FindWindowByName("###NavWindowingList");
+ SetNextWindowSizeConstraints(ImVec2(g.IO.DisplaySize.x * 0.20f, g.IO.DisplaySize.y * 0.20f), ImVec2(FLT_MAX, FLT_MAX));
+ SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
+ PushStyleVar(ImGuiStyleVar_WindowPadding, g.Style.WindowPadding * 2.0f);
+ Begin("###NavWindowingList", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings);
+ for (int n = g.WindowsFocusOrder.Size - 1; n >= 0; n--)
{
- IM_ASSERT(parent_node->TabBar == NULL);
- IM_ASSERT(parent_node->Windows.Size == 0);
+ ImGuiWindow* window = g.WindowsFocusOrder[n];
+ if (!IsWindowNavFocusable(window))
+ continue;
+ const char* label = window->Name;
+ if (label == FindRenderedTextEnd(label))
+ label = GetFallbackWindowNameForWindowingList(window);
+ Selectable(label, g.NavWindowingTarget == window);
}
- IMGUI_DEBUG_LOG_DOCKING("DockNodeTreeMerge 0x%08X & 0x%08X back into parent 0x%08X\n", child_0 ? child_0->ID : 0, child_1 ? child_1->ID : 0, parent_node->ID);
+ End();
+ PopStyleVar();
+}
- ImVec2 backup_last_explicit_size = parent_node->SizeRef;
- DockNodeMoveChildNodes(parent_node, merge_lead_child);
- if (child_0)
- {
- DockNodeMoveWindows(parent_node, child_0); // Generally only 1 of the 2 child node will have windows
- DockSettingsRenameNodeReferences(child_0->ID, parent_node->ID);
- }
- if (child_1)
- {
- DockNodeMoveWindows(parent_node, child_1);
- DockSettingsRenameNodeReferences(child_1->ID, parent_node->ID);
- }
- DockNodeApplyPosSizeToWindows(parent_node);
- parent_node->AuthorityForPos = parent_node->AuthorityForSize = parent_node->AuthorityForViewport = ImGuiDataAuthority_Auto;
- parent_node->VisibleWindow = merge_lead_child->VisibleWindow;
- parent_node->SizeRef = backup_last_explicit_size;
+//-----------------------------------------------------------------------------
+// [SECTION] DRAG AND DROP
+//-----------------------------------------------------------------------------
- // Flags transfer
- parent_node->LocalFlags &= ~ImGuiDockNodeFlags_LocalFlagsTransferMask_; // Preserve Dockspace flag
- parent_node->LocalFlags |= (child_0 ? child_0->LocalFlags : 0) & ImGuiDockNodeFlags_LocalFlagsTransferMask_;
- parent_node->LocalFlags |= (child_1 ? child_1->LocalFlags : 0) & ImGuiDockNodeFlags_LocalFlagsTransferMask_;
+void ImGui::ClearDragDrop()
+{
+ ImGuiContext& g = *GImGui;
+ g.DragDropActive = false;
+ g.DragDropPayload.Clear();
+ g.DragDropAcceptFlags = ImGuiDragDropFlags_None;
+ g.DragDropAcceptIdCurr = g.DragDropAcceptIdPrev = 0;
+ g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
+ g.DragDropAcceptFrameCount = -1;
- if (child_0)
- {
- ctx->DockContext->Nodes.SetVoidPtr(child_0->ID, NULL);
- IM_DELETE(child_0);
- }
- if (child_1)
- {
- ctx->DockContext->Nodes.SetVoidPtr(child_1->ID, NULL);
- IM_DELETE(child_1);
- }
+ g.DragDropPayloadBufHeap.clear();
+ memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal));
}
-// Update Pos/Size for a node hierarchy (don't affect child Windows yet)
-void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 size, bool only_write_to_marked_nodes)
+// Call when current ID is active.
+// When this returns true you need to: a) call SetDragDropPayload() exactly once, b) you may render the payload visual/description, c) call EndDragDropSource()
+bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
{
- // During the regular dock node update we write to all nodes.
- // 'only_write_to_marked_nodes' is only set when turning a node visible mid-frame and we need its size right-away.
- IM_ASSERT(size.x > 0.0f && size.y > 0.0f);
- const bool write_to_node = (only_write_to_marked_nodes == false) || (node->MarkedForPosSizeWrite);
- if (write_to_node)
- {
- node->Pos = pos;
- node->Size = size;
- }
-
- if (node->IsLeafNode())
- return;
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
- ImGuiDockNode* child_0 = node->ChildNodes[0];
- ImGuiDockNode* child_1 = node->ChildNodes[1];
- ImVec2 child_0_pos = pos, child_1_pos = pos;
- ImVec2 child_0_size = size, child_1_size = size;
- if (child_0->IsVisible && child_1->IsVisible)
+ bool source_drag_active = false;
+ ImGuiID source_id = 0;
+ ImGuiID source_parent_id = 0;
+ ImGuiMouseButton mouse_button = ImGuiMouseButton_Left;
+ if (!(flags & ImGuiDragDropFlags_SourceExtern))
{
- const float spacing = IMGUI_DOCK_SPLITTER_SIZE;
- const ImGuiAxis axis = (ImGuiAxis)node->SplitAxis;
- const float size_avail = ImMax(size[axis] - spacing, 0.0f);
-
- // Size allocation policy
- // 1) The first 0..WindowMinSize[axis]*2 are allocated evenly to both windows.
- ImGuiContext& g = *GImGui;
- const float size_min_each = ImFloor(ImMin(size_avail, g.Style.WindowMinSize[axis] * 2.0f) * 0.5f);
+ source_id = window->DC.LastItemId;
+ if (source_id != 0 && g.ActiveId != source_id) // Early out for most common case
+ return false;
+ if (g.IO.MouseDown[mouse_button] == false)
+ return false;
- // 2) Process locked absolute size (during a splitter resize we preserve the child of nodes not touching the splitter edge)
- IM_ASSERT(!(child_0->WantLockSizeOnce && child_1->WantLockSizeOnce));
- if (child_0->WantLockSizeOnce)
+ if (source_id == 0)
{
- child_0->WantLockSizeOnce = false;
- child_0_size[axis] = child_0->SizeRef[axis] = child_0->Size[axis];
- child_1_size[axis] = child_1->SizeRef[axis] = (size_avail - child_0_size[axis]);
- IM_ASSERT(child_0->SizeRef[axis] > 0.0f && child_1->SizeRef[axis] > 0.0f);
+ // If you want to use BeginDragDropSource() on an item with no unique identifier for interaction, such as Text() or Image(), you need to:
+ // A) Read the explanation below, B) Use the ImGuiDragDropFlags_SourceAllowNullID flag, C) Swallow your programmer pride.
+ if (!(flags & ImGuiDragDropFlags_SourceAllowNullID))
+ {
+ IM_ASSERT(0);
+ return false;
+ }
- }
- else if (child_1->WantLockSizeOnce)
- {
- child_1->WantLockSizeOnce = false;
- child_1_size[axis] = child_1->SizeRef[axis] = child_1->Size[axis];
- child_0_size[axis] = child_0->SizeRef[axis] = (size_avail - child_1_size[axis]);
- IM_ASSERT(child_0->SizeRef[axis] > 0.0f && child_1->SizeRef[axis] > 0.0f);
- }
+ // Early out
+ if ((window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect) == 0 && (g.ActiveId == 0 || g.ActiveIdWindow != window))
+ return false;
- // 3) If one window is the central node (~ use remaining space, should be made explicit!), use explicit size from the other, and remainder for the central node
- else if (child_1->IsCentralNode() && child_0->SizeRef[axis] != 0.0f)
- {
- child_0_size[axis] = ImMin(size_avail - size_min_each, child_0->SizeRef[axis]);
- child_1_size[axis] = (size_avail - child_0_size[axis]);
- }
- else if (child_0->IsCentralNode() && child_1->SizeRef[axis] != 0.0f)
- {
- child_1_size[axis] = ImMin(size_avail - size_min_each, child_1->SizeRef[axis]);
- child_0_size[axis] = (size_avail - child_1_size[axis]);
+ // Magic fallback (=somehow reprehensible) to handle items with no assigned ID, e.g. Text(), Image()
+ // We build a throwaway ID based on current ID stack + relative AABB of items in window.
+ // THE IDENTIFIER WON'T SURVIVE ANY REPOSITIONING OF THE WIDGET, so if your widget moves your dragging operation will be canceled.
+ // We don't need to maintain/call ClearActiveID() as releasing the button will early out this function and trigger !ActiveIdIsAlive.
+ source_id = window->DC.LastItemId = window->GetIDFromRectangle(window->DC.LastItemRect);
+ bool is_hovered = ItemHoverable(window->DC.LastItemRect, source_id);
+ if (is_hovered && g.IO.MouseClicked[mouse_button])
+ {
+ SetActiveID(source_id, window);
+ FocusWindow(window);
+ }
+ if (g.ActiveId == source_id) // Allow the underlying widget to display/return hovered during the mouse release frame, else we would get a flicker.
+ g.ActiveIdAllowOverlap = is_hovered;
}
else
{
- // 4) Otherwise distribute according to the relative ratio of each SizeRef value
- float split_ratio = child_0->SizeRef[axis] / (child_0->SizeRef[axis] + child_1->SizeRef[axis]);
- child_0_size[axis] = ImMax(size_min_each, ImFloor(size_avail * split_ratio + 0.5F));
- child_1_size[axis] = (size_avail - child_0_size[axis]);
+ g.ActiveIdAllowOverlap = false;
}
- child_1_pos[axis] += spacing + child_0_size[axis];
- }
- if (child_0->IsVisible)
- DockNodeTreeUpdatePosSize(child_0, child_0_pos, child_0_size);
- if (child_1->IsVisible)
- DockNodeTreeUpdatePosSize(child_1, child_1_pos, child_1_size);
-}
+ if (g.ActiveId != source_id)
+ return false;
+ source_parent_id = window->IDStack.back();
+ source_drag_active = IsMouseDragging(mouse_button);
-static void DockNodeTreeUpdateSplitterFindTouchingNode(ImGuiDockNode* node, ImGuiAxis axis, int side, ImVector* touching_nodes)
-{
- if (node->IsLeafNode())
+ // Disable navigation and key inputs while dragging
+ g.ActiveIdUsingNavDirMask = ~(ImU32)0;
+ g.ActiveIdUsingNavInputMask = ~(ImU32)0;
+ g.ActiveIdUsingKeyInputMask = ~(ImU64)0;
+ }
+ else
{
- touching_nodes->push_back(node);
- return;
+ window = NULL;
+ source_id = ImHashStr("#SourceExtern");
+ source_drag_active = true;
}
- if (node->ChildNodes[0]->IsVisible)
- if (node->SplitAxis != axis || side == 0 || !node->ChildNodes[1]->IsVisible)
- DockNodeTreeUpdateSplitterFindTouchingNode(node->ChildNodes[0], axis, side, touching_nodes);
- if (node->ChildNodes[1]->IsVisible)
- if (node->SplitAxis != axis || side == 1 || !node->ChildNodes[0]->IsVisible)
- DockNodeTreeUpdateSplitterFindTouchingNode(node->ChildNodes[1], axis, side, touching_nodes);
-}
-
-void ImGui::DockNodeTreeUpdateSplitter(ImGuiDockNode* node)
-{
- if (node->IsLeafNode())
- return;
-
- ImGuiContext& g = *GImGui;
- ImGuiDockNode* child_0 = node->ChildNodes[0];
- ImGuiDockNode* child_1 = node->ChildNodes[1];
- if (child_0->IsVisible && child_1->IsVisible)
+ if (source_drag_active)
{
- // Bounding box of the splitter cover the space between both nodes (w = Spacing, h = Size[xy^1] for when splitting horizontally)
- const ImGuiAxis axis = (ImGuiAxis)node->SplitAxis;
- IM_ASSERT(axis != ImGuiAxis_None);
- ImRect bb;
- bb.Min = child_0->Pos;
- bb.Max = child_1->Pos;
- bb.Min[axis] += child_0->Size[axis];
- bb.Max[axis ^ 1] += child_1->Size[axis ^ 1];
- //if (g.IO.KeyCtrl) GetForegroundDrawList(g.CurrentWindow->Viewport)->AddRect(bb.Min, bb.Max, IM_COL32(255,0,255,255));
-
- if ((child_0->GetMergedFlags() | child_1->GetMergedFlags()) & ImGuiDockNodeFlags_NoResize)
+ if (!g.DragDropActive)
{
- ImGuiWindow* window = g.CurrentWindow;
- window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_Separator), g.Style.FrameRounding);
+ IM_ASSERT(source_id != 0);
+ ClearDragDrop();
+ ImGuiPayload& payload = g.DragDropPayload;
+ payload.SourceId = source_id;
+ payload.SourceParentId = source_parent_id;
+ g.DragDropActive = true;
+ g.DragDropSourceFlags = flags;
+ g.DragDropMouseButton = mouse_button;
}
- else
- {
- //bb.Min[axis] += 1; // Display a little inward so highlight doesn't connect with nearby tabs on the neighbor node.
- //bb.Max[axis] -= 1;
- PushID(node->ID);
-
- // Gather list of nodes that are touching the splitter line. Find resizing limits based on those nodes.
- ImVector touching_nodes[2];
- float min_size = g.Style.WindowMinSize[axis];
- float resize_limits[2];
- resize_limits[0] = node->ChildNodes[0]->Pos[axis] + min_size;
- resize_limits[1] = node->ChildNodes[1]->Pos[axis] + node->ChildNodes[1]->Size[axis] - min_size;
-
- ImGuiID splitter_id = GetID("##Splitter");
- if (g.ActiveId == splitter_id)
- {
- // Only process when splitter is active
- DockNodeTreeUpdateSplitterFindTouchingNode(child_0, axis, 1, &touching_nodes[0]);
- DockNodeTreeUpdateSplitterFindTouchingNode(child_1, axis, 0, &touching_nodes[1]);
- for (int touching_node_n = 0; touching_node_n < touching_nodes[0].Size; touching_node_n++)
- resize_limits[0] = ImMax(resize_limits[0], touching_nodes[0][touching_node_n]->Rect().Min[axis] + min_size);
- for (int touching_node_n = 0; touching_node_n < touching_nodes[1].Size; touching_node_n++)
- resize_limits[1] = ImMin(resize_limits[1], touching_nodes[1][touching_node_n]->Rect().Max[axis] - min_size);
-
- /*
- // [DEBUG] Render limits
- ImDrawList* draw_list = node->HostWindow ? GetForegroundDrawList(node->HostWindow) : GetForegroundDrawList((ImGuiViewportP*)GetMainViewport());
- for (int n = 0; n < 2; n++)
- if (axis == ImGuiAxis_X)
- draw_list->AddLine(ImVec2(resize_limits[n], node->ChildNodes[n]->Pos.y), ImVec2(resize_limits[n], node->ChildNodes[n]->Pos.y + node->ChildNodes[n]->Size.y), IM_COL32(255, 0, 255, 255), 3.0f);
- else
- draw_list->AddLine(ImVec2(node->ChildNodes[n]->Pos.x, resize_limits[n]), ImVec2(node->ChildNodes[n]->Pos.x + node->ChildNodes[n]->Size.x, resize_limits[n]), IM_COL32(255, 0, 255, 255), 3.0f);
- */
- }
+ g.DragDropSourceFrameCount = g.FrameCount;
+ g.DragDropWithinSource = true;
- // Use a short delay before highlighting the splitter (and changing the mouse cursor) in order for regular mouse movement to not highlight many splitters
- float cur_size_0 = child_0->Size[axis];
- float cur_size_1 = child_1->Size[axis];
- float min_size_0 = resize_limits[0] - child_0->Pos[axis];
- float min_size_1 = child_1->Pos[axis] + child_1->Size[axis] - resize_limits[1];
- if (SplitterBehavior(bb, GetID("##Splitter"), axis, &cur_size_0, &cur_size_1, min_size_0, min_size_1, WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS, WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER))
+ if (!(flags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
+ {
+ // Target can request the Source to not display its tooltip (we use a dedicated flag to make this request explicit)
+ // We unfortunately can't just modify the source flags and skip the call to BeginTooltip, as caller may be emitting contents.
+ BeginTooltip();
+ if (g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip))
{
- if (touching_nodes[0].Size > 0 && touching_nodes[1].Size > 0)
- {
- child_0->Size[axis] = child_0->SizeRef[axis] = cur_size_0;
- child_1->Pos[axis] -= cur_size_1 - child_1->Size[axis];
- child_1->Size[axis] = child_1->SizeRef[axis] = cur_size_1;
-
- // Lock the size of every node that is a sibling of the node we are touching
- // This might be less desirable if we can merge sibling of a same axis into the same parental level.
- for (int side_n = 0; side_n < 2; side_n++)
- for (int touching_node_n = 0; touching_node_n < touching_nodes[side_n].Size; touching_node_n++)
- {
- ImGuiDockNode* touching_node = touching_nodes[side_n][touching_node_n];
- //ImDrawList* draw_list = node->HostWindow ? GetForegroundDrawList(node->HostWindow) : GetForegroundDrawList((ImGuiViewportP*)GetMainViewport());
- //draw_list->AddRect(touching_node->Pos, touching_node->Pos + touching_node->Size, IM_COL32(255, 128, 0, 255));
- while (touching_node->ParentNode != node)
- {
- if (touching_node->ParentNode->SplitAxis == axis)
- {
- // Mark other node so its size will be preserved during the upcoming call to DockNodeTreeUpdatePosSize().
- ImGuiDockNode* node_to_preserve = touching_node->ParentNode->ChildNodes[side_n];
- node_to_preserve->WantLockSizeOnce = true;
- //draw_list->AddRect(touching_node->Pos, touching_node->Rect().Max, IM_COL32(255, 0, 0, 255));
- //draw_list->AddRectFilled(node_to_preserve->Pos, node_to_preserve->Rect().Max, IM_COL32(0, 255, 0, 100));
- }
- touching_node = touching_node->ParentNode;
- }
- }
-
- DockNodeTreeUpdatePosSize(child_0, child_0->Pos, child_0->Size);
- DockNodeTreeUpdatePosSize(child_1, child_1->Pos, child_1->Size);
- MarkIniSettingsDirty();
- }
+ ImGuiWindow* tooltip_window = g.CurrentWindow;
+ tooltip_window->SkipItems = true;
+ tooltip_window->HiddenFramesCanSkipItems = 1;
}
- PopID();
}
- }
- if (child_0->IsVisible)
- DockNodeTreeUpdateSplitter(child_0);
- if (child_1->IsVisible)
- DockNodeTreeUpdateSplitter(child_1);
-}
+ if (!(flags & ImGuiDragDropFlags_SourceNoDisableHover) && !(flags & ImGuiDragDropFlags_SourceExtern))
+ window->DC.LastItemStatusFlags &= ~ImGuiItemStatusFlags_HoveredRect;
-ImGuiDockNode* ImGui::DockNodeTreeFindFallbackLeafNode(ImGuiDockNode* node)
-{
- if (node->IsLeafNode())
- return node;
- if (ImGuiDockNode* leaf_node = DockNodeTreeFindFallbackLeafNode(node->ChildNodes[0]))
- return leaf_node;
- if (ImGuiDockNode* leaf_node = DockNodeTreeFindFallbackLeafNode(node->ChildNodes[1]))
- return leaf_node;
- return NULL;
+ return true;
+ }
+ return false;
}
-ImGuiDockNode* ImGui::DockNodeTreeFindNodeByPos(ImGuiDockNode* node, ImVec2 pos)
+void ImGui::EndDragDropSource()
{
- if (!node->IsVisible)
- return NULL;
-
ImGuiContext& g = *GImGui;
- const float dock_spacing = g.Style.ItemInnerSpacing.x;
- ImRect r(node->Pos, node->Pos + node->Size);
- r.Expand(dock_spacing * 0.5f);
- bool inside = r.Contains(pos);
- if (!inside)
- return NULL;
-
- if (node->IsLeafNode())
- return node;
- if (ImGuiDockNode* hovered_node = DockNodeTreeFindNodeByPos(node->ChildNodes[0], pos))
- return hovered_node;
- if (ImGuiDockNode* hovered_node = DockNodeTreeFindNodeByPos(node->ChildNodes[1], pos))
- return hovered_node;
+ IM_ASSERT(g.DragDropActive);
+ IM_ASSERT(g.DragDropWithinSource && "Not after a BeginDragDropSource()?");
- // There is an edge case when docking into a dockspace which only has inactive nodes (because none of the windows are active)
- // In this case we need to fallback into any leaf mode, possibly the central node.
- if (node->IsDockSpace() && node->IsRootNode())
- {
- if (node->CentralNode && node->IsLeafNode()) // FIXME-20181220: We should not have to test for IsLeafNode() here but we have another bug to fix first.
- return node->CentralNode;
- return DockNodeTreeFindFallbackLeafNode(node);
- }
+ if (!(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
+ EndTooltip();
- return NULL;
+ // Discard the drag if have not called SetDragDropPayload()
+ if (g.DragDropPayload.DataFrameCount == -1)
+ ClearDragDrop();
+ g.DragDropWithinSource = false;
}
-//-----------------------------------------------------------------------------
-// Docking: Public Functions (SetWindowDock, DockSpace, DockSpaceOverViewport)
-//-----------------------------------------------------------------------------
-// - SetWindowDock() [Internal]
-// - DockSpace()
-// - DockSpaceOverViewport()
-//-----------------------------------------------------------------------------
-
-// [Internal] Called via SetNextWindowDockID()
-void ImGui::SetWindowDock(ImGuiWindow* window, ImGuiID dock_id, ImGuiCond cond)
+// Use 'cond' to choose to submit payload on drag start or every frame
+bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_size, ImGuiCond cond)
{
- // Test condition (NB: bit 0 is always true) and clear flags for next time
- if (cond && (window->SetWindowDockAllowFlags & cond) == 0)
- return;
- window->SetWindowDockAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
+ ImGuiContext& g = *GImGui;
+ ImGuiPayload& payload = g.DragDropPayload;
+ if (cond == 0)
+ cond = ImGuiCond_Always;
- if (window->DockId == dock_id)
- return;
+ IM_ASSERT(type != NULL);
+ IM_ASSERT(strlen(type) < IM_ARRAYSIZE(payload.DataType) && "Payload type can be at most 32 characters long");
+ IM_ASSERT((data != NULL && data_size > 0) || (data == NULL && data_size == 0));
+ IM_ASSERT(cond == ImGuiCond_Always || cond == ImGuiCond_Once);
+ IM_ASSERT(payload.SourceId != 0); // Not called between BeginDragDropSource() and EndDragDropSource()
- // If the user attempt to set a dock id that is a split node, we'll dig within to find a suitable docking spot
- ImGuiContext* ctx = GImGui;
- if (ImGuiDockNode* new_node = DockContextFindNodeByID(ctx, dock_id))
- if (new_node->IsSplitNode())
+ if (cond == ImGuiCond_Always || payload.DataFrameCount == -1)
+ {
+ // Copy payload
+ ImStrncpy(payload.DataType, type, IM_ARRAYSIZE(payload.DataType));
+ g.DragDropPayloadBufHeap.resize(0);
+ if (data_size > sizeof(g.DragDropPayloadBufLocal))
{
- // Policy: Find central node or latest focused node. We first move back to our root node.
- new_node = DockNodeGetRootNode(new_node);
- if (new_node->CentralNode)
- {
- IM_ASSERT(new_node->CentralNode->IsCentralNode());
- dock_id = new_node->CentralNode->ID;
- }
- else
- {
- dock_id = new_node->LastFocusedNodeID;
- }
+ // Store in heap
+ g.DragDropPayloadBufHeap.resize((int)data_size);
+ payload.Data = g.DragDropPayloadBufHeap.Data;
+ memcpy(payload.Data, data, data_size);
}
-
- if (window->DockId == dock_id)
- return;
-
- if (window->DockNode)
- DockNodeRemoveWindow(window->DockNode, window, 0);
- window->DockId = dock_id;
-}
-
-// Create an explicit dockspace node within an existing window. Also expose dock node flags and creates a CentralNode by default.
-// The Central Node is always displayed even when empty and shrink/extend according to the requested size of its neighbors.
-void ImGui::DockSpace(ImGuiID id, const ImVec2& size_arg, ImGuiDockNodeFlags flags, const ImGuiWindowClass* window_class)
-{
- ImGuiContext* ctx = GImGui;
- ImGuiContext& g = *ctx;
- ImGuiWindow* window = GetCurrentWindow();
- if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable))
- return;
-
- IM_ASSERT((flags & ImGuiDockNodeFlags_DockSpace) == 0);
- ImGuiDockNode* node = DockContextFindNodeByID(ctx, id);
- if (!node)
- {
- IMGUI_DEBUG_LOG_DOCKING("DockSpace: dockspace node 0x%08X created\n", id);
- node = DockContextAddNode(ctx, id);
- node->LocalFlags |= ImGuiDockNodeFlags_CentralNode;
- }
- if (window_class && window_class->ClassId != node->WindowClass.ClassId)
- IMGUI_DEBUG_LOG_DOCKING("DockSpace: dockspace node 0x%08X: setup WindowClass 0x%08X -> 0x%08X\n", id, node->WindowClass.ClassId, window_class->ClassId);
- node->SharedFlags = flags;
- node->WindowClass = window_class ? *window_class : ImGuiWindowClass();
-
- // When a DockSpace transitioned form implicit to explicit this may be called a second time
- // It is possible that the node has already been claimed by a docked window which appeared before the DockSpace() node, so we overwrite IsDockSpace again.
- if (node->LastFrameActive == g.FrameCount && !(flags & ImGuiDockNodeFlags_KeepAliveOnly))
- {
- IM_ASSERT(node->IsDockSpace() == false && "Cannot call DockSpace() twice a frame with the same ID");
- node->LocalFlags |= ImGuiDockNodeFlags_DockSpace;
- return;
- }
- node->LocalFlags |= ImGuiDockNodeFlags_DockSpace;
-
- // Keep alive mode, this is allow windows docked into this node so stay docked even if they are not visible
- if (flags & ImGuiDockNodeFlags_KeepAliveOnly)
- {
- node->LastFrameAlive = g.FrameCount;
- return;
+ else if (data_size > 0)
+ {
+ // Store locally
+ memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal));
+ payload.Data = g.DragDropPayloadBufLocal;
+ memcpy(payload.Data, data, data_size);
+ }
+ else
+ {
+ payload.Data = NULL;
+ }
+ payload.DataSize = (int)data_size;
}
+ payload.DataFrameCount = g.FrameCount;
- const ImVec2 content_avail = GetContentRegionAvail();
- ImVec2 size = ImFloor(size_arg);
- if (size.x <= 0.0f)
- size.x = ImMax(content_avail.x + size.x, 4.0f); // Arbitrary minimum child size (0.0f causing too much issues)
- if (size.y <= 0.0f)
- size.y = ImMax(content_avail.y + size.y, 4.0f);
- IM_ASSERT(size.x > 0.0f && size.y > 0.0f);
-
- node->Pos = window->DC.CursorPos;
- node->Size = node->SizeRef = size;
- SetNextWindowPos(node->Pos);
- SetNextWindowSize(node->Size);
- g.NextWindowData.PosUndock = false;
-
- // FIXME-DOCKING: Why do we need a child window to host a dockspace, could we host it in the existing window?
- ImGuiWindowFlags window_flags = ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_DockNodeHost;
- window_flags |= ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar;
- window_flags |= ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
-
- char title[256];
- ImFormatString(title, IM_ARRAYSIZE(title), "%s/DockSpace_%08X", window->Name, id);
-
- if (node->Windows.Size > 0 || node->IsSplitNode())
- PushStyleColor(ImGuiCol_ChildBg, IM_COL32(0, 0, 0, 0));
- PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0.0f);
- Begin(title, NULL, window_flags);
- PopStyleVar();
- if (node->Windows.Size > 0 || node->IsSplitNode())
- PopStyleColor();
-
- ImGuiWindow* host_window = g.CurrentWindow;
- host_window->DockNodeAsHost = node;
- host_window->ChildId = window->GetID(title);
- node->HostWindow = host_window;
- node->OnlyNodeWithWindows = NULL;
-
- IM_ASSERT(node->IsRootNode());
- DockNodeUpdate(node);
-
- End();
+ return (g.DragDropAcceptFrameCount == g.FrameCount) || (g.DragDropAcceptFrameCount == g.FrameCount - 1);
}
-// Tips: Use with ImGuiDockNodeFlags_PassthruCentralNode!
-// The limitation with this call is that your window won't have a menu bar.
-// Even though we could pass window flags, it would also require the user to be able to call BeginMenuBar() somehow meaning we can't Begin/End in a single function.
-// So if you want a menu bar you need to repeat this code manually ourselves. As with advanced other Docking API, we may change this function signature.
-ImGuiID ImGui::DockSpaceOverViewport(ImGuiViewport* viewport, ImGuiDockNodeFlags dockspace_flags, const ImGuiWindowClass* window_class)
+bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id)
{
- if (viewport == NULL)
- viewport = GetMainViewport();
+ ImGuiContext& g = *GImGui;
+ if (!g.DragDropActive)
+ return false;
- SetNextWindowPos(viewport->Pos);
- SetNextWindowSize(viewport->Size);
- SetNextWindowViewport(viewport->ID);
+ ImGuiWindow* window = g.CurrentWindow;
+ if (g.HoveredWindow == NULL || window->RootWindow != g.HoveredWindow->RootWindow)
+ return false;
+ IM_ASSERT(id != 0);
+ if (!IsMouseHoveringRect(bb.Min, bb.Max) || (id == g.DragDropPayload.SourceId))
+ return false;
+ if (window->SkipItems)
+ return false;
- ImGuiWindowFlags host_window_flags = 0;
- host_window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDocking;
- host_window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
- if (dockspace_flags & ImGuiDockNodeFlags_PassthruCentralNode)
- host_window_flags |= ImGuiWindowFlags_NoBackground;
+ IM_ASSERT(g.DragDropWithinTarget == false);
+ g.DragDropTargetRect = bb;
+ g.DragDropTargetId = id;
+ g.DragDropWithinTarget = true;
+ return true;
+}
- char label[32];
- ImFormatString(label, IM_ARRAYSIZE(label), "DockSpaceViewport_%08X", viewport->ID);
+// We don't use BeginDragDropTargetCustom() and duplicate its code because:
+// 1) we use LastItemRectHoveredRect which handles items that pushes a temporarily clip rectangle in their code. Calling BeginDragDropTargetCustom(LastItemRect) would not handle them.
+// 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can.
+// Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case)
+bool ImGui::BeginDragDropTarget()
+{
+ ImGuiContext& g = *GImGui;
+ if (!g.DragDropActive)
+ return false;
- PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
- PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
- PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
- Begin(label, NULL, host_window_flags);
- PopStyleVar(3);
+ ImGuiWindow* window = g.CurrentWindow;
+ if (!(window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect))
+ return false;
+ if (g.HoveredWindow == NULL || window->RootWindow != g.HoveredWindow->RootWindow)
+ return false;
- ImGuiID dockspace_id = GetID("DockSpace");
- DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags, window_class);
- End();
+ const ImRect& display_rect = (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect) ? window->DC.LastItemDisplayRect : window->DC.LastItemRect;
+ ImGuiID id = window->DC.LastItemId;
+ if (id == 0)
+ id = window->GetIDFromRectangle(display_rect);
+ if (g.DragDropPayload.SourceId == id)
+ return false;
- return dockspace_id;
+ IM_ASSERT(g.DragDropWithinTarget == false);
+ g.DragDropTargetRect = display_rect;
+ g.DragDropTargetId = id;
+ g.DragDropWithinTarget = true;
+ return true;
}
-//-----------------------------------------------------------------------------
-// Docking: Builder Functions
-//-----------------------------------------------------------------------------
-// Very early end-user API to manipulate dock nodes.
-// Only available in imgui_internal.h. Expect this API to change/break!
-// It is expected that those functions are all called _before_ the dockspace node submission.
-//-----------------------------------------------------------------------------
-// - DockBuilderDockWindow()
-// - DockBuilderGetNode()
-// - DockBuilderSetNodePos()
-// - DockBuilderSetNodeSize()
-// - DockBuilderAddNode()
-// - DockBuilderRemoveNode()
-// - DockBuilderRemoveNodeChildNodes()
-// - DockBuilderRemoveNodeDockedWindows()
-// - DockBuilderSplitNode()
-// - DockBuilderCopyNodeRec()
-// - DockBuilderCopyNode()
-// - DockBuilderCopyWindowSettings()
-// - DockBuilderCopyDockSpace()
-// - DockBuilderFinish()
-//-----------------------------------------------------------------------------
+bool ImGui::IsDragDropPayloadBeingAccepted()
+{
+ ImGuiContext& g = *GImGui;
+ return g.DragDropActive && g.DragDropAcceptIdPrev != 0;
+}
-void ImGui::DockBuilderDockWindow(const char* window_name, ImGuiID node_id)
+const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags)
{
- // We don't preserve relative order of multiple docked windows (by clearing DockOrder back to -1)
- ImGuiID window_id = ImHashStr(window_name);
- if (ImGuiWindow* window = FindWindowByID(window_id))
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ ImGuiPayload& payload = g.DragDropPayload;
+ IM_ASSERT(g.DragDropActive); // Not called between BeginDragDropTarget() and EndDragDropTarget() ?
+ IM_ASSERT(payload.DataFrameCount != -1); // Forgot to call EndDragDropTarget() ?
+ if (type != NULL && !payload.IsDataType(type))
+ return NULL;
+
+ // Accept smallest drag target bounding box, this allows us to nest drag targets conveniently without ordering constraints.
+ // NB: We currently accept NULL id as target. However, overlapping targets requires a unique ID to function!
+ const bool was_accepted_previously = (g.DragDropAcceptIdPrev == g.DragDropTargetId);
+ ImRect r = g.DragDropTargetRect;
+ float r_surface = r.GetWidth() * r.GetHeight();
+ if (r_surface < g.DragDropAcceptIdCurrRectSurface)
{
- // Apply to created window
- SetWindowDock(window, node_id, ImGuiCond_Always);
- window->DockOrder = -1;
+ g.DragDropAcceptFlags = flags;
+ g.DragDropAcceptIdCurr = g.DragDropTargetId;
+ g.DragDropAcceptIdCurrRectSurface = r_surface;
}
- else
+
+ // Render default drop visuals
+ payload.Preview = was_accepted_previously;
+ flags |= (g.DragDropSourceFlags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect); // Source can also inhibit the preview (useful for external sources that lives for 1 frame)
+ if (!(flags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect) && payload.Preview)
{
- // Apply to settings
- ImGuiWindowSettings* settings = FindWindowSettings(window_id);
- if (settings == NULL)
- settings = CreateNewWindowSettings(window_name);
- settings->DockId = node_id;
- settings->DockOrder = -1;
+ // FIXME-DRAG: Settle on a proper default visuals for drop target.
+ r.Expand(3.5f);
+ bool push_clip_rect = !window->ClipRect.Contains(r);
+ if (push_clip_rect) window->DrawList->PushClipRect(r.Min-ImVec2(1,1), r.Max+ImVec2(1,1));
+ window->DrawList->AddRect(r.Min, r.Max, GetColorU32(ImGuiCol_DragDropTarget), 0.0f, ~0, 2.0f);
+ if (push_clip_rect) window->DrawList->PopClipRect();
}
+
+ g.DragDropAcceptFrameCount = g.FrameCount;
+ payload.Delivery = was_accepted_previously && !IsMouseDown(g.DragDropMouseButton); // For extern drag sources affecting os window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased()
+ if (!payload.Delivery && !(flags & ImGuiDragDropFlags_AcceptBeforeDelivery))
+ return NULL;
+
+ return &payload;
}
-ImGuiDockNode* ImGui::DockBuilderGetNode(ImGuiID node_id)
+const ImGuiPayload* ImGui::GetDragDropPayload()
{
- ImGuiContext* ctx = GImGui;
- return DockContextFindNodeByID(ctx, node_id);
+ ImGuiContext& g = *GImGui;
+ return g.DragDropActive ? &g.DragDropPayload : NULL;
}
-void ImGui::DockBuilderSetNodePos(ImGuiID node_id, ImVec2 pos)
+// We don't really use/need this now, but added it for the sake of consistency and because we might need it later.
+void ImGui::EndDragDropTarget()
{
- ImGuiContext* ctx = GImGui;
- ImGuiDockNode* node = DockContextFindNodeByID(ctx, node_id);
- if (node == NULL)
- return;
- node->Pos = pos;
- node->AuthorityForPos = ImGuiDataAuthority_DockNode;
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(g.DragDropActive);
+ IM_ASSERT(g.DragDropWithinTarget);
+ g.DragDropWithinTarget = false;
}
-void ImGui::DockBuilderSetNodeSize(ImGuiID node_id, ImVec2 size)
+//-----------------------------------------------------------------------------
+// [SECTION] LOGGING/CAPTURING
+//-----------------------------------------------------------------------------
+// All text output from the interface can be captured into tty/file/clipboard.
+// By default, tree nodes are automatically opened during logging.
+//-----------------------------------------------------------------------------
+
+// Pass text data straight to log (without being displayed)
+void ImGui::LogText(const char* fmt, ...)
{
- ImGuiContext* ctx = GImGui;
- ImGuiDockNode* node = DockContextFindNodeByID(ctx, node_id);
- if (node == NULL)
+ ImGuiContext& g = *GImGui;
+ if (!g.LogEnabled)
return;
- IM_ASSERT(size.x > 0.0f && size.y > 0.0f);
- node->Size = node->SizeRef = size;
- node->AuthorityForSize = ImGuiDataAuthority_DockNode;
-}
-// Make sure to use the ImGuiDockNodeFlags_DockSpace flag to create a dockspace node! Otherwise this will create a floating node!
-// - Floating node: you can then call DockBuilderSetNodePos()/DockBuilderSetNodeSize() to position and size the floating node.
-// - Dockspace node: calling DockBuilderSetNodePos() is unnecessary.
-// - If you intend to split a node immediately after creation using DockBuilderSplitNode(), make sure to call DockBuilderSetNodeSize() beforehand!
-// For various reason, the splitting code currently needs a base size otherwise space may not be allocated as precisely as you would expect.
-// - Use (id == 0) to let the system allocate a node identifier.
-ImGuiID ImGui::DockBuilderAddNode(ImGuiID id, ImGuiDockNodeFlags flags)
-{
- ImGuiContext* ctx = GImGui;
- ImGuiDockNode* node = NULL;
- if (flags & ImGuiDockNodeFlags_DockSpace)
+ va_list args;
+ va_start(args, fmt);
+ if (g.LogFile)
{
- DockSpace(id, ImVec2(0, 0), (flags & ~ImGuiDockNodeFlags_DockSpace) | ImGuiDockNodeFlags_KeepAliveOnly);
- node = DockContextFindNodeByID(ctx, id);
+ g.LogBuffer.Buf.resize(0);
+ g.LogBuffer.appendfv(fmt, args);
+ ImFileWrite(g.LogBuffer.c_str(), sizeof(char), (ImU64)g.LogBuffer.size(), g.LogFile);
}
else
{
- if (id != 0)
- node = DockContextFindNodeByID(ctx, id);
- if (!node)
- node = DockContextAddNode(ctx, id);
- node->LocalFlags = flags;
+ g.LogBuffer.appendfv(fmt, args);
}
- node->LastFrameAlive = ctx->FrameCount; // Set this otherwise BeginDocked will undock during the same frame.
- return node->ID;
-}
-
-void ImGui::DockBuilderRemoveNode(ImGuiID node_id)
-{
- ImGuiContext* ctx = GImGui;
- ImGuiDockNode* node = DockContextFindNodeByID(ctx, node_id);
- if (node == NULL)
- return;
- DockBuilderRemoveNodeDockedWindows(node_id, true);
- DockBuilderRemoveNodeChildNodes(node_id);
- if (node->IsCentralNode() && node->ParentNode)
- node->ParentNode->LocalFlags |= ImGuiDockNodeFlags_CentralNode;
- DockContextRemoveNode(ctx, node, true);
+ va_end(args);
}
-void ImGui::DockBuilderRemoveNodeChildNodes(ImGuiID root_id)
+// Internal version that takes a position to decide on newline placement and pad items according to their depth.
+// We split text into individual lines to add current tree level padding
+void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end)
{
- ImGuiContext* ctx = GImGui;
- ImGuiDockContext* dc = ctx->DockContext;
-
- ImGuiDockNode* root_node = root_id ? DockContextFindNodeByID(ctx, root_id) : NULL;
- if (root_id && root_node == NULL)
- return;
- bool has_central_node = false;
-
- ImGuiDataAuthority backup_root_node_authority_for_pos = root_node ? root_node->AuthorityForPos : ImGuiDataAuthority_Auto;
- ImGuiDataAuthority backup_root_node_authority_for_size = root_node ? root_node->AuthorityForSize : ImGuiDataAuthority_Auto;
-
- // Process active windows
- ImVector nodes_to_remove;
- for (int n = 0; n < dc->Nodes.Data.Size; n++)
- if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
- {
- bool want_removal = (root_id == 0) || (node->ID != root_id && DockNodeGetRootNode(node)->ID == root_id);
- if (want_removal)
- {
- if (node->IsCentralNode())
- has_central_node = true;
- if (root_id != 0)
- DockContextQueueNotifyRemovedNode(ctx, node);
- if (root_node)
- DockNodeMoveWindows(root_node, node);
- nodes_to_remove.push_back(node);
- }
- }
-
- // DockNodeMoveWindows->DockNodeAddWindow will normally set those when reaching two windows (which is only adequate during interactive merge)
- // Make sure we don't lose our current pos/size. (FIXME-DOCK: Consider tidying up that code in DockNodeAddWindow instead)
- if (root_node)
- {
- root_node->AuthorityForPos = backup_root_node_authority_for_pos;
- root_node->AuthorityForSize = backup_root_node_authority_for_size;
- }
-
- // Apply to settings
- for (int settings_n = 0; settings_n < ctx->SettingsWindows.Size; settings_n++)
- if (ImGuiID window_settings_dock_id = ctx->SettingsWindows[settings_n].DockId)
- for (int n = 0; n < nodes_to_remove.Size; n++)
- if (nodes_to_remove[n]->ID == window_settings_dock_id)
- {
- ctx->SettingsWindows[settings_n].DockId = root_id;
- break;
- }
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
- // Not really efficient, but easier to destroy a whole hierarchy considering DockContextRemoveNode is attempting to merge nodes
- if (nodes_to_remove.Size > 1)
- ImQsort(nodes_to_remove.Data, nodes_to_remove.Size, sizeof(ImGuiDockNode*), DockNodeComparerDepthMostFirst);
- for (int n = 0; n < nodes_to_remove.Size; n++)
- DockContextRemoveNode(ctx, nodes_to_remove[n], false);
+ if (!text_end)
+ text_end = FindRenderedTextEnd(text, text_end);
- if (root_id == 0)
- {
- dc->Nodes.Clear();
- dc->Requests.clear();
- }
- else if (has_central_node)
- {
- root_node->LocalFlags |= ImGuiDockNodeFlags_CentralNode;
- root_node->CentralNode = root_node;
- }
-}
+ const bool log_new_line = ref_pos && (ref_pos->y > g.LogLinePosY + 1);
+ if (ref_pos)
+ g.LogLinePosY = ref_pos->y;
+ if (log_new_line)
+ g.LogLineFirstItem = true;
-void ImGui::DockBuilderRemoveNodeDockedWindows(ImGuiID root_id, bool clear_persistent_docking_references)
-{
- // Clear references in settings
- ImGuiContext* ctx = GImGui;
- ImGuiContext& g = *ctx;
- if (clear_persistent_docking_references)
+ const char* text_remaining = text;
+ if (g.LogDepthRef > window->DC.TreeDepth) // Re-adjust padding if we have popped out of our starting depth
+ g.LogDepthRef = window->DC.TreeDepth;
+ const int tree_depth = (window->DC.TreeDepth - g.LogDepthRef);
+ for (;;)
{
- for (int n = 0; n < g.SettingsWindows.Size; n++)
+ // Split the string. Each new line (after a '\n') is followed by spacing corresponding to the current depth of our log entry.
+ // We don't add a trailing \n to allow a subsequent item on the same line to be captured.
+ const char* line_start = text_remaining;
+ const char* line_end = ImStreolRange(line_start, text_end);
+ const bool is_first_line = (line_start == text);
+ const bool is_last_line = (line_end == text_end);
+ if (!is_last_line || (line_start != line_end))
{
- ImGuiWindowSettings* settings = &g.SettingsWindows[n];
- bool want_removal = (root_id == 0) || (settings->DockId == root_id);
- if (!want_removal && settings->DockId != 0)
- if (ImGuiDockNode* node = DockContextFindNodeByID(ctx, settings->DockId))
- if (DockNodeGetRootNode(node)->ID == root_id)
- want_removal = true;
- if (want_removal)
- settings->DockId = 0;
+ const int char_count = (int)(line_end - line_start);
+ if (log_new_line || !is_first_line)
+ LogText(IM_NEWLINE "%*s%.*s", tree_depth * 4, "", char_count, line_start);
+ else if (g.LogLineFirstItem)
+ LogText("%*s%.*s", tree_depth * 4, "", char_count, line_start);
+ else
+ LogText(" %.*s", char_count, line_start);
+ g.LogLineFirstItem = false;
}
- }
-
- // Clear references in windows
- for (int n = 0; n < g.Windows.Size; n++)
- {
- ImGuiWindow* window = g.Windows[n];
- bool want_removal = (root_id == 0) || (window->DockNode && DockNodeGetRootNode(window->DockNode)->ID == root_id) || (window->DockNodeAsHost && window->DockNodeAsHost->ID == root_id);
- if (want_removal)
+ else if (log_new_line)
{
- const ImGuiID backup_dock_id = window->DockId;
- DockContextProcessUndockWindow(ctx, window, clear_persistent_docking_references);
- if (!clear_persistent_docking_references)
- IM_ASSERT(window->DockId == backup_dock_id);
+ // An empty "" string at a different Y position should output a carriage return.
+ LogText(IM_NEWLINE);
+ break;
}
- }
-}
-
-// If 'out_id_at_dir' or 'out_id_at_opposite_dir' are non NULL, the function will write out the ID of the two new nodes created.
-// Return value is ID of the node at the specified direction, so same as (*out_id_at_dir) if that pointer is set.
-// FIXME-DOCK: We are not exposing nor using split_outer.
-ImGuiID ImGui::DockBuilderSplitNode(ImGuiID id, ImGuiDir split_dir, float size_ratio_for_node_at_dir, ImGuiID* out_id_at_dir, ImGuiID* out_id_at_opposite_dir)
-{
- ImGuiContext* ctx = GImGui;
- IM_ASSERT(split_dir != ImGuiDir_None);
- IMGUI_DEBUG_LOG_DOCKING("DockBuilderSplitNode node 0x%08X, split_dir %d\n", id, split_dir);
- ImGuiDockNode* node = DockContextFindNodeByID(ctx, id);
- if (node == NULL)
- {
- IM_ASSERT(node != NULL);
- return 0;
+ if (is_last_line)
+ break;
+ text_remaining = line_end + 1;
}
-
- IM_ASSERT(!node->IsSplitNode()); // Assert if already Split
-
- ImGuiDockRequest req;
- req.Type = ImGuiDockRequestType_Split;
- req.DockTargetWindow = NULL;
- req.DockTargetNode = node;
- req.DockPayload = NULL;
- req.DockSplitDir = split_dir;
- req.DockSplitRatio = ImSaturate((split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Up) ? size_ratio_for_node_at_dir : 1.0f - size_ratio_for_node_at_dir);
- req.DockSplitOuter = false;
- DockContextProcessDock(ctx, &req);
-
- ImGuiID id_at_dir = node->ChildNodes[(split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Up) ? 0 : 1]->ID;
- ImGuiID id_at_opposite_dir = node->ChildNodes[(split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Up) ? 1 : 0]->ID;
- if (out_id_at_dir)
- *out_id_at_dir = id_at_dir;
- if (out_id_at_opposite_dir)
- *out_id_at_opposite_dir = id_at_opposite_dir;
- return id_at_dir;
}
-static ImGuiDockNode* DockBuilderCopyNodeRec(ImGuiDockNode* src_node, ImGuiID dst_node_id_if_known, ImVector* out_node_remap_pairs)
-{
- ImGuiContext* ctx = GImGui;
- ImGuiDockNode* dst_node = ImGui::DockContextAddNode(ctx, dst_node_id_if_known);
- dst_node->SharedFlags = src_node->SharedFlags;
- dst_node->LocalFlags = src_node->LocalFlags;
- dst_node->Pos = src_node->Pos;
- dst_node->Size = src_node->Size;
- dst_node->SizeRef = src_node->SizeRef;
- dst_node->SplitAxis = src_node->SplitAxis;
-
- out_node_remap_pairs->push_back(src_node->ID);
- out_node_remap_pairs->push_back(dst_node->ID);
-
- for (int child_n = 0; child_n < IM_ARRAYSIZE(src_node->ChildNodes); child_n++)
- if (src_node->ChildNodes[child_n])
- {
- dst_node->ChildNodes[child_n] = DockBuilderCopyNodeRec(src_node->ChildNodes[child_n], 0, out_node_remap_pairs);
- dst_node->ChildNodes[child_n]->ParentNode = dst_node;
- }
-
- IMGUI_DEBUG_LOG_DOCKING("Fork node %08X -> %08X (%d childs)\n", src_node->ID, dst_node->ID, dst_node->IsSplitNode() ? 2 : 0);
- return dst_node;
-}
-
-void ImGui::DockBuilderCopyNode(ImGuiID src_node_id, ImGuiID dst_node_id, ImVector* out_node_remap_pairs)
+// Start logging/capturing text output
+void ImGui::LogBegin(ImGuiLogType type, int auto_open_depth)
{
- ImGuiContext* ctx = GImGui;
- IM_ASSERT(src_node_id != 0);
- IM_ASSERT(dst_node_id != 0);
- IM_ASSERT(out_node_remap_pairs != NULL);
-
- ImGuiDockNode* src_node = DockContextFindNodeByID(ctx, src_node_id);
- IM_ASSERT(src_node != NULL);
-
- out_node_remap_pairs->clear();
- DockBuilderRemoveNode(dst_node_id);
- DockBuilderCopyNodeRec(src_node, dst_node_id, out_node_remap_pairs);
-
- IM_ASSERT((out_node_remap_pairs->Size % 2) == 0);
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ IM_ASSERT(g.LogEnabled == false);
+ IM_ASSERT(g.LogFile == NULL);
+ IM_ASSERT(g.LogBuffer.empty());
+ g.LogEnabled = true;
+ g.LogType = type;
+ g.LogDepthRef = window->DC.TreeDepth;
+ g.LogDepthToExpand = ((auto_open_depth >= 0) ? auto_open_depth : g.LogDepthToExpandDefault);
+ g.LogLinePosY = FLT_MAX;
+ g.LogLineFirstItem = true;
}
-void ImGui::DockBuilderCopyWindowSettings(const char* src_name, const char* dst_name)
+void ImGui::LogToTTY(int auto_open_depth)
{
- ImGuiWindow* src_window = FindWindowByName(src_name);
- if (src_window == NULL)
+ ImGuiContext& g = *GImGui;
+ if (g.LogEnabled)
return;
- if (ImGuiWindow* dst_window = FindWindowByName(dst_name))
- {
- dst_window->Pos = src_window->Pos;
- dst_window->Size = src_window->Size;
- dst_window->SizeFull = src_window->SizeFull;
- dst_window->Collapsed = src_window->Collapsed;
- }
- else if (ImGuiWindowSettings* dst_settings = FindOrCreateWindowSettings(dst_name))
- {
- ImVec2ih window_pos_2ih = ImVec2ih(src_window->Pos);
- if (src_window->ViewportId != 0 && src_window->ViewportId != IMGUI_VIEWPORT_DEFAULT_ID)
- {
- dst_settings->ViewportPos = window_pos_2ih;
- dst_settings->ViewportId = src_window->ViewportId;
- dst_settings->Pos = ImVec2ih(0, 0);
- }
- else
- {
- dst_settings->Pos = window_pos_2ih;
- }
- dst_settings->Size = ImVec2ih(src_window->SizeFull);
- dst_settings->Collapsed = src_window->Collapsed;
- }
+ IM_UNUSED(auto_open_depth);
+#ifndef IMGUI_DISABLE_TTY_FUNCTIONS
+ LogBegin(ImGuiLogType_TTY, auto_open_depth);
+ g.LogFile = stdout;
+#endif
}
-// FIXME: Will probably want to change this signature, in particular how the window remapping pairs are passed.
-void ImGui::DockBuilderCopyDockSpace(ImGuiID src_dockspace_id, ImGuiID dst_dockspace_id, ImVector* in_window_remap_pairs)
+// Start logging/capturing text output to given file
+void ImGui::LogToFile(int auto_open_depth, const char* filename)
{
- IM_ASSERT(src_dockspace_id != 0);
- IM_ASSERT(dst_dockspace_id != 0);
- IM_ASSERT(in_window_remap_pairs != NULL);
- IM_ASSERT((in_window_remap_pairs->Size % 2) == 0);
-
- // Duplicate entire dock
- // FIXME: When overwriting dst_dockspace_id, windows that aren't part of our dockspace window class but that are docked in a same node will be split apart,
- // whereas we could attempt to at least keep them together in a new, same floating node.
- ImVector node_remap_pairs;
- DockBuilderCopyNode(src_dockspace_id, dst_dockspace_id, &node_remap_pairs);
+ ImGuiContext& g = *GImGui;
+ if (g.LogEnabled)
+ return;
- // Attempt to transition all the upcoming windows associated to dst_dockspace_id into the newly created hierarchy of dock nodes
- // (The windows associated to src_dockspace_id are staying in place)
- ImVector src_windows;
- for (int remap_window_n = 0; remap_window_n < in_window_remap_pairs->Size; remap_window_n += 2)
+ // FIXME: We could probably open the file in text mode "at", however note that clipboard/buffer logging will still
+ // be subject to outputting OS-incompatible carriage return if within strings the user doesn't use IM_NEWLINE.
+ // By opening the file in binary mode "ab" we have consistent output everywhere.
+ if (!filename)
+ filename = g.IO.LogFilename;
+ if (!filename || !filename[0])
+ return;
+ ImFileHandle f = ImFileOpen(filename, "ab");
+ if (!f)
{
- 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];
- ImGuiID src_window_id = ImHashStr(src_window_name);
- src_windows.push_back(src_window_id);
-
- // Search in the remapping tables
- ImGuiID src_dock_id = 0;
- if (ImGuiWindow* src_window = FindWindowByID(src_window_id))
- src_dock_id = src_window->DockId;
- else if (ImGuiWindowSettings* src_window_settings = FindWindowSettings(src_window_id))
- src_dock_id = src_window_settings->DockId;
- ImGuiID dst_dock_id = 0;
- for (int dock_remap_n = 0; dock_remap_n < node_remap_pairs.Size; dock_remap_n += 2)
- if (node_remap_pairs[dock_remap_n] == src_dock_id)
- {
- dst_dock_id = node_remap_pairs[dock_remap_n + 1];
- //node_remap_pairs[dock_remap_n] = node_remap_pairs[dock_remap_n + 1] = 0; // Clear
- break;
- }
-
- if (dst_dock_id != 0)
- {
- // Docked windows gets redocked into the new node hierarchy.
- IMGUI_DEBUG_LOG_DOCKING("Remap live window '%s' 0x%08X -> '%s' 0x%08X\n", src_window_name, src_dock_id, dst_window_name, dst_dock_id);
- DockBuilderDockWindow(dst_window_name, dst_dock_id);
- }
- else
- {
- // Floating windows gets their settings transferred (regardless of whether the new window already exist or not)
- // When this is leading to a Copy and not a Move, we would get two overlapping floating windows. Could we possibly dock them together?
- IMGUI_DEBUG_LOG_DOCKING("Remap window settings '%s' -> '%s'\n", src_window_name, dst_window_name);
- DockBuilderCopyWindowSettings(src_window_name, dst_window_name);
- }
+ IM_ASSERT(0);
+ return;
}
- // Anything else in the source nodes of 'node_remap_pairs' are windows that were docked in src_dockspace_id but are not owned by it (unaffiliated windows, e.g. "ImGui Demo")
- // Find those windows and move to them to the cloned dock node. This may be optional?
- for (int dock_remap_n = 0; dock_remap_n < node_remap_pairs.Size; dock_remap_n += 2)
- if (ImGuiID src_dock_id = node_remap_pairs[dock_remap_n])
- {
- ImGuiID dst_dock_id = node_remap_pairs[dock_remap_n + 1];
- ImGuiDockNode* node = DockBuilderGetNode(src_dock_id);
- for (int window_n = 0; window_n < node->Windows.Size; window_n++)
- {
- ImGuiWindow* window = node->Windows[window_n];
- if (src_windows.contains(window->ID))
- continue;
-
- // Docked windows gets redocked into the new node hierarchy.
- IMGUI_DEBUG_LOG_DOCKING("Remap window '%s' %08X -> %08X\n", window->Name, src_dock_id, dst_dock_id);
- DockBuilderDockWindow(window->Name, dst_dock_id);
- }
- }
+ LogBegin(ImGuiLogType_File, auto_open_depth);
+ g.LogFile = f;
}
-void ImGui::DockBuilderFinish(ImGuiID root_id)
+// Start logging/capturing text output to clipboard
+void ImGui::LogToClipboard(int auto_open_depth)
{
- ImGuiContext* ctx = GImGui;
- //DockContextRebuild(ctx);
- DockContextBuildAddWindowsToNodes(ctx, root_id);
+ ImGuiContext& g = *GImGui;
+ if (g.LogEnabled)
+ return;
+ LogBegin(ImGuiLogType_Clipboard, auto_open_depth);
}
-//-----------------------------------------------------------------------------
-// Docking: Begin/End Support Functions (called from Begin/End)
-//-----------------------------------------------------------------------------
-// - GetWindowAlwaysWantOwnTabBar()
-// - BeginDocked()
-// - BeginAsDockableDragDropSource()
-// - BeginAsDockableDragDropTarget()
-//-----------------------------------------------------------------------------
-
-bool ImGui::GetWindowAlwaysWantOwnTabBar(ImGuiWindow* window)
+void ImGui::LogToBuffer(int auto_open_depth)
{
ImGuiContext& g = *GImGui;
- if (g.IO.ConfigDockingAlwaysTabBar || window->WindowClass.DockingAlwaysTabBar)
- if ((window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDocking)) == 0)
- if (!window->IsFallbackWindow) // We don't support AlwaysTabBar on the fallback/implicit window to avoid unused dock-node overhead/noise
- return true;
- return false;
+ if (g.LogEnabled)
+ return;
+ LogBegin(ImGuiLogType_Buffer, auto_open_depth);
}
-static ImGuiDockNode* ImGui::DockContextBindNodeToWindow(ImGuiContext* ctx, ImGuiWindow* window)
+void ImGui::LogFinish()
{
- ImGuiContext& g = *ctx;
- ImGuiDockNode* node = DockContextFindNodeByID(ctx, window->DockId);
- IM_ASSERT(window->DockNode == NULL);
-
- // We should not be docking into a split node (SetWindowDock should avoid this)
- if (node && node->IsSplitNode())
- {
- DockContextProcessUndockWindow(ctx, window);
- return NULL;
- }
-
- // Create node
- if (node == NULL)
- {
- node = DockContextAddNode(ctx, window->DockId);
- node->AuthorityForPos = node->AuthorityForSize = node->AuthorityForViewport = ImGuiDataAuthority_Window;
- node->LastFrameAlive = g.FrameCount;
- }
+ ImGuiContext& g = *GImGui;
+ if (!g.LogEnabled)
+ return;
- // If the node just turned visible and is part of a hierarchy, it doesn't have a Size assigned by DockNodeTreeUpdatePosSize() yet,
- // so we're forcing a Pos/Size update from the first ancestor that is already visible (often it will be the root node).
- // If we don't do this, the window will be assigned a zero-size on its first frame, which won't ideally warm up the layout.
- // This is a little wonky because we don't normally update the Pos/Size of visible node mid-frame.
- if (!node->IsVisible)
+ LogText(IM_NEWLINE);
+ switch (g.LogType)
{
- ImGuiDockNode* ancestor_node = node;
- while (!ancestor_node->IsVisible)
- {
- ancestor_node->IsVisible = true;
- ancestor_node->MarkedForPosSizeWrite = true;
- if (ancestor_node->ParentNode)
- ancestor_node = ancestor_node->ParentNode;
- }
- IM_ASSERT(ancestor_node->Size.x > 0.0f && ancestor_node->Size.y > 0.0f);
- DockNodeTreeUpdatePosSize(ancestor_node, ancestor_node->Pos, ancestor_node->Size, true);
+ case ImGuiLogType_TTY:
+#ifndef IMGUI_DISABLE_TTY_FUNCTIONS
+ fflush(g.LogFile);
+#endif
+ break;
+ case ImGuiLogType_File:
+ ImFileClose(g.LogFile);
+ break;
+ case ImGuiLogType_Buffer:
+ break;
+ case ImGuiLogType_Clipboard:
+ if (!g.LogBuffer.empty())
+ SetClipboardText(g.LogBuffer.begin());
+ break;
+ case ImGuiLogType_None:
+ IM_ASSERT(0);
+ break;
}
- // Add window to node
- DockNodeAddWindow(node, window, true);
- IM_ASSERT(node == window->DockNode);
- return node;
+ g.LogEnabled = false;
+ g.LogType = ImGuiLogType_None;
+ g.LogFile = NULL;
+ g.LogBuffer.clear();
}
-void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open)
+// Helper to display logging buttons
+// FIXME-OBSOLETE: We should probably obsolete this and let the user have their own helper (this is one of the oldest function alive!)
+void ImGui::LogButtons()
{
- ImGuiContext* ctx = GImGui;
- ImGuiContext& g = *ctx;
+ ImGuiContext& g = *GImGui;
- const bool auto_dock_node = GetWindowAlwaysWantOwnTabBar(window);
- if (auto_dock_node)
- {
- if (window->DockId == 0)
- {
- IM_ASSERT(window->DockNode == NULL);
- window->DockId = DockContextGenNodeID(ctx);
- }
- }
- else
- {
- // Calling SetNextWindowPos() undock windows by default (by setting PosUndock)
- bool want_undock = false;
- want_undock |= (window->Flags & ImGuiWindowFlags_NoDocking) != 0;
- want_undock |= (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) && (window->SetWindowPosAllowFlags & g.NextWindowData.PosCond) && g.NextWindowData.PosUndock;
- if (want_undock)
- {
- DockContextProcessUndockWindow(ctx, window);
- return;
- }
- }
+ PushID("LogButtons");
+#ifndef IMGUI_DISABLE_TTY_FUNCTIONS
+ const bool log_to_tty = Button("Log To TTY"); SameLine();
+#else
+ const bool log_to_tty = false;
+#endif
+ const bool log_to_file = Button("Log To File"); SameLine();
+ const bool log_to_clipboard = Button("Log To Clipboard"); SameLine();
+ PushAllowKeyboardFocus(false);
+ SetNextItemWidth(80.0f);
+ SliderInt("Default Depth", &g.LogDepthToExpandDefault, 0, 9, NULL);
+ PopAllowKeyboardFocus();
+ PopID();
- // Bind to our dock node
- ImGuiDockNode* node = window->DockNode;
- if (node != NULL)
- IM_ASSERT(window->DockId == node->ID);
- if (window->DockId != 0 && node == NULL)
- {
- node = DockContextBindNodeToWindow(ctx, window);
- if (node == NULL)
- return;
- }
+ // Start logging at the end of the function so that the buttons don't appear in the log
+ if (log_to_tty)
+ LogToTTY();
+ if (log_to_file)
+ LogToFile();
+ if (log_to_clipboard)
+ LogToClipboard();
+}
-#if 0
- // Undock if the ImGuiDockNodeFlags_NoDockingInCentralNode got set
- if (node->IsCentralNode && (node->Flags & ImGuiDockNodeFlags_NoDockingInCentralNode))
+//-----------------------------------------------------------------------------
+// [SECTION] SETTINGS
+//-----------------------------------------------------------------------------
+
+// Called by NewFrame()
+void ImGui::UpdateSettings()
+{
+ // Load settings on first frame (if not explicitly loaded manually before)
+ ImGuiContext& g = *GImGui;
+ if (!g.SettingsLoaded)
{
- DockContextProcessUndockWindow(ctx, window);
- return;
+ IM_ASSERT(g.SettingsWindows.empty());
+ if (g.IO.IniFilename)
+ LoadIniSettingsFromDisk(g.IO.IniFilename);
+ g.SettingsLoaded = true;
}
-#endif
- // Undock if our dockspace node disappeared
- // Note how we are testing for LastFrameAlive and NOT LastFrameActive. A DockSpace node can be maintained alive while being inactive with ImGuiDockNodeFlags_KeepAliveOnly.
- if (node->LastFrameAlive < g.FrameCount)
+ // Save settings (with a delay after the last modification, so we don't spam disk too much)
+ if (g.SettingsDirtyTimer > 0.0f)
{
- // If the window has been orphaned, transition the docknode to an implicit node processed in DockContextUpdateDocking()
- ImGuiDockNode* root_node = DockNodeGetRootNode(node);
- if (root_node->LastFrameAlive < g.FrameCount)
- {
- DockContextProcessUndockWindow(ctx, window);
- }
- else
+ g.SettingsDirtyTimer -= g.IO.DeltaTime;
+ if (g.SettingsDirtyTimer <= 0.0f)
{
- window->DockIsActive = true;
- window->DockTabIsVisible = false;
+ if (g.IO.IniFilename != NULL)
+ SaveIniSettingsToDisk(g.IO.IniFilename);
+ else
+ g.IO.WantSaveIniSettings = true; // Let user know they can call SaveIniSettingsToMemory(). user will need to clear io.WantSaveIniSettings themselves.
+ g.SettingsDirtyTimer = 0.0f;
}
- return;
}
+}
- // Fast path return. It is common for windows to hold on a persistent DockId but be the only visible window,
- // and never create neither a host window neither a tab bar.
- // FIXME-DOCK: replace ->HostWindow NULL compare with something more explicit (~was initially intended as a first frame test)
- if (node->HostWindow == NULL)
- {
- window->DockIsActive = (node->State == ImGuiDockNodeState_HostWindowHiddenBecauseWindowsAreResizing);
- window->DockTabIsVisible = false;
- return;
- }
+void ImGui::MarkIniSettingsDirty()
+{
+ ImGuiContext& g = *GImGui;
+ if (g.SettingsDirtyTimer <= 0.0f)
+ g.SettingsDirtyTimer = g.IO.IniSavingRate;
+}
- IM_ASSERT(node->HostWindow);
- IM_ASSERT(node->IsLeafNode());
- IM_ASSERT(node->Size.x > 0.0f && node->Size.y > 0.0f);
- node->State = ImGuiDockNodeState_HostWindowVisible;
+void ImGui::MarkIniSettingsDirty(ImGuiWindow* window)
+{
+ ImGuiContext& g = *GImGui;
+ if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings))
+ if (g.SettingsDirtyTimer <= 0.0f)
+ g.SettingsDirtyTimer = g.IO.IniSavingRate;
+}
- // Undock if we are submitted earlier than the host window
- if (window->BeginOrderWithinContext < node->HostWindow->BeginOrderWithinContext)
- {
- DockContextProcessUndockWindow(ctx, window);
- return;
- }
+ImGuiWindowSettings* ImGui::CreateNewWindowSettings(const char* name)
+{
+ ImGuiContext& g = *GImGui;
- // Position window
- SetNextWindowPos(node->Pos);
- SetNextWindowSize(node->Size);
- g.NextWindowData.PosUndock = false; // Cancel implicit undocking of SetNextWindowPos()
- window->DockIsActive = true;
- window->DockTabIsVisible = false;
- if (node->SharedFlags & ImGuiDockNodeFlags_KeepAliveOnly)
- return;
+#if !IMGUI_DEBUG_INI_SETTINGS
+ // Skip to the "###" marker if any. We don't skip past to match the behavior of GetID()
+ // Preserve the full string when IMGUI_DEBUG_INI_SETTINGS is set to make .ini inspection easier.
+ if (const char* p = strstr(name, "###"))
+ name = p;
+#endif
+ const size_t name_len = strlen(name);
- // When the window is selected we mark it as visible.
- if (node->VisibleWindow == window)
- window->DockTabIsVisible = true;
+ // Allocate chunk
+ const size_t chunk_size = sizeof(ImGuiWindowSettings) + name_len + 1;
+ ImGuiWindowSettings* settings = g.SettingsWindows.alloc_chunk(chunk_size);
+ IM_PLACEMENT_NEW(settings) ImGuiWindowSettings();
+ settings->ID = ImHashStr(name, name_len);
+ memcpy(settings->GetName(), name, name_len + 1); // Store with zero terminator
- // Update window flag
- IM_ASSERT((window->Flags & ImGuiWindowFlags_ChildWindow) == 0);
- window->Flags |= ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_NoResize;
- if (node->IsHiddenTabBar() || node->IsNoTabBar())
- window->Flags |= ImGuiWindowFlags_NoTitleBar;
- else
- window->Flags &= ~ImGuiWindowFlags_NoTitleBar; // Clear the NoTitleBar flag in case the user set it: confusingly enough we need a title bar height so we are correctly offset, but it won't be displayed!
+ return settings;
+}
- // Save new dock order only if the tab bar has been visible once.
- // This allows multiple windows to be created in the same frame and have their respective dock orders preserved.
- if (node->TabBar && node->TabBar->CurrFrameVisible != -1)
- window->DockOrder = (short)DockNodeGetTabOrder(window);
+ImGuiWindowSettings* ImGui::FindWindowSettings(ImGuiID id)
+{
+ ImGuiContext& g = *GImGui;
+ for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings))
+ if (settings->ID == id)
+ return settings;
+ return NULL;
+}
- if ((node->WantCloseAll || node->WantCloseTabID == window->ID) && p_open != NULL)
- *p_open = false;
+ImGuiWindowSettings* ImGui::FindOrCreateWindowSettings(const char* name)
+{
+ if (ImGuiWindowSettings* settings = FindWindowSettings(ImHashStr(name)))
+ return settings;
+ return CreateNewWindowSettings(name);
+}
- // Update ChildId to allow returning from Child to Parent with Escape
- ImGuiWindow* parent_window = window->DockNode->HostWindow;
- window->ChildId = parent_window->GetID(window->Name);
+void ImGui::LoadIniSettingsFromDisk(const char* ini_filename)
+{
+ size_t file_data_size = 0;
+ char* file_data = (char*)ImFileLoadToMemory(ini_filename, "rb", &file_data_size);
+ if (!file_data)
+ return;
+ LoadIniSettingsFromMemory(file_data, (size_t)file_data_size);
+ IM_FREE(file_data);
}
-void ImGui::BeginAsDockableDragDropSource(ImGuiWindow* window)
+ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name)
{
ImGuiContext& g = *GImGui;
- IM_ASSERT(g.ActiveId == window->MoveId);
-
- window->DC.LastItemId = window->MoveId;
- window = window->RootWindow;
- IM_ASSERT((window->Flags & ImGuiWindowFlags_NoDocking) == 0);
- bool is_drag_docking = (g.IO.ConfigDockingWithShift) || ImRect(0, 0, window->SizeFull.x, GetFrameHeight()).Contains(g.ActiveIdClickOffset);
- if (is_drag_docking && BeginDragDropSource(ImGuiDragDropFlags_SourceNoPreviewTooltip | ImGuiDragDropFlags_SourceNoHoldToOpenOthers | ImGuiDragDropFlags_SourceAutoExpirePayload))
- {
- SetDragDropPayload(IMGUI_PAYLOAD_TYPE_WINDOW, &window, sizeof(window));
- EndDragDropSource();
- }
+ const ImGuiID type_hash = ImHashStr(type_name);
+ for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
+ if (g.SettingsHandlers[handler_n].TypeHash == type_hash)
+ return &g.SettingsHandlers[handler_n];
+ return NULL;
}
-void ImGui::BeginAsDockableDragDropTarget(ImGuiWindow* window)
+// Zero-tolerance, no error reporting, cheap .ini parsing
+void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
{
- ImGuiContext* ctx = GImGui;
- ImGuiContext& g = *ctx;
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(g.Initialized);
+ IM_ASSERT(g.SettingsLoaded == false && g.FrameCount == 0);
- //IM_ASSERT(window->RootWindow == window); // May also be a DockSpace
- IM_ASSERT((window->Flags & ImGuiWindowFlags_NoDocking) == 0);
- if (!g.DragDropActive)
- return;
- if (!BeginDragDropTargetCustom(window->Rect(), window->ID))
- return;
+ // For user convenience, we allow passing a non zero-terminated string (hence the ini_size parameter).
+ // For our convenience and to make the code simpler, we'll also write zero-terminators within the buffer. So let's create a writable copy..
+ if (ini_size == 0)
+ ini_size = strlen(ini_data);
+ char* buf = (char*)IM_ALLOC(ini_size + 1);
+ char* buf_end = buf + ini_size;
+ memcpy(buf, ini_data, ini_size);
+ buf[ini_size] = 0;
- // Peek into the payload before calling AcceptDragDropPayload() so we can handle overlapping dock nodes with filtering
- // (this is a little unusual pattern, normally most code would call AcceptDragDropPayload directly)
- const ImGuiPayload* payload = &g.DragDropPayload;
- if (!payload->IsDataType(IMGUI_PAYLOAD_TYPE_WINDOW) || !DockNodeIsDropAllowed(window, *(ImGuiWindow**)payload->Data))
- {
- EndDragDropTarget();
- return;
- }
+ void* entry_data = NULL;
+ ImGuiSettingsHandler* entry_handler = NULL;
- ImGuiWindow* payload_window = *(ImGuiWindow**)payload->Data;
- if (AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_WINDOW, ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect))
+ char* line_end = NULL;
+ for (char* line = buf; line < buf_end; line = line_end + 1)
{
- // Select target node
- ImGuiDockNode* node = NULL;
- bool allow_null_target_node = false;
- if (window->DockNodeAsHost)
- node = DockNodeTreeFindNodeByPos(window->DockNodeAsHost, g.IO.MousePos);
- else if (window->DockNode) // && window->DockIsActive)
- node = window->DockNode;
- else
- allow_null_target_node = true; // Dock into a regular window
-
- const ImRect explicit_target_rect = (node && node->TabBar && !node->IsHiddenTabBar() && !node->IsNoTabBar()) ? node->TabBar->BarRect : ImRect(window->Pos, window->Pos + ImVec2(window->Size.x, GetFrameHeight()));
- const bool is_explicit_target = g.IO.ConfigDockingWithShift || IsMouseHoveringRect(explicit_target_rect.Min, explicit_target_rect.Max);
-
- // Preview docking request and find out split direction/ratio
- //const bool do_preview = true; // Ignore testing for payload->IsPreview() which removes one frame of delay, but breaks overlapping drop targets within the same window.
- const bool do_preview = payload->IsPreview() || payload->IsDelivery();
- if (do_preview && (node != NULL || allow_null_target_node))
+ // Skip new lines markers, then find end of the line
+ while (*line == '\n' || *line == '\r')
+ line++;
+ line_end = line;
+ while (line_end < buf_end && *line_end != '\n' && *line_end != '\r')
+ line_end++;
+ line_end[0] = 0;
+ if (line[0] == ';')
+ continue;
+ if (line[0] == '[' && line_end > line && line_end[-1] == ']')
{
- ImGuiDockPreviewData split_inner, split_outer;
- ImGuiDockPreviewData* split_data = &split_inner;
- if (node && (node->ParentNode || node->IsCentralNode()))
- if (ImGuiDockNode* root_node = DockNodeGetRootNode(node))
- {
- DockNodePreviewDockCalc(window, root_node, payload_window, &split_outer, is_explicit_target, true);
- if (split_outer.IsSplitDirExplicit)
- split_data = &split_outer;
- }
- DockNodePreviewDockCalc(window, node, payload_window, &split_inner, is_explicit_target, false);
- if (split_data == &split_outer)
- split_inner.IsDropAllowed = false;
-
- // Draw inner then outer, so that previewed tab (in inner data) will be behind the outer drop boxes
- DockNodePreviewDockRender(window, node, payload_window, &split_inner);
- DockNodePreviewDockRender(window, node, payload_window, &split_outer);
-
- // Queue docking request
- if (split_data->IsDropAllowed && payload->IsDelivery())
- DockContextQueueDock(ctx, window, split_data->SplitNode, payload_window, split_data->SplitDir, split_data->SplitRatio, split_data == &split_outer);
+ // Parse "[Type][Name]". Note that 'Name' can itself contains [] characters, which is acceptable with the current format and parsing code.
+ line_end[-1] = 0;
+ const char* name_end = line_end - 1;
+ const char* type_start = line + 1;
+ char* type_end = (char*)(void*)ImStrchrRange(type_start, name_end, ']');
+ const char* name_start = type_end ? ImStrchrRange(type_end + 1, name_end, '[') : NULL;
+ if (!type_end || !name_start)
+ continue;
+ *type_end = 0; // Overwrite first ']'
+ name_start++; // Skip second '['
+ entry_handler = FindSettingsHandler(type_start);
+ entry_data = entry_handler ? entry_handler->ReadOpenFn(&g, entry_handler, name_start) : NULL;
+ }
+ else if (entry_handler != NULL && entry_data != NULL)
+ {
+ // Let type handler parse the line
+ entry_handler->ReadLineFn(&g, entry_handler, entry_data, line);
}
}
- EndDragDropTarget();
+ IM_FREE(buf);
+ g.SettingsLoaded = true;
}
-//-----------------------------------------------------------------------------
-// Docking: Settings
-//-----------------------------------------------------------------------------
-// - DockSettingsRenameNodeReferences()
-// - DockSettingsRemoveNodeReferences()
-// - DockSettingsFindNodeSettings()
-// - DockSettingsHandler_ReadOpen()
-// - DockSettingsHandler_ReadLine()
-// - DockSettingsHandler_DockNodeToSettings()
-// - DockSettingsHandler_WriteAll()
-//-----------------------------------------------------------------------------
-
-static void ImGui::DockSettingsRenameNodeReferences(ImGuiID old_node_id, ImGuiID new_node_id)
+void ImGui::SaveIniSettingsToDisk(const char* ini_filename)
{
ImGuiContext& g = *GImGui;
- IMGUI_DEBUG_LOG_DOCKING("DockSettingsRenameNodeReferences: from 0x%08X -> to 0x%08X\n", old_node_id, new_node_id);
- for (int window_n = 0; window_n < g.Windows.Size; window_n++)
- {
- ImGuiWindow* window = g.Windows[window_n];
- if (window->DockId == old_node_id && window->DockNode == NULL)
- window->DockId = new_node_id;
- }
- for (int settings_n = 0; settings_n < g.SettingsWindows.Size; settings_n++) // FIXME-OPT: We could remove this loop by storing the index in the map
- {
- ImGuiWindowSettings* window_settings = &g.SettingsWindows[settings_n];
- if (window_settings->DockId == old_node_id)
- window_settings->DockId = new_node_id;
- }
+ g.SettingsDirtyTimer = 0.0f;
+ if (!ini_filename)
+ return;
+
+ size_t ini_data_size = 0;
+ const char* ini_data = SaveIniSettingsToMemory(&ini_data_size);
+ ImFileHandle f = ImFileOpen(ini_filename, "wt");
+ if (!f)
+ return;
+ ImFileWrite(ini_data, sizeof(char), ini_data_size, f);
+ ImFileClose(f);
}
-// Remove references stored in ImGuiWindowSettings to the given ImGuiDockNodeSettings
-static void ImGui::DockSettingsRemoveNodeReferences(ImGuiID* node_ids, int node_ids_count)
+// Call registered handlers (e.g. SettingsHandlerWindow_WriteAll() + custom handlers) to write their stuff into a text buffer
+const char* ImGui::SaveIniSettingsToMemory(size_t* out_size)
{
ImGuiContext& g = *GImGui;
- int found = 0;
- for (int settings_n = 0; settings_n < g.SettingsWindows.Size; settings_n++) // FIXME-OPT: We could remove this loop by storing the index in the map
+ g.SettingsDirtyTimer = 0.0f;
+ g.SettingsIniData.Buf.resize(0);
+ g.SettingsIniData.Buf.push_back(0);
+ for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
{
- ImGuiWindowSettings* window_settings = &g.SettingsWindows[settings_n];
- for (int node_n = 0; node_n < node_ids_count; node_n++)
- if (window_settings->DockId == node_ids[node_n])
- {
- window_settings->DockId = 0;
- window_settings->DockOrder = -1;
- if (++found < node_ids_count)
- break;
- return;
- }
+ ImGuiSettingsHandler* handler = &g.SettingsHandlers[handler_n];
+ handler->WriteAllFn(&g, handler, &g.SettingsIniData);
}
+ if (out_size)
+ *out_size = (size_t)g.SettingsIniData.size();
+ return g.SettingsIniData.c_str();
}
-static ImGuiDockNodeSettings* ImGui::DockSettingsFindNodeSettings(ImGuiContext* ctx, ImGuiID id)
+static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
{
- // FIXME-OPT
- ImGuiDockContext* dc = ctx->DockContext;
- for (int n = 0; n < dc->SettingsNodes.Size; n++)
- if (dc->SettingsNodes[n].ID == id)
- return &dc->SettingsNodes[n];
- return NULL;
+ ImGuiWindowSettings* settings = ImGui::FindWindowSettings(ImHashStr(name));
+ if (!settings)
+ settings = ImGui::CreateNewWindowSettings(name);
+ return (void*)settings;
}
-static void* ImGui::DockSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
+static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line)
{
- if (strcmp(name, "Data") != 0)
- return NULL;
- return (void*)1;
+ ImGuiWindowSettings* settings = (ImGuiWindowSettings*)entry;
+ int x, y;
+ int i;
+ if (sscanf(line, "Pos=%i,%i", &x, &y) == 2) settings->Pos = ImVec2ih((short)x, (short)y);
+ else if (sscanf(line, "Size=%i,%i", &x, &y) == 2) settings->Size = ImVec2ih((short)x, (short)y);
+ else if (sscanf(line, "Collapsed=%d", &i) == 1) settings->Collapsed = (i != 0);
}
-static void ImGui::DockSettingsHandler_ReadLine(ImGuiContext* ctx, ImGuiSettingsHandler*, void*, const char* line)
-{
- char c = 0;
- int x = 0, y = 0;
- int r = 0;
-
- // Parsing, e.g.
- // " DockNode ID=0x00000001 Pos=383,193 Size=201,322 Split=Y,0.506 "
- // " DockNode ID=0x00000002 Parent=0x00000001 "
- // Important: this code expect currently fields in a fixed order.
- ImGuiDockNodeSettings node;
- line = ImStrSkipBlank(line);
- if (strncmp(line, "DockNode", 8) == 0) { line = ImStrSkipBlank(line + strlen("DockNode")); }
- else if (strncmp(line, "DockSpace", 9) == 0) { line = ImStrSkipBlank(line + strlen("DockSpace")); node.Flags |= ImGuiDockNodeFlags_DockSpace; }
- else return;
- if (sscanf(line, "ID=0x%08X%n", &node.ID, &r) == 1) { line += r; } else return;
- if (sscanf(line, " Parent=0x%08X%n", &node.ParentNodeID, &r) == 1) { line += r; if (node.ParentNodeID == 0) return; }
- if (sscanf(line, " Window=0x%08X%n", &node.ParentWindowID, &r) ==1) { line += r; if (node.ParentWindowID == 0) return; }
- if (node.ParentNodeID == 0)
- {
- if (sscanf(line, " Pos=%i,%i%n", &x, &y, &r) == 2) { line += r; node.Pos = ImVec2ih((short)x, (short)y); } else return;
- if (sscanf(line, " Size=%i,%i%n", &x, &y, &r) == 2) { line += r; node.Size = ImVec2ih((short)x, (short)y); } else return;
- }
- else
- {
- if (sscanf(line, " SizeRef=%i,%i%n", &x, &y, &r) == 2) { line += r; node.SizeRef = ImVec2ih((short)x, (short)y); }
- }
- if (sscanf(line, " Split=%c%n", &c, &r) == 1) { line += r; if (c == 'X') node.SplitAxis = ImGuiAxis_X; else if (c == 'Y') node.SplitAxis = ImGuiAxis_Y; }
- if (sscanf(line, " NoResize=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_NoResize; }
- if (sscanf(line, " CentralNode=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_CentralNode; }
- if (sscanf(line, " NoTabBar=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_NoTabBar; }
- if (sscanf(line, " HiddenTabBar=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_HiddenTabBar; }
- if (sscanf(line, " NoWindowMenuButton=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_NoWindowMenuButton; }
- if (sscanf(line, " NoCloseButton=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_NoCloseButton; }
- if (sscanf(line, " Selected=0x%08X%n", &node.SelectedWindowID,&r) == 1) { line += r; }
- ImGuiDockContext* dc = ctx->DockContext;
- if (node.ParentNodeID != 0)
- if (ImGuiDockNodeSettings* parent_settings = DockSettingsFindNodeSettings(ctx, node.ParentNodeID))
- node.Depth = parent_settings->Depth + 1;
- dc->SettingsNodes.push_back(node);
-}
-
-static void DockSettingsHandler_DockNodeToSettings(ImGuiDockContext* dc, ImGuiDockNode* node, int depth)
-{
- ImGuiDockNodeSettings node_settings;
- IM_ASSERT(depth < (1 << (sizeof(node_settings.Depth) << 3)));
- node_settings.ID = node->ID;
- node_settings.ParentNodeID = node->ParentNode ? node->ParentNode->ID : 0;
- node_settings.ParentWindowID = (node->IsDockSpace() && node->HostWindow && node->HostWindow->ParentWindow) ? node->HostWindow->ParentWindow->ID : 0;
- node_settings.SelectedWindowID = node->SelectedTabID;
- node_settings.SplitAxis = node->IsSplitNode() ? (char)node->SplitAxis : ImGuiAxis_None;
- node_settings.Depth = (char)depth;
- node_settings.Flags = (node->LocalFlags & ImGuiDockNodeFlags_SavedFlagsMask_);
- node_settings.Pos = ImVec2ih(node->Pos);
- node_settings.Size = ImVec2ih(node->Size);
- node_settings.SizeRef = ImVec2ih(node->SizeRef);
- dc->SettingsNodes.push_back(node_settings);
- if (node->ChildNodes[0])
- DockSettingsHandler_DockNodeToSettings(dc, node->ChildNodes[0], depth + 1);
- if (node->ChildNodes[1])
- DockSettingsHandler_DockNodeToSettings(dc, node->ChildNodes[1], depth + 1);
-}
-
-static void ImGui::DockSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf)
+static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf)
{
+ // Gather data from windows that were active during this session
+ // (if a window wasn't opened in this session we preserve its settings)
ImGuiContext& g = *ctx;
- ImGuiDockContext* dc = g.DockContext;
- if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable))
- return;
-
- // Gather settings data
- // (unlike our windows settings, because nodes are always built we can do a full rewrite of the SettingsNode buffer)
- dc->SettingsNodes.resize(0);
- dc->SettingsNodes.reserve(dc->Nodes.Data.Size);
- for (int n = 0; n < dc->Nodes.Data.Size; n++)
- if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
- if (node->IsRootNode())
- DockSettingsHandler_DockNodeToSettings(dc, node, 0);
+ for (int i = 0; i != g.Windows.Size; i++)
+ {
+ ImGuiWindow* window = g.Windows[i];
+ if (window->Flags & ImGuiWindowFlags_NoSavedSettings)
+ continue;
- int max_depth = 0;
- for (int node_n = 0; node_n < dc->SettingsNodes.Size; node_n++)
- max_depth = ImMax((int)dc->SettingsNodes[node_n].Depth, max_depth);
+ ImGuiWindowSettings* settings = (window->SettingsOffset != -1) ? g.SettingsWindows.ptr_from_offset(window->SettingsOffset) : ImGui::FindWindowSettings(window->ID);
+ if (!settings)
+ {
+ settings = ImGui::CreateNewWindowSettings(window->Name);
+ window->SettingsOffset = g.SettingsWindows.offset_from_ptr(settings);
+ }
+ IM_ASSERT(settings->ID == window->ID);
+ settings->Pos = ImVec2ih((short)window->Pos.x, (short)window->Pos.y);
+ settings->Size = ImVec2ih((short)window->SizeFull.x, (short)window->SizeFull.y);
+ settings->Collapsed = window->Collapsed;
+ }
// Write to text buffer
- buf->appendf("[%s][Data]\n", handler->TypeName);
- for (int node_n = 0; node_n < dc->SettingsNodes.Size; node_n++)
+ buf->reserve(buf->size() + g.SettingsWindows.size() * 6); // ballpark reserve
+ for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings))
{
- const int line_start_pos = buf->size(); (void)line_start_pos;
- const ImGuiDockNodeSettings* node_settings = &dc->SettingsNodes[node_n];
- buf->appendf("%*s%s%*s", node_settings->Depth * 2, "", (node_settings->Flags & ImGuiDockNodeFlags_DockSpace) ? "DockSpace" : "DockNode ", (max_depth - node_settings->Depth) * 2, ""); // Text align nodes to facilitate looking at .ini file
- buf->appendf(" ID=0x%08X", node_settings->ID);
- if (node_settings->ParentNodeID)
- {
- buf->appendf(" Parent=0x%08X SizeRef=%d,%d", node_settings->ParentNodeID, node_settings->SizeRef.x, node_settings->SizeRef.y);
- }
- else
- {
- if (node_settings->ParentWindowID)
- buf->appendf(" Window=0x%08X", node_settings->ParentWindowID);
- buf->appendf(" Pos=%d,%d Size=%d,%d", node_settings->Pos.x, node_settings->Pos.y, node_settings->Size.x, node_settings->Size.y);
- }
- if (node_settings->SplitAxis != ImGuiAxis_None)
- buf->appendf(" Split=%c", (node_settings->SplitAxis == ImGuiAxis_X) ? 'X' : 'Y');
- if (node_settings->Flags & ImGuiDockNodeFlags_NoResize)
- buf->appendf(" NoResize=1");
- if (node_settings->Flags & ImGuiDockNodeFlags_CentralNode)
- buf->appendf(" CentralNode=1");
- if (node_settings->Flags & ImGuiDockNodeFlags_NoTabBar)
- buf->appendf(" NoTabBar=1");
- if (node_settings->Flags & ImGuiDockNodeFlags_HiddenTabBar)
- buf->appendf(" HiddenTabBar=1");
- if (node_settings->Flags & ImGuiDockNodeFlags_NoWindowMenuButton)
- buf->appendf(" NoWindowMenuButton=1");
- if (node_settings->Flags & ImGuiDockNodeFlags_NoCloseButton)
- buf->appendf(" NoCloseButton=1");
- if (node_settings->SelectedWindowID)
- buf->appendf(" Selected=0x%08X", node_settings->SelectedWindowID);
-
-#if IMGUI_DEBUG_INI_SETTINGS
- // [DEBUG] Include comments in the .ini file to ease debugging
- if (ImGuiDockNode* node = DockContextFindNodeByID(ctx, node_settings->ID))
- {
- buf->appendf("%*s", ImMax(2, (line_start_pos + 92) - buf->size()), ""); // Align everything
- if (node->IsDockSpace() && node->HostWindow && node->HostWindow->ParentWindow)
- buf->appendf(" ; in '%s'", node->HostWindow->ParentWindow->Name);
- int contains_window = 0;
- for (int window_n = 0; window_n < ctx->SettingsWindows.Size; window_n++) // Iterate settings so we can give info about windows that didn't exist during the session.
- if (ctx->SettingsWindows[window_n].DockId == node_settings->ID)
- {
- if (contains_window++ == 0)
- buf->appendf(" ; contains ");
- buf->appendf("'%s' ", ctx->SettingsWindows[window_n].Name);
- }
- }
-#endif
- buf->appendf("\n");
+ const char* settings_name = settings->GetName();
+ buf->appendf("[%s][%s]\n", handler->TypeName, settings_name);
+ buf->appendf("Pos=%d,%d\n", settings->Pos.x, settings->Pos.y);
+ buf->appendf("Size=%d,%d\n", settings->Size.x, settings->Size.y);
+ buf->appendf("Collapsed=%d\n", settings->Collapsed);
+ buf->append("\n");
}
- buf->appendf("\n");
}
//-----------------------------------------------------------------------------
-// [SECTION] PLATFORM DEPENDENT HELPERS
+// [SECTION] VIEWPORTS, PLATFORM WINDOWS
//-----------------------------------------------------------------------------
-#if defined(_WIN32) && !defined(_WINDOWS_) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && (!defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS) || !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS))
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-#ifndef __MINGW32__
-#include
-#else
-#include
-#endif
-#elif defined(__APPLE__)
-#include
-#endif
+// (this section is filled in the 'docking' branch)
+
+
+//-----------------------------------------------------------------------------
+// [SECTION] DOCKING
+//-----------------------------------------------------------------------------
+
+// (this section is filled in the 'docking' branch)
+
+
+//-----------------------------------------------------------------------------
+// [SECTION] PLATFORM DEPENDENT HELPERS
+//-----------------------------------------------------------------------------
#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS)
#ifdef _MSC_VER
#pragma comment(lib, "user32")
+#pragma comment(lib, "kernel32")
#endif
// Win32 clipboard implementation
+// We use g.ClipboardHandlerData for temporary storage to ensure it is freed on Shutdown()
static const char* GetClipboardTextFn_DefaultImpl(void*)
{
- static ImVector buf_local;
- buf_local.clear();
+ ImGuiContext& g = *GImGui;
+ g.ClipboardHandlerData.clear();
if (!::OpenClipboard(NULL))
return NULL;
HANDLE wbuf_handle = ::GetClipboardData(CF_UNICODETEXT);
@@ -14516,30 +9818,30 @@ static const char* GetClipboardTextFn_DefaultImpl(void*)
::CloseClipboard();
return NULL;
}
- if (ImWchar* wbuf_global = (ImWchar*)::GlobalLock(wbuf_handle))
+ if (const WCHAR* wbuf_global = (const WCHAR*)::GlobalLock(wbuf_handle))
{
- int buf_len = ImTextCountUtf8BytesFromStr(wbuf_global, NULL) + 1;
- buf_local.resize(buf_len);
- ImTextStrToUtf8(buf_local.Data, buf_len, wbuf_global, NULL);
+ int buf_len = ::WideCharToMultiByte(CP_UTF8, 0, wbuf_global, -1, NULL, 0, NULL, NULL);
+ g.ClipboardHandlerData.resize(buf_len);
+ ::WideCharToMultiByte(CP_UTF8, 0, wbuf_global, -1, g.ClipboardHandlerData.Data, buf_len, NULL, NULL);
}
::GlobalUnlock(wbuf_handle);
::CloseClipboard();
- return buf_local.Data;
+ return g.ClipboardHandlerData.Data;
}
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
{
if (!::OpenClipboard(NULL))
return;
- const int wbuf_length = ImTextCountCharsFromUtf8(text, NULL) + 1;
- HGLOBAL wbuf_handle = ::GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)wbuf_length * sizeof(ImWchar));
+ const int wbuf_length = ::MultiByteToWideChar(CP_UTF8, 0, text, -1, NULL, 0);
+ HGLOBAL wbuf_handle = ::GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)wbuf_length * sizeof(WCHAR));
if (wbuf_handle == NULL)
{
::CloseClipboard();
return;
}
- ImWchar* wbuf_global = (ImWchar*)::GlobalLock(wbuf_handle);
- ImTextStrFromUtf8(wbuf_global, wbuf_length, text, NULL);
+ WCHAR* wbuf_global = (WCHAR*)::GlobalLock(wbuf_handle);
+ ::MultiByteToWideChar(CP_UTF8, 0, text, -1, wbuf_global, wbuf_length);
::GlobalUnlock(wbuf_handle);
::EmptyClipboard();
if (::SetClipboardData(CF_UNICODETEXT, wbuf_handle) == NULL)
@@ -14586,13 +9888,14 @@ static const char* GetClipboardTextFn_DefaultImpl(void*)
CFDataRef cf_data;
if (PasteboardCopyItemFlavorData(main_clipboard, item_id, CFSTR("public.utf8-plain-text"), &cf_data) == noErr)
{
- static ImVector clipboard_text;
+ ImGuiContext& g = *GImGui;
+ g.ClipboardHandlerData.clear();
int length = (int)CFDataGetLength(cf_data);
- clipboard_text.resize(length + 1);
- CFDataGetBytes(cf_data, CFRangeMake(0, length), (UInt8*)clipboard_text.Data);
- clipboard_text[length] = 0;
+ g.ClipboardHandlerData.resize(length + 1);
+ CFDataGetBytes(cf_data, CFRangeMake(0, length), (UInt8*)g.ClipboardHandlerData.Data);
+ g.ClipboardHandlerData[length] = 0;
CFRelease(cf_data);
- return clipboard_text.Data;
+ return g.ClipboardHandlerData.Data;
}
}
}
@@ -14605,86 +9908,70 @@ static const char* GetClipboardTextFn_DefaultImpl(void*)
static const char* GetClipboardTextFn_DefaultImpl(void*)
{
ImGuiContext& g = *GImGui;
- return g.PrivateClipboard.empty() ? NULL : g.PrivateClipboard.begin();
+ return g.ClipboardHandlerData.empty() ? NULL : g.ClipboardHandlerData.begin();
}
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
{
ImGuiContext& g = *GImGui;
- g.PrivateClipboard.clear();
+ g.ClipboardHandlerData.clear();
const char* text_end = text + strlen(text);
- g.PrivateClipboard.resize((int)(text_end - text) + 1);
- memcpy(&g.PrivateClipboard[0], text, (size_t)(text_end - text));
- g.PrivateClipboard[(int)(text_end - text)] = 0;
+ g.ClipboardHandlerData.resize((int)(text_end - text) + 1);
+ memcpy(&g.ClipboardHandlerData[0], text, (size_t)(text_end - text));
+ g.ClipboardHandlerData[(int)(text_end - text)] = 0;
}
#endif
-//-----------------------------------------------------------------------------
-// [SECTION] METRICS/DEBUG WINDOW
-//-----------------------------------------------------------------------------
+// Win32 API IME support (for Asian languages, etc.)
+#if defined(_WIN32) && !defined(__GNUC__) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS)
+
+#include
+#ifdef _MSC_VER
+#pragma comment(lib, "imm32")
+#endif
-static void RenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewport, const ImRect& bb)
+static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y)
{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
+ // Notify OS Input Method Editor of text input position
+ ImGuiIO& io = ImGui::GetIO();
+ if (HWND hwnd = (HWND)io.ImeWindowHandle)
+ if (HIMC himc = ::ImmGetContext(hwnd))
+ {
+ COMPOSITIONFORM cf;
+ cf.ptCurrentPos.x = x;
+ cf.ptCurrentPos.y = y;
+ cf.dwStyle = CFS_FORCE_POSITION;
+ ::ImmSetCompositionWindow(himc, &cf);
+ ::ImmReleaseContext(hwnd, himc);
+ }
+}
- ImVec2 scale = bb.GetSize() / viewport->Size;
- ImVec2 off = bb.Min - viewport->Pos * scale;
- float alpha_mul = (viewport->Flags & ImGuiViewportFlags_Minimized) ? 0.30f : 1.00f;
- window->DrawList->AddRectFilled(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_Border, alpha_mul * 0.40f));
- for (int i = 0; i != g.Windows.Size; i++)
- {
- ImGuiWindow* thumb_window = g.Windows[i];
- if (!thumb_window->WasActive || ((thumb_window->Flags & ImGuiWindowFlags_ChildWindow)))
- continue;
- if (thumb_window->SkipItems && (thumb_window->Flags & ImGuiWindowFlags_ChildWindow)) // FIXME-DOCK: Skip hidden docked windows. Identify those betters.
- continue;
- if (thumb_window->Viewport != viewport)
- continue;
+#else
- ImRect thumb_r = thumb_window->Rect();
- ImRect title_r = thumb_window->TitleBarRect();
- ImRect thumb_r_scaled = ImRect(ImFloor(off + thumb_r.Min * scale), ImFloor(off + thumb_r.Max * scale));
- ImRect title_r_scaled = ImRect(ImFloor(off + title_r.Min * scale), ImFloor(off + ImVec2(title_r.Max.x, title_r.Min.y) * scale) + ImVec2(0,5)); // Exaggerate title bar height
- thumb_r_scaled.ClipWithFull(bb);
- title_r_scaled.ClipWithFull(bb);
- const bool window_is_focused = (g.NavWindow && thumb_window->RootWindowForTitleBarHighlight == g.NavWindow->RootWindowForTitleBarHighlight);
- window->DrawList->AddRectFilled(thumb_r_scaled.Min, thumb_r_scaled.Max, ImGui::GetColorU32(ImGuiCol_WindowBg, alpha_mul));
- window->DrawList->AddRectFilled(title_r_scaled.Min, title_r_scaled.Max, ImGui::GetColorU32(window_is_focused ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg, alpha_mul));
- window->DrawList->AddRect(thumb_r_scaled.Min, thumb_r_scaled.Max, ImGui::GetColorU32(ImGuiCol_Border, alpha_mul));
- if (ImGuiWindow* window_for_title = GetWindowForTitleDisplay(thumb_window))
- window->DrawList->AddText(g.Font, g.FontSize * 1.0f, title_r_scaled.Min, ImGui::GetColorU32(ImGuiCol_Text, alpha_mul), window_for_title->Name, ImGui::FindRenderedTextEnd(window_for_title->Name));
- }
- draw_list->AddRect(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_Border, alpha_mul));
-}
+static void ImeSetInputScreenPosFn_DefaultImpl(int, int) {}
-void ImGui::ShowViewportThumbnails()
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
+#endif
+
+//-----------------------------------------------------------------------------
+// [SECTION] METRICS/DEBUG WINDOW
+//-----------------------------------------------------------------------------
- // We don't display full monitor bounds (we could, but it often looks awkward), instead we display just enough to cover all of our viewports.
- float SCALE = 1.0f / 8.0f;
- ImRect bb_full;
- //for (int n = 0; n < g.PlatformIO.Monitors.Size; n++)
- // bb_full.Add(GetPlatformMonitorMainRect(g.PlatformIO.Monitors[n]));
- for (int n = 0; n < g.Viewports.Size; n++)
- bb_full.Add(g.Viewports[n]->GetRect());
- ImVec2 p = window->DC.CursorPos;
- ImVec2 off = p - bb_full.Min * SCALE;
- //for (int n = 0; n < g.PlatformIO.Monitors.Size; n++)
- // window->DrawList->AddRect(off + g.PlatformIO.Monitors[n].MainPos * SCALE, off + (g.PlatformIO.Monitors[n].MainPos + g.PlatformIO.Monitors[n].MainSize) * SCALE, ImGui::GetColorU32(ImGuiCol_Border));
- for (int n = 0; n < g.Viewports.Size; n++)
+#ifndef IMGUI_DISABLE_METRICS_WINDOW
+// Avoid naming collision with imgui_demo.cpp's HelpMarker() for unity builds.
+static void MetricsHelpMarker(const char* desc)
+{
+ ImGui::TextDisabled("(?)");
+ if (ImGui::IsItemHovered())
{
- ImGuiViewportP* viewport = g.Viewports[n];
- ImRect viewport_draw_bb(off + (viewport->Pos) * SCALE, off + (viewport->Pos + viewport->Size) * SCALE);
- RenderViewportThumbnail(window->DrawList, viewport, viewport_draw_bb);
+ ImGui::BeginTooltip();
+ ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
+ ImGui::TextUnformatted(desc);
+ ImGui::PopTextWrapPos();
+ ImGui::EndTooltip();
}
- ImGui::Dummy(bb_full.GetSize() * SCALE);
}
-#ifndef IMGUI_DISABLE_METRICS_WINDOW
void ImGui::ShowMetricsWindow(bool* p_open)
{
if (!ImGui::Begin("Dear ImGui Metrics", p_open))
@@ -14693,14 +9980,20 @@ void ImGui::ShowMetricsWindow(bool* p_open)
return;
}
+ // Debugging enums
+ enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Content, WRT_ContentRegionRect, WRT_Count }; // Windows Rect Type
+ const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Content", "ContentRegionRect" };
+ enum { TRT_OuterRect, TRT_WorkRect, TRT_HostClipRect, TRT_InnerClipRect, TRT_BackgroundClipRect, TRT_ColumnsRect, TRT_ColumnsClipRect, TRT_ColumnsContentHeadersUsed, TRT_ColumnsContentHeadersDesired, TRT_ColumnsContentRowsFrozen, TRT_ColumnsContentRowsUnfrozen, TRT_Count }; // Tables Rect Type
+ const char* trt_rects_names[TRT_Count] = { "OuterRect", "WorkRect", "HostClipRect", "InnerClipRect", "BackgroundClipRect", "ColumnsRect", "ColumnsClipRect", "ColumnsContentHeadersUsed", "ColumnsContentHeadersDesired", "ColumnsContentRowsFrozen", "ColumnsContentRowsUnfrozen" };
+
// State
- enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Contents, WRT_ContentsRegionRect, WRT_Count }; // Windows Rect Type
- const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Contents", "ContentsRegionRect" };
static bool show_windows_rects = false;
static int show_windows_rect_type = WRT_WorkRect;
static bool show_windows_begin_order = false;
- static bool show_drawcmd_clip_rects = true;
- static bool show_docking_nodes = false;
+ static bool show_tables_rects = false;
+ static int show_tables_rect_type = TRT_WorkRect;
+ static bool show_drawcmd_mesh = true;
+ static bool show_drawcmd_aabb = true;
// Basic info
ImGuiContext& g = *GImGui;
@@ -14713,13 +10006,12 @@ void ImGui::ShowMetricsWindow(bool* p_open)
ImGui::Separator();
// Helper functions to display common structures:
- // - NodeDrawList
- // - NodeColumns
- // - NodeWindow
- // - NodeWindows
- // - NodeViewport
- // - NodeDockNode
- // - NodeTabBar
+ // - NodeDrawList()
+ // - NodeColumns()
+ // - NodeWindow()
+ // - NodeWindows()
+ // - NodeTabBar()
+ // - NodeStorage()
struct Funcs
{
static ImRect GetWindowRect(ImGuiWindow* window, int rect_type)
@@ -14729,13 +10021,45 @@ void ImGui::ShowMetricsWindow(bool* p_open)
else if (rect_type == WRT_InnerRect) { return window->InnerRect; }
else if (rect_type == WRT_InnerClipRect) { return window->InnerClipRect; }
else if (rect_type == WRT_WorkRect) { return window->WorkRect; }
- else if (rect_type == WRT_Contents) { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSize); }
- else if (rect_type == WRT_ContentsRegionRect) { return window->ContentsRegionRect; }
+ else if (rect_type == WRT_Content) { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSize); }
+ else if (rect_type == WRT_ContentRegionRect) { return window->ContentRegionRect; }
IM_ASSERT(0);
return ImRect();
}
- static void NodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, ImDrawList* draw_list, const char* label)
+ static void NodeDrawCmdShowMeshAndBoundingBox(ImGuiWindow* window, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, int elem_offset, bool show_mesh, bool show_aabb)
+ {
+ IM_ASSERT(show_mesh || show_aabb);
+ ImDrawList* fg_draw_list = GetForegroundDrawList(window); // Render additional visuals into the top-most draw list
+ ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL;
+
+ // Draw wire-frame version of all triangles
+ ImRect clip_rect = draw_cmd->ClipRect;
+ ImRect vtxs_rect(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
+ ImDrawListFlags backup_flags = fg_draw_list->Flags;
+ fg_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines is more readable for very large and thin triangles.
+ for (unsigned int base_idx = elem_offset; base_idx < (elem_offset + draw_cmd->ElemCount); base_idx += 3)
+ {
+ ImVec2 triangle[3];
+ for (int n = 0; n < 3; n++)
+ {
+ ImVec2 p = draw_list->VtxBuffer[idx_buffer ? idx_buffer[base_idx + n] : (base_idx + n)].pos;
+ triangle[n] = p;
+ vtxs_rect.Add(p);
+ }
+ if (show_mesh)
+ fg_draw_list->AddPolyline(triangle, 3, IM_COL32(255, 255, 0, 255), true, 1.0f); // In yellow: mesh triangles
+ }
+ // Draw bounding boxes
+ if (show_aabb)
+ {
+ fg_draw_list->AddRect(ImFloor(clip_rect.Min), ImFloor(clip_rect.Max), IM_COL32(255, 0, 255, 255)); // In pink: clipping rectangle submitted to GPU
+ fg_draw_list->AddRect(ImFloor(vtxs_rect.Min), ImFloor(vtxs_rect.Max), IM_COL32(0, 255, 255, 255)); // In cyan: bounding box of triangles
+ }
+ fg_draw_list->Flags = backup_flags;
+ }
+
+ static void NodeDrawList(ImGuiWindow* window, ImDrawList* draw_list, const char* label)
{
bool node_open = ImGui::TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->_OwnerName ? draw_list->_OwnerName : "", draw_list->VtxBuffer.Size, draw_list->IdxBuffer.Size, draw_list->CmdBuffer.Size);
if (draw_list == ImGui::GetWindowDrawList())
@@ -14746,16 +10070,16 @@ void ImGui::ShowMetricsWindow(bool* p_open)
return;
}
- ImDrawList* fg_draw_list = viewport ? GetForegroundDrawList(viewport) : NULL; // Render additional visuals into the top-most draw list
- if (window && fg_draw_list && ImGui::IsItemHovered())
+ ImDrawList* fg_draw_list = GetForegroundDrawList(window); // Render additional visuals into the top-most draw list
+ if (window && IsItemHovered())
fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255));
if (!node_open)
return;
if (window && !window->WasActive)
- ImGui::Text("(Note: owning Window is inactive: DrawList is not being rendered!)");
+ ImGui::TextDisabled("Warning: owning Window is inactive. This DrawList is not being rendered!");
- int elem_offset = 0;
+ unsigned int elem_offset = 0;
for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.begin(); pcmd < draw_list->CmdBuffer.end(); elem_offset += pcmd->ElemCount, pcmd++)
{
if (pcmd->UserCallback == NULL && pcmd->ElemCount == 0)
@@ -14765,45 +10089,56 @@ void ImGui::ShowMetricsWindow(bool* p_open)
ImGui::BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData);
continue;
}
+
ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL;
char buf[300];
- ImFormatString(buf, IM_ARRAYSIZE(buf), "Draw %4d triangles, tex 0x%p, clip_rect (%4.0f,%4.0f)-(%4.0f,%4.0f)",
- pcmd->ElemCount/3, (void*)(intptr_t)pcmd->TextureId, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
+ ImFormatString(buf, IM_ARRAYSIZE(buf), "DrawCmd: %4d triangles, Tex 0x%p, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)",
+ pcmd->ElemCount/3, (void*)(intptr_t)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()), "%s", buf);
- if (show_drawcmd_clip_rects && fg_draw_list && ImGui::IsItemHovered())
- {
- ImRect clip_rect = pcmd->ClipRect;
- ImRect vtxs_rect;
- for (int i = elem_offset; i < elem_offset + (int)pcmd->ElemCount; i++)
- vtxs_rect.Add(draw_list->VtxBuffer[idx_buffer ? idx_buffer[i] : i].pos);
- clip_rect.Floor(); fg_draw_list->AddRect(clip_rect.Min, clip_rect.Max, IM_COL32(255,0,255,255));
- vtxs_rect.Floor(); fg_draw_list->AddRect(vtxs_rect.Min, vtxs_rect.Max, IM_COL32(255,255,0,255));
- }
+ if (ImGui::IsItemHovered() && (show_drawcmd_mesh || show_drawcmd_aabb) && fg_draw_list)
+ NodeDrawCmdShowMeshAndBoundingBox(window, draw_list, pcmd, elem_offset, show_drawcmd_mesh, show_drawcmd_aabb);
if (!pcmd_node_open)
continue;
+ // Calculate approximate coverage area (touched pixel count)
+ // This will be in pixels squared as long there's no post-scaling happening to the renderer output.
+ float total_area = 0.0f;
+ for (unsigned int base_idx = elem_offset; base_idx < (elem_offset + pcmd->ElemCount); base_idx += 3)
+ {
+ ImVec2 triangle[3];
+ for (int n = 0; n < 3; n++)
+ triangle[n] = draw_list->VtxBuffer[idx_buffer ? idx_buffer[base_idx + n] : (base_idx + n)].pos;
+ total_area += ImTriangleArea(triangle[0], triangle[1], triangle[2]);
+ }
+
+ // Display vertex information summary. Hover to get all triangles drawn in wire-frame
+ ImFormatString(buf, IM_ARRAYSIZE(buf), "Mesh: ElemCount: %d, VtxOffset: +%d, IdxOffset: +%d, Area: ~%0.f px", pcmd->ElemCount, pcmd->VtxOffset, pcmd->IdxOffset, total_area);
+ ImGui::Selectable(buf);
+ if (ImGui::IsItemHovered() && fg_draw_list)
+ NodeDrawCmdShowMeshAndBoundingBox(window, draw_list, pcmd, elem_offset, true, false);
+
// Display individual triangles/vertices. Hover on to get the corresponding triangle highlighted.
- ImGui::Text("ElemCount: %d, ElemCount/3: %d, VtxOffset: +%d, IdxOffset: +%d", pcmd->ElemCount, pcmd->ElemCount/3, pcmd->VtxOffset, pcmd->IdxOffset);
ImGuiListClipper clipper(pcmd->ElemCount/3); // Manually coarse clip our print out of individual vertices to save CPU, only items that may be visible.
while (clipper.Step())
for (int prim = clipper.DisplayStart, idx_i = elem_offset + clipper.DisplayStart*3; prim < clipper.DisplayEnd; prim++)
{
char *buf_p = buf, *buf_end = buf + IM_ARRAYSIZE(buf);
- ImVec2 triangles_pos[3];
+ ImVec2 triangle[3];
for (int n = 0; n < 3; n++, idx_i++)
{
- int vtx_i = idx_buffer ? idx_buffer[idx_i] : idx_i;
- ImDrawVert& v = draw_list->VtxBuffer[vtx_i];
- triangles_pos[n] = v.pos;
+ ImDrawVert& v = draw_list->VtxBuffer[idx_buffer ? idx_buffer[idx_i] : idx_i];
+ triangle[n] = v.pos;
buf_p += ImFormatString(buf_p, buf_end - buf_p, "%s %04d: pos (%8.2f,%8.2f), uv (%.6f,%.6f), col %08X\n",
- (n == 0) ? "elem" : " ", idx_i, v.pos.x, v.pos.y, v.uv.x, v.uv.y, v.col);
+ (n == 0) ? "Vert:" : " ", idx_i, v.pos.x, v.pos.y, v.uv.x, v.uv.y, v.col);
}
+
ImGui::Selectable(buf, false);
if (fg_draw_list && ImGui::IsItemHovered())
{
ImDrawListFlags backup_flags = fg_draw_list->Flags;
- fg_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines at is more readable for very large and thin triangles.
- fg_draw_list->AddPolyline(triangles_pos, 3, IM_COL32(255,255,0,255), true, 1.0f);
+ fg_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines is more readable for very large and thin triangles.
+ fg_draw_list->AddPolyline(triangle, 3, IM_COL32(255,255,0,255), true, 1.0f);
fg_draw_list->Flags = backup_flags;
}
}
@@ -14822,6 +10157,19 @@ void ImGui::ShowMetricsWindow(bool* p_open)
ImGui::TreePop();
}
+ static void NodeWindows(ImVector& windows, const char* label)
+ {
+ if (!ImGui::TreeNode(label, "%s (%d)", label, windows.Size))
+ return;
+ for (int i = 0; i < windows.Size; i++)
+ {
+ ImGui::PushID(windows[i]);
+ Funcs::NodeWindow(windows[i], "Window");
+ ImGui::PopID();
+ }
+ ImGui::TreePop();
+ }
+
static void NodeWindow(ImGuiWindow* window, const char* label)
{
if (window == NULL)
@@ -14829,17 +10177,25 @@ void ImGui::ShowMetricsWindow(bool* p_open)
ImGui::BulletText("%s: NULL", label);
return;
}
- if (!ImGui::TreeNode(window, "%s '%s', %d @ 0x%p", label, window->Name, (window->Active || window->WasActive), window))
+ bool open = ImGui::TreeNode(label, "%s '%s', %d @ 0x%p", label, window->Name, (window->Active || window->WasActive), window);
+ if (ImGui::IsItemHovered() && window->WasActive)
+ ImGui::GetForegroundDrawList()->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255));
+ if (!open)
return;
+
+ if (!window->WasActive)
+ ImGui::TextDisabled("Note: window is not currently visible.");
+ if (window->MemoryCompacted)
+ ImGui::TextDisabled("Note: some memory buffers have been compacted/freed.");
+
ImGuiWindowFlags flags = window->Flags;
- NodeDrawList(window, window->Viewport, window->DrawList, "DrawList");
+ NodeDrawList(window, window->DrawList, "DrawList");
ImGui::BulletText("Pos: (%.1f,%.1f), Size: (%.1f,%.1f), ContentSize (%.1f,%.1f)", window->Pos.x, window->Pos.y, window->Size.x, window->Size.y, window->ContentSize.x, window->ContentSize.y);
ImGui::BulletText("Flags: 0x%08X (%s%s%s%s%s%s%s%s%s..)", flags,
(flags & ImGuiWindowFlags_ChildWindow) ? "Child " : "", (flags & ImGuiWindowFlags_Tooltip) ? "Tooltip " : "", (flags & ImGuiWindowFlags_Popup) ? "Popup " : "",
(flags & ImGuiWindowFlags_Modal) ? "Modal " : "", (flags & ImGuiWindowFlags_ChildMenu) ? "ChildMenu " : "", (flags & ImGuiWindowFlags_NoSavedSettings) ? "NoSavedSettings " : "",
(flags & ImGuiWindowFlags_NoMouseInputs)? "NoMouseInputs":"", (flags & ImGuiWindowFlags_NoNavInputs) ? "NoNavInputs" : "", (flags & ImGuiWindowFlags_AlwaysAutoResize) ? "AlwaysAutoResize" : "");
- ImGui::BulletText("WindowClassId: 0x%08X", window->WindowClass.ClassId);
- ImGui::BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f)", window->Scroll.x, window->ScrollMax.x, window->Scroll.y, window->ScrollMax.y);
+ ImGui::BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f) Scrollbar:%s%s", window->Scroll.x, window->ScrollMax.x, window->Scroll.y, window->ScrollMax.y, window->ScrollbarX ? "X" : "", window->ScrollbarY ? "Y" : "");
ImGui::BulletText("Active: %d/%d, WriteAccessed: %d, BeginOrderWithinContext: %d", window->Active, window->WasActive, window->WriteAccessed, (window->Active || window->WasActive) ? window->BeginOrderWithinContext : -1);
ImGui::BulletText("Appearing: %d, Hidden: %d (CanSkip %d Cannot %d), SkipItems: %d", window->Appearing, window->Hidden, window->HiddenFramesCanSkipItems, window->HiddenFramesCannotSkipItems, window->SkipItems);
ImGui::BulletText("NavLastIds: 0x%08X,0x%08X, NavLayerActiveMask: %X", window->NavLastIds[0], window->NavLastIds[1], window->DC.NavLayerActiveMask);
@@ -14848,13 +10204,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
ImGui::BulletText("NavRectRel[0]: (%.1f,%.1f)(%.1f,%.1f)", window->NavRectRel[0].Min.x, window->NavRectRel[0].Min.y, window->NavRectRel[0].Max.x, window->NavRectRel[0].Max.y);
else
ImGui::BulletText("NavRectRel[0]: ");
- ImGui::BulletText("Viewport: %d%s, ViewportId: 0x%08X, ViewportPos: (%.1f,%.1f)", window->Viewport ? window->Viewport->Idx : -1, window->ViewportOwned ? " (Owned)" : "", window->ViewportId, window->ViewportPos.x, window->ViewportPos.y);
- ImGui::BulletText("ViewportMonitor: %d", window->Viewport ? window->Viewport->PlatformMonitor : -1);
- ImGui::BulletText("DockId: 0x%04X, DockOrder: %d, Act: %d, Vis: %d", window->DockId, window->DockOrder, window->DockIsActive, window->DockTabIsVisible);
- if (window->DockNode || window->DockNodeAsHost)
- NodeDockNode(window->DockNodeAsHost ? window->DockNodeAsHost : window->DockNode, window->DockNodeAsHost ? "DockNodeAsHost" : "DockNode");
if (window->RootWindow != window) NodeWindow(window->RootWindow, "RootWindow");
- if (window->RootWindowDockStop != window->RootWindow) NodeWindow(window->RootWindowDockStop, "RootWindowDockStop");
if (window->ParentWindow != NULL) NodeWindow(window->ParentWindow, "ParentWindow");
if (window->DC.ChildWindows.Size > 0) NodeWindows(window->DC.ChildWindows, "ChildWindows");
if (window->ColumnsStorage.Size > 0 && ImGui::TreeNode("Columns", "Columns sets (%d)", window->ColumnsStorage.Size))
@@ -14863,95 +10213,17 @@ void ImGui::ShowMetricsWindow(bool* p_open)
NodeColumns(&window->ColumnsStorage[n]);
ImGui::TreePop();
}
- ImGui::BulletText("Storage: %d bytes", window->StateStorage.Data.size_in_bytes());
- ImGui::TreePop();
- }
-
- static void NodeWindows(ImVector& windows, const char* label)
- {
- if (!ImGui::TreeNode(label, "%s (%d)", label, windows.Size))
- return;
- for (int i = 0; i < windows.Size; i++)
- Funcs::NodeWindow(windows[i], "Window");
+ NodeStorage(&window->StateStorage, "Storage");
ImGui::TreePop();
}
- static void NodeViewport(ImGuiViewportP* viewport)
- {
- ImGui::SetNextItemOpen(true, ImGuiCond_Once);
- if (ImGui::TreeNode((void*)(intptr_t)viewport->ID, "Viewport #%d, ID: 0x%08X, Parent: 0x%08X, Window: \"%s\"", viewport->Idx, viewport->ID, viewport->ParentViewportId, viewport->Window ? viewport->Window->Name : "N/A"))
- {
- ImGuiWindowFlags flags = viewport->Flags;
- ImGui::BulletText("Pos: (%.0f,%.0f), Size: (%.0f,%.0f), Monitor: %d, DpiScale: %.0f%%", viewport->Pos.x, viewport->Pos.y, viewport->Size.x, viewport->Size.y, viewport->PlatformMonitor, viewport->DpiScale * 100.0f);
- if (viewport->Idx > 0) { ImGui::SameLine(); if (ImGui::SmallButton("Reset Pos")) { viewport->Pos = ImVec2(200,200); if (viewport->Window) viewport->Window->Pos = ImVec2(200,200); } }
- ImGui::BulletText("Flags: 0x%04X =%s%s%s%s%s%s%s", viewport->Flags,
- (flags & ImGuiViewportFlags_CanHostOtherWindows) ? " CanHostOtherWindows" : "", (flags & ImGuiViewportFlags_NoDecoration) ? " NoDecoration" : "",
- (flags & ImGuiViewportFlags_NoFocusOnAppearing) ? " NoFocusOnAppearing" : "", (flags & ImGuiViewportFlags_NoInputs) ? " NoInputs" : "",
- (flags & ImGuiViewportFlags_NoRendererClear) ? " NoRendererClear" : "", (flags & ImGuiViewportFlags_Minimized) ? " Minimized" : "",
- (flags & ImGuiViewportFlags_NoAutoMerge) ? " NoAutoMerge" : "");
- for (int layer_i = 0; layer_i < IM_ARRAYSIZE(viewport->DrawDataBuilder.Layers); layer_i++)
- for (int draw_list_i = 0; draw_list_i < viewport->DrawDataBuilder.Layers[layer_i].Size; draw_list_i++)
- Funcs::NodeDrawList(NULL, viewport, viewport->DrawDataBuilder.Layers[layer_i][draw_list_i], "DrawList");
- ImGui::TreePop();
- }
- }
-
- static void NodeDockNode(ImGuiDockNode* node, const char* label)
- {
- ImGuiContext& g = *GImGui;
- bool open;
- if (node->Windows.Size > 0)
- open = ImGui::TreeNode((void*)(intptr_t)node->ID, "%s 0x%04X%s: %d windows (vis: '%s')", label, node->ID, node->IsVisible ? "" : " (hidden)", node->Windows.Size, node->VisibleWindow ? node->VisibleWindow->Name : "NULL");
- else
- open = ImGui::TreeNode((void*)(intptr_t)node->ID, "%s 0x%04X%s: %s split (vis: '%s')", label, node->ID, node->IsVisible ? "" : " (hidden)", (node->SplitAxis == ImGuiAxis_X) ? "horizontal" : (node->SplitAxis == ImGuiAxis_Y) ? "vertical" : "n/a", node->VisibleWindow ? node->VisibleWindow->Name : "NULL");
- if (open)
- {
- IM_ASSERT(node->ChildNodes[0] == NULL || node->ChildNodes[0]->ParentNode == node);
- IM_ASSERT(node->ChildNodes[1] == NULL || node->ChildNodes[1]->ParentNode == node);
- ImGui::BulletText("Pos (%.0f,%.0f), Size (%.0f, %.0f) Ref (%.0f, %.0f)",
- node->Pos.x, node->Pos.y, node->Size.x, node->Size.y, node->SizeRef.x, node->SizeRef.y);
- NodeWindow(node->HostWindow, "HostWindow");
- NodeWindow(node->VisibleWindow, "VisibleWindow");
- ImGui::BulletText("SelectedTabID: 0x%08X, LastFocusedNodeID: 0x%08X", node->SelectedTabID, node->LastFocusedNodeID);
- ImGui::BulletText("Misc:%s%s%s%s", node->IsDockSpace() ? " IsDockSpace" : "", node->IsCentralNode() ? " IsCentralNode" : "", (g.FrameCount - node->LastFrameAlive < 2) ? " IsAlive" : "", (g.FrameCount - node->LastFrameActive < 2) ? " IsActive" : "");
- if (ImGui::TreeNode("flags", "LocalFlags: 0x%04X SharedFlags: 0x%04X", node->LocalFlags, node->SharedFlags))
- {
- ImGui::CheckboxFlags("LocalFlags: NoDocking", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoDocking);
- ImGui::CheckboxFlags("LocalFlags: NoSplit", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoSplit);
- ImGui::CheckboxFlags("LocalFlags: NoResize", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoResize);
- ImGui::CheckboxFlags("LocalFlags: NoTabBar", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoTabBar);
- ImGui::CheckboxFlags("LocalFlags: HiddenTabBar", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_HiddenTabBar);
- ImGui::CheckboxFlags("LocalFlags: NoWindowMenuButton", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoWindowMenuButton);
- ImGui::CheckboxFlags("LocalFlags: NoCloseButton", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoCloseButton);
- ImGui::TreePop();
- }
- if (node->ParentNode)
- NodeDockNode(node->ParentNode, "ParentNode");
- if (node->ChildNodes[0])
- NodeDockNode(node->ChildNodes[0], "Child[0]");
- if (node->ChildNodes[1])
- NodeDockNode(node->ChildNodes[1], "Child[1]");
- if (node->TabBar)
- NodeTabBar(node->TabBar);
- ImGui::TreePop();
- }
- }
-
static void NodeTabBar(ImGuiTabBar* tab_bar)
{
// Standalone tab bars (not associated to docking/windows functionality) currently hold no discernible strings.
char buf[256];
char* p = buf;
const char* buf_end = buf + IM_ARRAYSIZE(buf);
- p += ImFormatString(p, buf_end - p, "TabBar (%d tabs)%s",
- tab_bar->Tabs.Size, (tab_bar->PrevFrameVisible < ImGui::GetFrameCount() - 2) ? " *Inactive*" : "");
- if (tab_bar->Flags & ImGuiTabBarFlags_DockNode)
- {
- p += ImFormatString(p, buf_end - p, " { ");
- for (int tab_n = 0; tab_n < ImMin(tab_bar->Tabs.Size, 3); tab_n++)
- p += ImFormatString(p, buf_end - p, "%s'%s'", tab_n > 0 ? ", " : "", tab_bar->Tabs[tab_n].Window->Name);
- p += ImFormatString(p, buf_end - p, (tab_bar->Tabs.Size > 3) ? " ... }" : " } ");
- }
+ p += ImFormatString(p, buf_end - p, "TabBar (%d tabs)%s", tab_bar->Tabs.Size, (tab_bar->PrevFrameVisible < ImGui::GetFrameCount() - 2) ? " *Inactive*" : "");
if (ImGui::TreeNode(tab_bar, "%s", buf))
{
for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
@@ -14960,38 +10232,68 @@ void ImGui::ShowMetricsWindow(bool* p_open)
ImGui::PushID(tab);
if (ImGui::SmallButton("<")) { TabBarQueueChangeTabOrder(tab_bar, tab, -1); } ImGui::SameLine(0, 2);
if (ImGui::SmallButton(">")) { TabBarQueueChangeTabOrder(tab_bar, tab, +1); } ImGui::SameLine();
- ImGui::Text("%02d%c Tab 0x%08X '%s'", tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID, tab->Window ? tab->Window->Name : "N/A");
+ ImGui::Text("%02d%c Tab 0x%08X '%s'", tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID, (tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "");
ImGui::PopID();
}
ImGui::TreePop();
}
}
+
+ static void NodeStorage(ImGuiStorage* storage, const char* label)
+ {
+ if (!ImGui::TreeNode(label, "%s: %d entries, %d bytes", label, storage->Data.Size, storage->Data.size_in_bytes()))
+ return;
+ for (int n = 0; n < storage->Data.Size; n++)
+ {
+ const ImGuiStorage::ImGuiStoragePair& p = storage->Data[n];
+ ImGui::BulletText("Key 0x%08X Value { i: %d }", p.key, p.val_i); // Important: we currently don't store a type, real value may not be integer.
+ }
+ ImGui::TreePop();
+ }
};
- Funcs::NodeWindows(g.Windows, "Windows");
- if (ImGui::TreeNode("Viewport", "Viewports (%d)", g.Viewports.Size))
+
+ // Tools
+ if (ImGui::TreeNode("Tools"))
{
- ImGui::Indent(ImGui::GetTreeNodeToLabelSpacing());
- ImGui::ShowViewportThumbnails();
- ImGui::Unindent(ImGui::GetTreeNodeToLabelSpacing());
- if (g.PlatformIO.Monitors.Size > 0 && ImGui::TreeNode("Monitors", "Monitors (%d)", g.PlatformIO.Monitors.Size))
+ // The Item Picker tool is super useful to visually select an item and break into the call-stack of where it was submitted.
+ if (ImGui::Button("Item Picker.."))
+ ImGui::DebugStartItemPicker();
+ ImGui::SameLine();
+ MetricsHelpMarker("Will call the IM_DEBUG_BREAK() macro to break in debugger.\nWarning: If you don't have a debugger attached, this will probably crash.");
+
+ 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("##show_windows_rect_type", &show_windows_rect_type, wrt_rects_names, WRT_Count, WRT_Count);
+ if (show_windows_rects && g.NavWindow)
{
- ImGui::TextWrapped("(When viewports are enabled, imgui needs uses monitor data to position popup/tooltips so they don't straddle monitors.)");
- for (int i = 0; i < g.PlatformIO.Monitors.Size; i++)
+ ImGui::BulletText("'%s':", g.NavWindow->Name);
+ ImGui::Indent();
+ for (int rect_n = 0; rect_n < WRT_Count; rect_n++)
{
- const ImGuiPlatformMonitor& mon = g.PlatformIO.Monitors[i];
- ImGui::BulletText("Monitor #%d: DPI %.0f%%\n MainMin (%.0f,%.0f), MainMax (%.0f,%.0f), MainSize (%.0f,%.0f)\n WorkMin (%.0f,%.0f), WorkMax (%.0f,%.0f), WorkSize (%.0f,%.0f)",
- i, mon.DpiScale * 100.0f,
- mon.MainPos.x, mon.MainPos.y, mon.MainPos.x + mon.MainSize.x, mon.MainPos.y + mon.MainSize.y, mon.MainSize.x, mon.MainSize.y,
- mon.WorkPos.x, mon.WorkPos.y, mon.WorkPos.x + mon.WorkSize.x, mon.WorkPos.y + mon.WorkSize.y, mon.WorkSize.x, mon.WorkSize.y);
+ ImRect r = Funcs::GetWindowRect(g.NavWindow, rect_n);
+ ImGui::Text("(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), wrt_rects_names[rect_n]);
}
- ImGui::TreePop();
+ ImGui::Unindent();
}
- for (int i = 0; i < g.Viewports.Size; i++)
- Funcs::NodeViewport(g.Viewports[i]);
+ ImGui::Checkbox("Show mesh when hovering ImDrawCmd", &show_drawcmd_mesh);
+ ImGui::Checkbox("Show bounding boxes when hovering ImDrawCmd", &show_drawcmd_aabb);
+ ImGui::TreePop();
+ }
+
+ // Contents
+ Funcs::NodeWindows(g.Windows, "Windows");
+ //Funcs::NodeWindows(g.WindowsFocusOrder, "WindowsFocusOrder");
+ if (ImGui::TreeNode("DrawLists", "Active DrawLists (%d)", g.DrawDataBuilder.Layers[0].Size))
+ {
+ for (int i = 0; i < g.DrawDataBuilder.Layers[0].Size; i++)
+ Funcs::NodeDrawList(NULL, g.DrawDataBuilder.Layers[0][i], "DrawList");
ImGui::TreePop();
}
+ // Details for Popups
if (ImGui::TreeNode("Popups", "Popups (%d)", g.OpenPopupStack.Size))
{
for (int i = 0; i < g.OpenPopupStack.Size; i++)
@@ -15002,76 +10304,41 @@ void ImGui::ShowMetricsWindow(bool* p_open)
ImGui::TreePop();
}
- if (ImGui::TreeNode("TabBars", "Tab Bars (%d)", g.TabBars.Data.Size))
+ // Details for TabBars
+ if (ImGui::TreeNode("TabBars", "Tab Bars (%d)", g.TabBars.GetSize()))
{
- for (int n = 0; n < g.TabBars.Data.Size; n++)
+ for (int n = 0; n < g.TabBars.GetSize(); n++)
Funcs::NodeTabBar(g.TabBars.GetByIndex(n));
ImGui::TreePop();
}
- if (ImGui::TreeNode("Docking"))
+ // Details for Tables
+ IM_UNUSED(trt_rects_names);
+ IM_UNUSED(show_tables_rects);
+ IM_UNUSED(show_tables_rect_type);
+#ifdef IMGUI_HAS_TABLE
+ if (ImGui::TreeNode("Tables", "Tables (%d)", g.Tables.GetSize()))
{
- ImGuiDockContext* dc = g.DockContext;
- ImGui::Checkbox("Ctrl shows window dock info", &show_docking_nodes);
-
- if (ImGui::TreeNode("Dock nodes"))
- {
- if (ImGui::SmallButton("Clear settings")) { DockContextClearNodes(&g, 0, true); }
- ImGui::SameLine();
- if (ImGui::SmallButton("Rebuild all")) { dc->WantFullRebuild = true; }
- for (int n = 0; n < dc->Nodes.Data.Size; n++)
- if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
- if (node->IsRootNode())
- Funcs::NodeDockNode(node, "Node");
- ImGui::TreePop();
- }
-
- if (ImGui::TreeNode("Settings"))
- {
- if (ImGui::SmallButton("Refresh"))
- SaveIniSettingsToMemory();
- ImGui::SameLine();
- if (ImGui::SmallButton("Save to disk"))
- SaveIniSettingsToDisk(g.IO.IniFilename);
- ImGui::Separator();
- ImGui::Text("Docked Windows:");
- for (int n = 0; n < g.SettingsWindows.Size; n++)
- if (g.SettingsWindows[n].DockId != 0)
- ImGui::BulletText("Window '%s' -> DockId %08X", g.SettingsWindows[n].Name, g.SettingsWindows[n].DockId);
- ImGui::Separator();
- ImGui::Text("Dock Nodes:");
- for (int n = 0; n < dc->SettingsNodes.Size; n++)
- {
- ImGuiDockNodeSettings* settings = &dc->SettingsNodes[n];
- const char* selected_tab_name = NULL;
- if (settings->SelectedWindowID)
- {
- if (ImGuiWindow* window = FindWindowByID(settings->SelectedWindowID))
- selected_tab_name = window->Name;
- else if (ImGuiWindowSettings* window_settings = FindWindowSettings(settings->SelectedWindowID))
- selected_tab_name = window_settings->Name;
- }
- ImGui::BulletText("Node %08X, Parent %08X, SelectedTab %08X ('%s')", settings->ID, settings->ParentNodeID, settings->SelectedWindowID, selected_tab_name ? selected_tab_name : settings->SelectedWindowID ? "N/A" : "");
- }
- ImGui::TreePop();
- }
-
+ for (int n = 0; n < g.Tables.GetSize(); n++)
+ Funcs::NodeTable(g.Tables.GetByIndex(n));
ImGui::TreePop();
}
+#endif // #define IMGUI_HAS_TABLE
-#if 0
- if (ImGui::TreeNode("Tables", "Tables (%d)", g.Tables.Data.Size))
+ // Details for Docking
+#ifdef IMGUI_HAS_DOCK
+ if (ImGui::TreeNode("Docking"))
{
ImGui::TreePop();
}
-#endif
+#endif // #define IMGUI_HAS_DOCK
+ // Misc Details
if (ImGui::TreeNode("Internal state"))
{
const char* input_source_names[] = { "None", "Mouse", "Nav", "NavKeyboard", "NavGamepad" }; IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT);
ImGui::Text("HoveredWindow: '%s'", g.HoveredWindow ? g.HoveredWindow->Name : "NULL");
ImGui::Text("HoveredRootWindow: '%s'", g.HoveredRootWindow ? g.HoveredRootWindow->Name : "NULL");
- ImGui::Text("HoveredWindowUnderMovingWindow: '%s'", g.HoveredWindowUnderMovingWindow ? g.HoveredWindowUnderMovingWindow->Name : "NULL");
ImGui::Text("HoveredId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredId, g.HoveredIdPreviousFrame, g.HoveredIdTimer, g.HoveredIdAllowOverlap); // Data is "in-flight" so depending on when the Metrics window is called we may see current frame information or not
ImGui::Text("ActiveId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d, Source: %s", g.ActiveId, g.ActiveIdPreviousFrame, g.ActiveIdTimer, g.ActiveIdAllowOverlap, input_source_names[g.ActiveIdSource]);
ImGui::Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL");
@@ -15084,37 +10351,10 @@ void ImGui::ShowMetricsWindow(bool* p_open)
ImGui::Text("NavDisableHighlight: %d, NavDisableMouseHover: %d", g.NavDisableHighlight, g.NavDisableMouseHover);
ImGui::Text("NavWindowingTarget: '%s'", g.NavWindowingTarget ? g.NavWindowingTarget->Name : "NULL");
ImGui::Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize);
- ImGui::Text("MouseViewport: 0x%08X (UserHovered 0x%08X, LastHovered 0x%08X)", g.MouseViewport->ID, g.IO.MouseHoveredViewport, g.MouseLastHoveredViewport ? g.MouseLastHoveredViewport->ID : 0);
ImGui::TreePop();
}
- if (ImGui::TreeNode("Tools"))
- {
- // The Item Picker tool is super useful to visually select an item and break into the call-stack of where it was submitted.
- if (ImGui::Button("Item Picker.."))
- ImGui::DebugStartItemPicker();
-
- 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("##show_windows_rect_type", &show_windows_rect_type, wrt_rects_names, WRT_Count);
- if (show_windows_rects && g.NavWindow)
- {
- ImGui::BulletText("'%s':", g.NavWindow->Name);
- ImGui::Indent();
- for (int rect_n = 0; rect_n < WRT_Count; rect_n++)
- {
- ImRect r = Funcs::GetWindowRect(g.NavWindow, rect_n);
- ImGui::Text("(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), wrt_rects_names[rect_n]);
- }
- ImGui::Unindent();
- }
- ImGui::Checkbox("Show clipping rectangle when hovering ImDrawCmd node", &show_drawcmd_clip_rects);
- ImGui::TreePop();
- }
-
- // Tool: Display windows Rectangles and Begin Order
+ // Overlay: Display windows Rectangles and Begin Order
if (show_windows_rects || show_windows_begin_order)
{
for (int n = 0; n < g.Windows.Size; n++)
@@ -15139,29 +10379,23 @@ void ImGui::ShowMetricsWindow(bool* p_open)
}
}
+#ifdef IMGUI_HAS_TABLE
+ // Overlay: Display Tables Rectangles
+ if (show_tables_rects)
+ {
+ for (int table_n = 0; table_n < g.Tables.GetSize(); table_n++)
+ {
+ ImGuiTable* table = g.Tables.GetByIndex(table_n);
+ }
+ }
+#endif // #define IMGUI_HAS_TABLE
+
+#ifdef IMGUI_HAS_DOCK
+ // Overlay: Display Docking info
if (show_docking_nodes && g.IO.KeyCtrl)
{
- for (int n = 0; n < g.DockContext->Nodes.Data.Size; n++)
- if (ImGuiDockNode* node = (ImGuiDockNode*)g.DockContext->Nodes.Data[n].val_p)
- {
- ImGuiDockNode* root_node = DockNodeGetRootNode(node);
- if (ImGuiDockNode* hovered_node = DockNodeTreeFindNodeByPos(root_node, g.IO.MousePos))
- if (hovered_node != node)
- continue;
- char buf[64] = "";
- char* p = buf;
- ImDrawList* overlay_draw_list = node->HostWindow ? GetForegroundDrawList(node->HostWindow) : GetForegroundDrawList((ImGuiViewportP*)GetMainViewport());
- p += ImFormatString(p, buf + IM_ARRAYSIZE(buf) - p, "DockId: %X%s\n", node->ID, node->IsCentralNode() ? " *CentralNode*" : "");
- p += ImFormatString(p, buf + IM_ARRAYSIZE(buf) - p, "WindowClass: %08X\n", node->WindowClass.ClassId);
- p += ImFormatString(p, buf + IM_ARRAYSIZE(buf) - p, "Size: (%.0f, %.0f)\n", node->Size.x, node->Size.y);
- p += ImFormatString(p, buf + IM_ARRAYSIZE(buf) - p, "SizeRef: (%.0f, %.0f)\n", node->SizeRef.x, node->SizeRef.y);
- int depth = DockNodeGetDepth(node);
- overlay_draw_list->AddRect(node->Pos + ImVec2(3, 3) * (float)depth, node->Pos + node->Size - ImVec2(3, 3) * (float)depth, IM_COL32(200, 100, 100, 255));
- ImVec2 pos = node->Pos + ImVec2(3, 3) * (float)depth;
- overlay_draw_list->AddRectFilled(pos - ImVec2(1, 1), pos + CalcTextSize(buf) + ImVec2(1, 1), IM_COL32(200, 100, 100, 255));
- overlay_draw_list->AddText(NULL, 0.0f, pos, IM_COL32(255, 255, 255, 255), buf);
- }
}
+#endif // #define IMGUI_HAS_DOCK
ImGui::End();
}
@@ -15181,3 +10415,5 @@ void ImGui::ShowMetricsWindow(bool*) { }
#endif
//-----------------------------------------------------------------------------
+
+#endif // #ifndef IMGUI_DISABLE
diff --git a/Sources/CImGui/imgui/imgui.h b/Sources/CImGui/imgui/imgui.h
index 965cba0..92c5674 100644
--- a/Sources/CImGui/imgui/imgui.h
+++ b/Sources/CImGui/imgui/imgui.h
@@ -1,10 +1,20 @@
-// dear imgui, v1.74 WIP
+// dear imgui, v1.76
// (headers)
-// See imgui.cpp file for documentation.
-// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
-// Newcomers, read 'Programmer guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
-// Get latest version at https://github.com/ocornut/imgui
+// Help:
+// - Read FAQ at http://dearimgui.org/faq
+// - Newcomers, read 'Programmer guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
+// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code. All applications in examples/ are doing that.
+// Read imgui.cpp for details, links and comments.
+
+// Resources:
+// - FAQ http://dearimgui.org/faq
+// - Homepage & latest https://github.com/ocornut/imgui
+// - Releases & changelog https://github.com/ocornut/imgui/releases
+// - Gallery https://github.com/ocornut/imgui/issues/3075 (please post your screenshots/video there!)
+// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
+// - Wiki https://github.com/ocornut/imgui/wiki
+// - Issues & support https://github.com/ocornut/imgui/issues
/*
@@ -17,18 +27,17 @@ Index of this file:
// ImVector<>
// ImGuiStyle
// ImGuiIO
-// Misc data structures (ImGuiInputTextCallbackData, ImGuiSizeCallbackData, ImGuiWindowClass, ImGuiPayload)
+// Misc data structures (ImGuiInputTextCallbackData, ImGuiSizeCallbackData, ImGuiPayload)
// Obsolete functions
// Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, ImColor)
// Draw List API (ImDrawCallback, ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawListFlags, ImDrawList, ImDrawData)
// Font API (ImFontConfig, ImFontGlyph, ImFontGlyphRangesBuilder, ImFontAtlasFlags, ImFontAtlas, ImFont)
-// Platform interface for multi-viewport support (ImGuiPlatformMonitor, ImGuiPlatformIO, ImGuiViewport)
*/
#pragma once
-// Configuration file with compile-time options (edit imconfig.h or define IMGUI_USER_CONFIG to your own filename)
+// Configuration file with compile-time options (edit imconfig.h or #define IMGUI_USER_CONFIG to your own filename)
#ifdef IMGUI_USER_CONFIG
#include IMGUI_USER_CONFIG
#endif
@@ -36,26 +45,27 @@ Index of this file:
#include "imconfig.h"
#endif
+#ifndef IMGUI_DISABLE
+
//-----------------------------------------------------------------------------
// Header mess
//-----------------------------------------------------------------------------
-#include // FLT_MAX
-#include // va_list
+// Includes
+#include // FLT_MIN, FLT_MAX
+#include // va_list, va_start, va_end
#include // ptrdiff_t, NULL
#include // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
// Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
-#define IMGUI_VERSION "1.74 WIP"
-#define IMGUI_VERSION_NUM 17301
+#define IMGUI_VERSION "1.76"
+#define IMGUI_VERSION_NUM 17600
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
-#define IMGUI_HAS_VIEWPORT 1 // Viewport WIP branch
-#define IMGUI_HAS_DOCK 1 // Docking WIP branch
// Define attributes of all API symbols declarations (e.g. for DLL under Windows)
// IMGUI_API is used for core imgui functions, IMGUI_IMPL_API is used for the default bindings files (imgui_impl_xxx.h)
-// Using dear imgui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
+// Using dear imgui via a shared library is not recommended, because we don't guarantee backward nor forward ABI compatibility (also function call overhead, as dear imgui is a call-heavy API)
#ifndef IMGUI_API
#define IMGUI_API
#endif
@@ -68,14 +78,14 @@ Index of this file:
#include
#define IM_ASSERT(_EXPR) assert(_EXPR) // You can override the default assert handler by editing imconfig.h
#endif
-#if defined(__clang__) || defined(__GNUC__)
-#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1))) // Apply printf-style warnings to user functions.
+#if !defined(IMGUI_USE_STB_SPRINTF) && (defined(__clang__) || defined(__GNUC__))
+#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1))) // To apply printf-style warnings to our functions.
#define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0)))
#else
#define IM_FMTARGS(FMT)
#define IM_FMTLIST(FMT)
#endif
-#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR)/sizeof(*_ARR))) // Size of a static C-style array. Don't use on pointers!
+#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR) / sizeof(*_ARR))) // Size of a static C-style array. Don't use on pointers!
#define IM_UNUSED(_VAR) ((void)_VAR) // Used to silence "unused variable warnings". Often useful as asserts may be stripped out from final builds.
#if (__cplusplus >= 201100)
#define IM_OFFSETOF(_TYPE,_MEMBER) offsetof(_TYPE, _MEMBER) // Offset of _MEMBER within _TYPE. Standardized as offsetof() in C++11
@@ -100,6 +110,7 @@ Index of this file:
// Forward declarations and basic types
//-----------------------------------------------------------------------------
+// Forward declarations
struct ImDrawChannel; // Temporary storage to output draw commands out of order, used by ImDrawListSplitter and ImDrawList::ChannelsSplit()
struct ImDrawCmd; // A single draw command within a parent ImDrawList (generally maps to 1 GPU draw call, unless it is a callback)
struct ImDrawData; // All draw command lists required to render the frame + pos/size coordinates to use for the projection matrix.
@@ -119,29 +130,23 @@ struct ImGuiInputTextCallbackData; // Shared state of InputText() when using cu
struct ImGuiListClipper; // Helper to manually clip large list of items
struct ImGuiOnceUponAFrame; // Helper for running a block of code not more than once a frame, used by IMGUI_ONCE_UPON_A_FRAME macro
struct ImGuiPayload; // User data payload for drag and drop operations
-struct ImGuiPlatformIO; // Multi-viewport support: interface for Platform/Renderer back-ends + viewports to render
-struct ImGuiPlatformMonitor; // Multi-viewport support: user-provided bounds for each connected monitor/display. Used when positioning popups and tooltips to avoid them straddling monitors
struct ImGuiSizeCallbackData; // Callback data when using SetNextWindowSizeConstraints() (rare/advanced use)
struct ImGuiStorage; // Helper for key->value storage
struct ImGuiStyle; // Runtime data for styling/colors
struct ImGuiTextBuffer; // Helper to hold and append into a text buffer (~string builder)
-struct ImGuiTextFilter; // Helper to parse and apply text filters (e.g. "aaaaa[,bbbb][,ccccc]")
-struct ImGuiViewport; // Viewport (generally ~1 per window to output to at the OS level. Need per-platform support to use multiple viewports)
-struct ImGuiWindowClass; // Window class (rare/advanced uses: provide hints to the platform back-end via altered viewport flags and parent/child info)
-
-// Typedefs and Enums/Flags (declared as int for compatibility with old C++, to allow using as flags and to not pollute the top of this file)
-// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
-#ifndef ImTextureID
-typedef void* ImTextureID; // User data to identify a texture (this is whatever to you want it to be! read the FAQ about ImTextureID in imgui.cpp)
-#endif
-typedef unsigned int ImGuiID; // Unique ID used by widgets (typically hashed from a stack of string)
-typedef unsigned short ImWchar; // A single U16 character for keyboard input/display. We encode them as multi bytes UTF-8 when used in strings.
+struct ImGuiTextFilter; // Helper to parse and apply text filters (e.g. "aaaaa[,bbbbb][,ccccc]")
+
+// Enums/Flags (declared as int for compatibility with old C++, to allow using as flags and to not pollute the top of this file)
+// - Tip: Use your programming IDE navigation facilities on the names in the _central column_ below to find the actual flags/enum lists!
+// In Visual Studio IDE: CTRL+comma ("Edit.NavigateTo") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
+// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments.
typedef int ImGuiCol; // -> enum ImGuiCol_ // Enum: A color identifier for styling
typedef int ImGuiCond; // -> enum ImGuiCond_ // Enum: A condition for many Set*() functions
typedef int ImGuiDataType; // -> enum ImGuiDataType_ // Enum: A primary data type
typedef int ImGuiDir; // -> enum ImGuiDir_ // Enum: A cardinal direction
typedef int ImGuiKey; // -> enum ImGuiKey_ // Enum: A key identifier (ImGui-side enum)
typedef int ImGuiNavInput; // -> enum ImGuiNavInput_ // Enum: An input identifier for navigation
+typedef int ImGuiMouseButton; // -> enum ImGuiMouseButton_ // Enum: A mouse button identifier (0=left, 1=right, 2=middle)
typedef int ImGuiMouseCursor; // -> enum ImGuiMouseCursor_ // Enum: A mouse cursor identifier
typedef int ImGuiStyleVar; // -> enum ImGuiStyleVar_ // Enum: A variable identifier for styling
typedef int ImDrawCornerFlags; // -> enum ImDrawCornerFlags_ // Flags: for ImDrawList::AddRect(), AddRectFilled() etc.
@@ -151,22 +156,37 @@ typedef int ImGuiBackendFlags; // -> enum ImGuiBackendFlags_ // Flags: f
typedef int ImGuiColorEditFlags; // -> enum ImGuiColorEditFlags_ // Flags: for ColorEdit4(), ColorPicker4() etc.
typedef int ImGuiConfigFlags; // -> enum ImGuiConfigFlags_ // Flags: for io.ConfigFlags
typedef int ImGuiComboFlags; // -> enum ImGuiComboFlags_ // Flags: for BeginCombo()
-typedef int ImGuiDockNodeFlags; // -> enum ImGuiDockNodeFlags_ // Flags: for DockSpace()
typedef int ImGuiDragDropFlags; // -> enum ImGuiDragDropFlags_ // Flags: for BeginDragDropSource(), AcceptDragDropPayload()
typedef int ImGuiFocusedFlags; // -> enum ImGuiFocusedFlags_ // Flags: for IsWindowFocused()
typedef int ImGuiHoveredFlags; // -> enum ImGuiHoveredFlags_ // Flags: for IsItemHovered(), IsWindowHovered() etc.
typedef int ImGuiInputTextFlags; // -> enum ImGuiInputTextFlags_ // Flags: for InputText(), InputTextMultiline()
+typedef int ImGuiKeyModFlags; // -> enum ImGuiKeyModFlags_ // Flags: for io.KeyMods (Ctrl/Shift/Alt/Super)
typedef int ImGuiSelectableFlags; // -> enum ImGuiSelectableFlags_ // Flags: for Selectable()
typedef int ImGuiTabBarFlags; // -> enum ImGuiTabBarFlags_ // Flags: for BeginTabBar()
typedef int ImGuiTabItemFlags; // -> enum ImGuiTabItemFlags_ // Flags: for BeginTabItem()
typedef int ImGuiTreeNodeFlags; // -> enum ImGuiTreeNodeFlags_ // Flags: for TreeNode(), TreeNodeEx(), CollapsingHeader()
-typedef int ImGuiViewportFlags; // -> enum ImGuiViewportFlags_ // Flags: for ImGuiViewport
typedef int ImGuiWindowFlags; // -> enum ImGuiWindowFlags_ // Flags: for Begin(), BeginChild()
+
+// Other types
+#ifndef ImTextureID // ImTextureID [configurable type: override in imconfig.h with '#define ImTextureID xxx']
+typedef void* ImTextureID; // User data for rendering back-end to identify a texture. This is whatever to you want it to be! read the FAQ about ImTextureID for details.
+#endif
+typedef unsigned int ImGuiID; // A unique ID used by widgets, typically hashed from a stack of string.
typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData *data);
typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data);
-// Scalar data types
-typedef signed char ImS8; // 8-bit signed integer == char
+// Decoded character types
+// (we generally use UTF-8 encoded string in the API. This is storage specifically for a decoded character used for keyboard input and display)
+typedef unsigned short ImWchar16; // A single decoded U16 character/code point. We encode them as multi bytes UTF-8 when used in strings.
+typedef unsigned int ImWchar32; // A single decoded U32 character/code point. We encode them as multi bytes UTF-8 when used in strings.
+#ifdef IMGUI_USE_WCHAR32 // ImWchar [configurable type: override in imconfig.h with '#define IMGUI_USE_WCHAR32' to support Unicode planes 1-16]
+typedef ImWchar32 ImWchar;
+#else
+typedef ImWchar16 ImWchar;
+#endif
+
+// Basic scalar data types
+typedef signed char ImS8; // 8-bit signed integer
typedef unsigned char ImU8; // 8-bit unsigned integer
typedef signed short ImS16; // 16-bit signed integer
typedef unsigned short ImU16; // 16-bit unsigned integer
@@ -184,14 +204,14 @@ typedef signed long long ImS64; // 64-bit signed integer (post C++11)
typedef unsigned long long ImU64; // 64-bit unsigned integer (post C++11)
#endif
-// 2D vector (often used to store positions, sizes, etc.)
+// 2D vector (often used to store positions or sizes)
struct ImVec2
{
- float x, y;
- ImVec2() { x = y = 0.0f; }
- ImVec2(float _x, float _y) { x = _x; y = _y; }
- float operator[] (size_t idx) const { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine.
- float& operator[] (size_t idx) { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine.
+ float x, y;
+ ImVec2() { x = y = 0.0f; }
+ ImVec2(float _x, float _y) { x = _x; y = _y; }
+ float operator[] (size_t idx) const { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine.
+ float& operator[] (size_t idx) { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine.
#ifdef IM_VEC2_CLASS_EXTRA
IM_VEC2_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec2.
#endif
@@ -200,9 +220,9 @@ struct ImVec2
// 4D vector (often used to store floating-point colors)
struct ImVec4
{
- float x, y, z, w;
- ImVec4() { x = y = z = w = 0.0f; }
- ImVec4(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; }
+ float x, y, z, w;
+ ImVec4() { x = y = z = w = 0.0f; }
+ ImVec4(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; }
#ifdef IM_VEC4_CLASS_EXTRA
IM_VEC4_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec4.
#endif
@@ -210,32 +230,31 @@ struct ImVec4
//-----------------------------------------------------------------------------
// ImGui: Dear ImGui end-user API
-// (Inside a namespace so you can add extra functions in your own separate file. Please don't modify imgui.cpp/.h!)
+// (This is a namespace. You can add extra ImGui:: functions in your own separate file. Please don't modify imgui source files!)
//-----------------------------------------------------------------------------
namespace ImGui
{
// Context creation and access
// Each context create its own ImFontAtlas by default. You may instance one yourself and pass it to CreateContext() to share a font atlas between imgui contexts.
- // All those functions are not reliant on the current context.
+ // None of those functions is reliant on the current context.
IMGUI_API ImGuiContext* CreateContext(ImFontAtlas* shared_font_atlas = NULL);
IMGUI_API void DestroyContext(ImGuiContext* ctx = NULL); // NULL = destroy current context
IMGUI_API ImGuiContext* GetCurrentContext();
IMGUI_API void SetCurrentContext(ImGuiContext* ctx);
- IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert, size_t sz_drawidx);
// Main
IMGUI_API ImGuiIO& GetIO(); // access the IO structure (mouse/keyboard/gamepad inputs, time, various configuration options/flags)
- IMGUI_API ImGuiStyle& GetStyle(); // access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame.
+ IMGUI_API ImGuiStyle& GetStyle(); // access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame!
IMGUI_API void NewFrame(); // start a new Dear ImGui frame, you can submit any command from this point until Render()/EndFrame().
- IMGUI_API void EndFrame(); // ends the Dear ImGui frame. automatically called by Render(), you likely don't need to call that yourself directly. If you don't need to render data (skipping rendering) you may call EndFrame() but you'll have wasted CPU already! If you don't need to render, better to not create any imgui windows and not call NewFrame() at all!
- IMGUI_API void Render(); // ends the Dear ImGui frame, finalize the draw data. You can get call GetDrawData() to obtain it and run your rendering function. (Obsolete: this used to call io.RenderDrawListsFn(). Nowadays, we allow and prefer calling your render function yourself.)
+ IMGUI_API void EndFrame(); // ends the Dear ImGui frame. automatically called by Render(). If you don't need to render data (skipping rendering) you may call EndFrame() without Render()... but you'll have wasted CPU already! If you don't need to render, better to not create any windows and not call NewFrame() at all!
+ IMGUI_API void Render(); // ends the Dear ImGui frame, finalize the draw data. You can get call GetDrawData() to obtain it and run your rendering function (up to v1.60, this used to call io.RenderDrawListsFn(). Nowadays, we allow and prefer calling your render function yourself.)
IMGUI_API ImDrawData* GetDrawData(); // valid after Render() and until the next call to NewFrame(). this is what you have to render.
// Demo, Debug, Information
IMGUI_API void ShowDemoWindow(bool* p_open = NULL); // create Demo window (previously called ShowTestWindow). demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application!
IMGUI_API void ShowAboutWindow(bool* p_open = NULL); // create About window. display Dear ImGui version, credits and build/system information.
- IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create Metrics/Debug window. display Dear ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc.
+ IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create Debug/Metrics window. display Dear ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc.
IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style)
IMGUI_API bool ShowStyleSelector(const char* label); // add style selector block (not a window), essentially a combo listing the default styles.
IMGUI_API void ShowFontSelector(const char* label); // add font selector block (not a window), essentially a combo listing the loaded fonts.
@@ -254,8 +273,9 @@ namespace ImGui
// which clicking will set the boolean to false when clicked.
// - Begin() return false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting
// anything to the window. Always call a matching End() for each Begin() call, regardless of its return value!
- // [this is due to legacy reason and is inconsistent with most other functions such as BeginMenu/EndMenu, BeginPopup/EndPopup, etc.
- // where the EndXXX call should only be called if the corresponding BeginXXX function returned true.]
+ // [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu,
+ // BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function
+ // returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.]
// - Note that the bottom of window stack always contains a window called "Debug".
IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0);
IMGUI_API void End();
@@ -264,20 +284,18 @@ namespace ImGui
// - Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window. Child windows can embed their own child.
// - For each independent axis of 'size': ==0.0f: use remaining host window size / >0.0f: fixed size / <0.0f: use remaining window size minus abs(size) / Each axis can use a different mode, e.g. ImVec2(0,400).
// - BeginChild() returns false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting anything to the window.
- // Always call a matching EndChild() for each BeginChild() call, regardless of its return value [this is due to legacy reason and is inconsistent with most other functions such as BeginMenu/EndMenu, BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function returned true.]
+ // Always call a matching EndChild() for each BeginChild() call, regardless of its return value [as with Begin: this is due to legacy reason and inconsistent with most BeginXXX functions apart from the regular Begin() which behaves like BeginChild().]
IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags flags = 0);
IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags flags = 0);
IMGUI_API void EndChild();
// Windows Utilities
- // - "current window" = the window we are appending into while inside a Begin()/End() block. "next window" = next window we will Begin() into.
+ // - 'current window' = the window we are appending into while inside a Begin()/End() block. 'next window' = next window we will Begin() into.
IMGUI_API bool IsWindowAppearing();
IMGUI_API bool IsWindowCollapsed();
IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags=0); // is current window focused? or its root/child, depending on flags. see flags for options.
IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags=0); // is current window hovered (and typically: not blocked by a popup/modal)? see flags for options. NB: If you are trying to check whether your mouse should be dispatched to imgui or to your app, you should use the 'io.WantCaptureMouse' boolean for that! Please read the FAQ!
IMGUI_API ImDrawList* GetWindowDrawList(); // get draw list associated to the current window, to append your own drawing primitives
- IMGUI_API float GetWindowDpiScale(); // get DPI scale currently associated to the current window's viewport.
- IMGUI_API ImGuiViewport*GetWindowViewport(); // get viewport currently associated to the current window.
IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
IMGUI_API ImVec2 GetWindowSize(); // get current window size
IMGUI_API float GetWindowWidth(); // get current window width (shortcut for GetWindowSize().x)
@@ -290,8 +308,7 @@ namespace ImGui
IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (~ scrollable client area, which enforce the range of scrollbars). Not including window decorations (title bar, menu bar, etc.) nor WindowPadding. set an axis to 0.0f to leave it automatic. call before Begin()
IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // set next window collapsed state. call before Begin()
IMGUI_API void SetNextWindowFocus(); // set next window to be focused / top-most. call before Begin()
- IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily modify ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground.
- IMGUI_API void SetNextWindowViewport(ImGuiID viewport_id); // set next window viewport
+ IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily override the Alpha component of ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground.
IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0,0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
@@ -340,11 +357,11 @@ namespace ImGui
IMGUI_API ImU32 GetColorU32(ImU32 col); // retrieve given color with style alpha applied
// Parameters stacks (current window)
- 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 PushItemWidth(float item_width); // push 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 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. NOT necessarily the width of last item unlike most 'Item' functions.
- 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); // push word-wrapping position 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 PushAllowKeyboardFocus(bool allow_keyboard_focus); // allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets
IMGUI_API void PopAllowKeyboardFocus();
@@ -354,6 +371,10 @@ namespace ImGui
// Cursor / Layout
// - 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.
+ // - You can call SameLine() between widgets to undo the last carriage return and output at the right of the preceeding widget.
+ // - Attention! We currently have inconsistencies between window-local and absolute positions we will aim to fix with future API:
+ // Window-local coordinates: SameLine(), GetCursorPos(), SetCursorPos(), GetCursorStartPos(), GetContentRegionMax(), GetWindowContentRegion*(), PushTextWrapPos()
+ // Absolute coordinate: GetCursorScreenPos(), SetCursorScreenPos(), all ImDrawList:: functions.
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 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.
@@ -370,8 +391,8 @@ namespace ImGui
IMGUI_API void SetCursorPosX(float local_x); // GetWindowPos() + GetCursorPos() == GetCursorScreenPos() etc.)
IMGUI_API void SetCursorPosY(float local_y); //
IMGUI_API ImVec2 GetCursorStartPos(); // initial cursor position in window coordinates
- IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates (0..io.DisplaySize) or natural OS coordinates when using multiple viewport. Useful to work with ImDrawList API.
- IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute screen coordinates (0..io.DisplaySize) or natural OS coordinates when using multiple viewport.
+ IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates [0..io.DisplaySize] (useful to work with ImDrawList API)
+ IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute screen coordinates [0..io.DisplaySize]
IMGUI_API void AlignTextToFramePadding(); // vertically align upcoming text baseline to FramePadding.y so that it will align properly to regularly framed items (call if you have text on a line before a framed item)
IMGUI_API float GetTextLineHeight(); // ~ FontSize
IMGUI_API float GetTextLineHeightWithSpacing(); // ~ FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text)
@@ -395,8 +416,8 @@ namespace ImGui
IMGUI_API ImGuiID GetID(const void* ptr_id);
// Widgets: Text
- IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text.
- IMGUI_API void Text(const char* fmt, ...) IM_FMTARGS(1); // simple formatted text
+ IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text.
+ IMGUI_API void Text(const char* fmt, ...) IM_FMTARGS(1); // formatted text
IMGUI_API void TextV(const char* fmt, va_list args) IM_FMTLIST(1);
IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_FMTARGS(2); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args) IM_FMTLIST(2);
@@ -411,6 +432,7 @@ namespace ImGui
// Widgets: Main
// - Most widgets return true when the value has been changed or when pressed/selected
+ // - You may also use one of the many IsItemXXX functions (e.g. IsItemActive, IsItemHovered, etc.) to query widget state.
IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0)); // button
IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed within text
IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size); // button behavior without the visuals, frequently useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.)
@@ -425,7 +447,7 @@ namespace ImGui
IMGUI_API void Bullet(); // draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses
// Widgets: Combo Box
- // - The new BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items.
+ // - The BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items.
// - The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose.
IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags = 0);
IMGUI_API void EndCombo(); // only call EndCombo() if BeginCombo() returns true!
@@ -439,6 +461,7 @@ namespace ImGui
// - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc.
// - Speed are per-pixel of mouse movement (v_speed=0.2f: mouse needs to move by 5 pixels to increase value by 1). For gamepad/keyboard navigation, minimum speed is Max(v_speed, minimum_step_at_given_precision).
// - Use v_min < v_max to clamp edits to given limits. Note that CTRL+Click manual input can override those limits.
+ // - Use v_max = FLT_MAX / INT_MAX etc to avoid clamping to a maximum, same with v_min = -FLT_MAX / INT_MIN to avoid clamping to a minimum.
// - Use v_min > v_max to lock edits.
IMGUI_API bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", float power = 1.0f); // If v_min >= v_max we have no bound
IMGUI_API bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", float power = 1.0f);
@@ -472,7 +495,7 @@ namespace ImGui
IMGUI_API bool VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, float power = 1.0f);
// Widgets: Input with Keyboard
- // - If you want to use InputText() with a dynamic string type such as std::string or your own, see misc/cpp/imgui_stdlib.h
+ // - If you want to use InputText() with std::string or any custom dynamic string type, see misc/cpp/imgui_stdlib.h and comments in imgui_demo.cpp.
// - Most of the ImGuiInputTextFlags flags are only useful for InputText() and not for InputFloatX, InputIntX, InputDouble etc.
IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
IMGUI_API bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0,0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
@@ -521,7 +544,7 @@ namespace ImGui
// Widgets: Selectables
// - A selectable highlights when hovered, and can display another color when selected.
- // - Neighbors selectable extend their highlight bounds in order to leave no gap between them.
+ // - Neighbors selectable extend their highlight bounds in order to leave no gap between them. This is so a series of selected Selectable appear contiguous.
IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height
IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper.
@@ -547,16 +570,20 @@ namespace ImGui
IMGUI_API void Value(const char* prefix, float v, const char* float_format = NULL);
// Widgets: Menus
- IMGUI_API bool BeginMainMenuBar(); // create and append to a full screen menu-bar.
- IMGUI_API void EndMainMenuBar(); // only call EndMainMenuBar() if BeginMainMenuBar() returns true!
+ // - Use BeginMenuBar() on a window ImGuiWindowFlags_MenuBar to append to its menu bar.
+ // - Use BeginMainMenuBar() to create a menu bar at the top of the screen and append to it.
+ // - Use BeginMenu() to create a menu. You can call BeginMenu() multiple time with the same identifier to append more items to it.
IMGUI_API bool BeginMenuBar(); // append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set on parent window).
IMGUI_API void EndMenuBar(); // only call EndMenuBar() if BeginMenuBar() returns true!
+ IMGUI_API bool BeginMainMenuBar(); // create and append to a full screen menu-bar.
+ IMGUI_API void EndMainMenuBar(); // only call EndMainMenuBar() if BeginMainMenuBar() returns true!
IMGUI_API bool BeginMenu(const char* label, bool enabled = true); // create a sub-menu entry. only call EndMenu() if this returns true!
IMGUI_API void EndMenu(); // only call EndMenu() if BeginMenu() returns true!
IMGUI_API bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); // return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment
IMGUI_API bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); // return true when activated + toggle (*p_selected) if p_selected != NULL
// Tooltips
+ // - Tooltip are windows following the mouse which do not take focus away.
IMGUI_API void BeginTooltip(); // begin/append a tooltip window. to create full-featured tooltip (with any kind of items).
IMGUI_API void EndTooltip();
IMGUI_API void SetTooltip(const char* fmt, ...) IM_FMTARGS(1); // set a text-only tooltip, typically use with ImGui::IsItemHovered(). override any previous call to SetTooltip().
@@ -568,22 +595,25 @@ namespace ImGui
// - Unless modal, they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
// - Their visibility state (~bool) is held internally by imgui instead of being held by the programmer as we are used to with regular Begin() calls.
// User can manipulate the visibility state by calling OpenPopup().
- // (*) One can use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) to bypass it and detect hovering even when normally blocked by a popup.
+ // - We default to use the right mouse (ImGuiMouseButton_Right=1) for the Popup Context functions.
+ // (*) You can use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) to bypass it and detect hovering even when normally blocked by a popup.
// Those three properties are connected. The library needs to hold their visibility state because it can close popups at any time.
IMGUI_API void OpenPopup(const char* str_id); // call to mark popup as open (don't call every frame!). popups are closed when user click outside, or if CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. By default, Selectable()/MenuItem() are calling CloseCurrentPopup(). Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
IMGUI_API bool BeginPopup(const char* str_id, ImGuiWindowFlags flags = 0); // return true if the popup is open, and you can start outputting to it. only call EndPopup() if BeginPopup() returns true!
- IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
- IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, int mouse_button = 1, bool also_over_items = true); // helper to open and begin popup when clicked on current window.
- IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked in void (where there are no imgui windows).
+ IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiMouseButton mouse_button = 1); // helper to open and begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
+ IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiMouseButton mouse_button = 1, bool also_over_items = true); // helper to open and begin popup when clicked on current window.
+ IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiMouseButton mouse_button = 1); // helper to open and begin popup when clicked in void (where there are no imgui windows).
IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // modal dialog (regular window with title bar, block interactions behind the modal window, can't close the modal window by clicking outside)
IMGUI_API void EndPopup(); // only call EndPopup() if BeginPopupXXX() returns true!
- IMGUI_API bool OpenPopupOnItemClick(const char* str_id = NULL, int mouse_button = 1); // helper to open popup when clicked on last item (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors). return true when just opened.
+ IMGUI_API bool OpenPopupOnItemClick(const char* str_id = NULL, ImGuiMouseButton mouse_button = 1); // helper to open popup when clicked on last item (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors). return true when just opened.
IMGUI_API bool IsPopupOpen(const char* str_id); // return true if the popup is open at the current begin-ed level of the popup stack.
IMGUI_API void CloseCurrentPopup(); // close the popup we have begin-ed into. clicking on a MenuItem or Selectable automatically close the current popup.
// Columns
// - You can also use SameLine(pos_x) to mimic simplified columns.
// - The columns API is work-in-progress and rather lacking (columns are arguably the worst part of dear imgui at the moment!)
+ // - There is a maximum of 64 columns.
+ // - Currently working on new 'Tables' api which will replace columns around Q2 2020 (see GitHub #2957).
IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true);
IMGUI_API void NextColumn(); // next column, defaults to current row or next row if the current row is finished
IMGUI_API int GetColumnIndex(); // get current column index
@@ -594,27 +624,12 @@ namespace ImGui
IMGUI_API int GetColumnsCount();
// Tab Bars, Tabs
- // [BETA API] API may evolve!
- // Note: Tabs are automatically created by the docking system. Use this to create tab bars/tabs yourself without docking being involved.
IMGUI_API bool BeginTabBar(const char* str_id, ImGuiTabBarFlags flags = 0); // create and append into a TabBar
IMGUI_API void EndTabBar(); // only call EndTabBar() if BeginTabBar() returns true!
IMGUI_API bool BeginTabItem(const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0);// create a Tab. Returns true if the Tab is selected.
IMGUI_API void EndTabItem(); // only call EndTabItem() if BeginTabItem() returns true!
IMGUI_API void SetTabItemClosed(const char* tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name.
- // Docking
- // [BETA API] Enable with io.ConfigFlags |= ImGuiConfigFlags_DockingEnable.
- // Note: you DO NOT need to call DockSpace() to use most Docking facilities!
- // - To dock windows: if io.ConfigDockingWithShift == false (default) drag window from their title bar.
- // - To dock windows: if io.ConfigDockingWithShift == true: hold SHIFT anywhere while moving windows.
- // - Use DockSpace() to create an explicit dock node _within_ an existing window. See Docking demo for details.
- IMGUI_API void DockSpace(ImGuiID id, const ImVec2& size = ImVec2(0, 0), ImGuiDockNodeFlags flags = 0, const ImGuiWindowClass* window_class = NULL);
- IMGUI_API ImGuiID DockSpaceOverViewport(ImGuiViewport* viewport = NULL, ImGuiDockNodeFlags flags = 0, const ImGuiWindowClass* window_class = NULL);
- IMGUI_API void SetNextWindowDockID(ImGuiID dock_id, ImGuiCond cond = 0); // set next window dock id (FIXME-DOCK)
- IMGUI_API void SetNextWindowClass(const ImGuiWindowClass* window_class); // set next window class (rare/advanced uses: provide hints to the platform back-end via altered viewport flags and parent/child info)
- IMGUI_API ImGuiID GetWindowDockID();
- IMGUI_API bool IsWindowDocked(); // is current window docked into another window?
-
// Logging/Capture
// - All text output from the interface can be captured into tty/file/clipboard. By default, tree nodes are automatically opened during logging.
IMGUI_API void LogToTTY(int auto_open_depth = -1); // start logging to tty (stdout)
@@ -625,7 +640,7 @@ namespace ImGui
IMGUI_API void LogText(const char* fmt, ...) IM_FMTARGS(1); // pass text data straight to log (without being displayed)
// Drag and Drop
- // [BETA API] API may evolve!
+ // - [BETA API] API may evolve!
IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags = 0); // call when the current item is active. If this return true, you can call SetDragDropPayload() + EndDragDropSource()
IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t sz, ImGuiCond cond = 0); // type is a user defined string of maximum 32 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui.
IMGUI_API void EndDragDropSource(); // only call EndDragDropSource() if BeginDragDropSource() returns true!
@@ -649,12 +664,13 @@ namespace ImGui
IMGUI_API bool IsItemHovered(ImGuiHoveredFlags flags = 0); // is the last item hovered? (and usable, aka not blocked by a popup, etc.). See ImGuiHoveredFlags for more options.
IMGUI_API bool IsItemActive(); // is the last item active? (e.g. button being held, text field being edited. This will continuously return true while holding mouse button on an item. Items that don't interact will always return false)
IMGUI_API bool IsItemFocused(); // is the last item focused for keyboard/gamepad navigation?
- IMGUI_API bool IsItemClicked(int mouse_button = 0); // is the last item clicked? (e.g. button/node just clicked on) == IsMouseClicked(mouse_button) && IsItemHovered()
+ IMGUI_API bool IsItemClicked(ImGuiMouseButton mouse_button = 0); // is the last item clicked? (e.g. button/node just clicked on) == IsMouseClicked(mouse_button) && IsItemHovered()
IMGUI_API bool IsItemVisible(); // is the last item visible? (items may be out of sight because of clipping/scrolling)
IMGUI_API bool IsItemEdited(); // did the last item modify its underlying value this frame? or was pressed? This is generally the same as the "bool" return value of many widgets.
IMGUI_API bool IsItemActivated(); // was the last item just made active (item was previously inactive).
IMGUI_API bool IsItemDeactivated(); // was the last item just made inactive (item was previously active). Useful for Undo/Redo patterns with widgets that requires continuous editing.
IMGUI_API bool IsItemDeactivatedAfterEdit(); // was the last item just made inactive and made a value change when it was active? (e.g. Slider/Drag moved). Useful for Undo/Redo patterns with widgets that requires continuous editing. Note that you may get false positives (some widgets such as Combo()/ListBox()/Selectable() will return true even when clicking an already selected item).
+ IMGUI_API bool IsItemToggledOpen(); // was the last item open state toggled? set by TreeNode().
IMGUI_API bool IsAnyItemHovered(); // is any item hovered?
IMGUI_API bool IsAnyItemActive(); // is any item active?
IMGUI_API bool IsAnyItemFocused(); // is any item focused?
@@ -668,49 +684,57 @@ namespace ImGui
IMGUI_API bool IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max); // test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side.
IMGUI_API double GetTime(); // get global imgui time. incremented by io.DeltaTime every frame.
IMGUI_API int GetFrameCount(); // get global imgui frame count. incremented by 1 every frame.
- IMGUI_API ImDrawList* GetBackgroundDrawList(); // get background draw list for the viewport associated to the current window. this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents.
- IMGUI_API ImDrawList* GetForegroundDrawList(); // get foreground draw list for the viewport associated to the current window. this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents.
- IMGUI_API ImDrawList* GetBackgroundDrawList(ImGuiViewport* viewport); // get background draw list for the given viewport. this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents.
- IMGUI_API ImDrawList* GetForegroundDrawList(ImGuiViewport* viewport); // get foreground draw list for the given viewport. this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents.
+ IMGUI_API ImDrawList* GetBackgroundDrawList(); // this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents.
+ IMGUI_API ImDrawList* GetForegroundDrawList(); // this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents.
IMGUI_API ImDrawListSharedData* GetDrawListSharedData(); // you may use this when creating your own ImDrawList instances.
IMGUI_API const char* GetStyleColorName(ImGuiCol idx); // get a string corresponding to the enum value (for display, saving, etc.).
IMGUI_API void SetStateStorage(ImGuiStorage* storage); // replace current window storage with our own (if you want to manipulate it yourself, typically clear subsection of it)
IMGUI_API ImGuiStorage* GetStateStorage();
- IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
IMGUI_API void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); // calculate coarse clipping for large list of evenly sized items. Prefer using the ImGuiListClipper higher-level helper if you can.
IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags flags = 0); // helper to create a child window / scrolling region that looks like a normal widget frame
IMGUI_API void EndChildFrame(); // always call EndChildFrame() regardless of BeginChildFrame() return values (which indicates a collapsed/clipped window)
+ // Text Utilities
+ IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
+
// Color Utilities
IMGUI_API ImVec4 ColorConvertU32ToFloat4(ImU32 in);
IMGUI_API ImU32 ColorConvertFloat4ToU32(const ImVec4& in);
IMGUI_API void ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v);
IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
- // Inputs Utilities
+ // Inputs Utilities: Keyboard
+ // - For 'int user_key_index' you can use your own indices/enums according to how your backend/engine stored them in io.KeysDown[].
+ // - We don't know the meaning of those value. You can use GetKeyIndex() to map a ImGuiKey_ value into the user index.
IMGUI_API int GetKeyIndex(ImGuiKey imgui_key); // map ImGuiKey_* values into user's key index. == io.KeyMap[key]
- IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index]. note that imgui doesn't know the semantic of each entry of io.KeysDown[]. Use your own indices/enums according to how your backend/engine stored them into io.KeysDown[]!
- IMGUI_API bool IsKeyPressed(int user_key_index, bool repeat = true); // was key pressed (went from !Down to Down). if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate
- IMGUI_API bool IsKeyReleased(int user_key_index); // was key released (went from Down to !Down)..
+ IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index].
+ IMGUI_API bool IsKeyPressed(int user_key_index, bool repeat = true); // was key pressed (went from !Down to Down)? if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate
+ IMGUI_API bool IsKeyReleased(int user_key_index); // was key released (went from Down to !Down)?
IMGUI_API int GetKeyPressedAmount(int key_index, float repeat_delay, float rate); // uses provided repeat rate/delay. return a count, most often 0 or 1 but might be >1 if RepeatRate is small enough that DeltaTime > RepeatRate
- IMGUI_API bool IsMouseDown(int button); // is mouse button held (0=left, 1=right, 2=middle)
- IMGUI_API bool IsAnyMouseDown(); // is any mouse button held
- IMGUI_API bool IsMouseClicked(int button, bool repeat = false); // did mouse button clicked (went from !Down to Down) (0=left, 1=right, 2=middle)
- IMGUI_API bool IsMouseDoubleClicked(int button); // did mouse button double-clicked. a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime.
- IMGUI_API bool IsMouseReleased(int button); // did mouse button released (went from Down to !Down)
- IMGUI_API bool IsMouseDragging(int button = 0, float lock_threshold = -1.0f); // is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold
- IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true); // is mouse hovering given bounding rect (in screen space). clipped by current clipping settings, but disregarding of other consideration of focus/window ordering/popup-block.
- IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); // by convention we use (-FLT_MAX,-FLT_MAX) to denote that there is no mouse
+ IMGUI_API void CaptureKeyboardFromApp(bool want_capture_keyboard_value = true); // attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle). e.g. force capture keyboard when your widget is being hovered. This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard_value"; after the next NewFrame() call.
+
+ // Inputs Utilities: Mouse
+ // - To refer to a mouse button, you may use named enums in your code e.g. ImGuiMouseButton_Left, ImGuiMouseButton_Right.
+ // - You can also use regular integer: it is forever guaranteed that 0=Left, 1=Right, 2=Middle.
+ // - Dragging operations are only reported after mouse has moved a certain distance away from the initial clicking position (see 'lock_threshold' and 'io.MouseDraggingThreshold')
+ IMGUI_API bool IsMouseDown(ImGuiMouseButton button); // is mouse button held?
+ IMGUI_API bool IsMouseClicked(ImGuiMouseButton button, bool repeat = false); // did mouse button clicked? (went from !Down to Down)
+ IMGUI_API bool IsMouseReleased(ImGuiMouseButton button); // did mouse button released? (went from Down to !Down)
+ IMGUI_API bool IsMouseDoubleClicked(ImGuiMouseButton button); // did mouse button double-clicked? a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime.
+ IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true);// is mouse hovering given bounding rect (in screen space). clipped by current clipping settings, but disregarding of other consideration of focus/window ordering/popup-block.
+ IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); // by convention we use (-FLT_MAX,-FLT_MAX) to denote that there is no mouse available
+ IMGUI_API bool IsAnyMouseDown(); // is any mouse button held?
IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
- IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve backup of mouse position at the time of opening popup we have BeginPopup() into
- IMGUI_API ImVec2 GetMouseDragDelta(int button = 0, float lock_threshold = -1.0f); // return the delta from the initial clicking position while the mouse button is pressed or was just released. This is locked and return 0.0f until the mouse moves past a distance threshold at least once. If lock_threshold < -1.0f uses io.MouseDraggingThreshold.
- IMGUI_API void ResetMouseDragDelta(int button = 0); //
+ IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve mouse position at the time of opening popup we have BeginPopup() into (helper to avoid user backing that value themselves)
+ IMGUI_API bool IsMouseDragging(ImGuiMouseButton button, float lock_threshold = -1.0f); // is mouse dragging? (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold)
+ IMGUI_API ImVec2 GetMouseDragDelta(ImGuiMouseButton button = 0, float lock_threshold = -1.0f); // return the delta from the initial clicking position while the mouse button is pressed or was just released. This is locked and return 0.0f until the mouse moves past a distance threshold at least once (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold)
+ IMGUI_API void ResetMouseDragDelta(ImGuiMouseButton button = 0); //
IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired cursor type, reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you
- IMGUI_API void SetMouseCursor(ImGuiMouseCursor type); // set desired cursor type
- IMGUI_API void CaptureKeyboardFromApp(bool want_capture_keyboard_value = true); // attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle). e.g. force capture keyboard when your widget is being hovered. This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard_value"; after the next NewFrame() call.
+ IMGUI_API void SetMouseCursor(ImGuiMouseCursor cursor_type); // set desired cursor type
IMGUI_API void CaptureMouseFromApp(bool want_capture_mouse_value = true); // attention: misleading name! manually override io.WantCaptureMouse flag next frame (said flag is entirely left for your application to handle). This is equivalent to setting "io.WantCaptureMouse = want_capture_mouse_value;" after the next NewFrame() call.
- // Clipboard Utilities (also see the LogToClipboard() function to capture or output text data to the clipboard)
+ // Clipboard Utilities
+ // - Also see the LogToClipboard() function to capture GUI into clipboard, or easily output text data to the clipboard.
IMGUI_API const char* GetClipboardText();
IMGUI_API void SetClipboardText(const char* text);
@@ -722,6 +746,9 @@ namespace ImGui
IMGUI_API void SaveIniSettingsToDisk(const char* ini_filename); // this is automatically called (if io.IniFilename is not empty) a few seconds after any modification that should be reflected in the .ini file (and also by DestroyContext).
IMGUI_API const char* SaveIniSettingsToMemory(size_t* out_ini_size = NULL); // return a zero-terminated string with the .ini data which you can save by your own mean. call when io.WantSaveIniSettings is set, then save data by your own mean and clear io.WantSaveIniSettings.
+ // Debug Utilities
+ IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert, size_t sz_drawidx); // This is called by IMGUI_CHECKVERSION() macro.
+
// Memory Allocators
// - All those functions are not reliant on the current context.
// - If you reload the contents of imgui.cpp at runtime, you may need to call SetCurrentContext() + SetAllocatorFunctions() again because we use global storage for those.
@@ -729,16 +756,6 @@ namespace ImGui
IMGUI_API void* MemAlloc(size_t size);
IMGUI_API void MemFree(void* ptr);
- // (Optional) Platform/OS interface for multi-viewport support
- // Note: You may use GetWindowViewport() to get the current viewport of the current window.
- IMGUI_API ImGuiPlatformIO& GetPlatformIO(); // platform/renderer functions, for back-end to setup + viewports list.
- IMGUI_API ImGuiViewport* GetMainViewport(); // main viewport. same as GetPlatformIO().MainViewport == GetPlatformIO().Viewports[0].
- IMGUI_API void UpdatePlatformWindows(); // call in main loop. will call CreateWindow/ResizeWindow/etc. platform functions for each secondary viewport, and DestroyWindow for each inactive viewport.
- IMGUI_API void RenderPlatformWindowsDefault(void* platform_arg = NULL, void* renderer_arg = NULL); // call in main loop. will call RenderWindow/SwapBuffers platform functions for each secondary viewport which doesn't have the ImGuiViewportFlags_Minimized flag set. May be reimplemented by user for custom rendering needs.
- IMGUI_API void DestroyPlatformWindows(); // call DestroyWindow platform functions for all viewports. call from back-end Shutdown() if you need to close platform windows before imgui shutdown. otherwise will be called by DestroyContext().
- IMGUI_API ImGuiViewport* FindViewportByID(ImGuiID id); // this is a helper for back-ends.
- IMGUI_API ImGuiViewport* FindViewportByPlatformHandle(void* platform_handle); // this is a helper for back-ends. the type platform_handle is decided by the back-end (e.g. HWND, MyWindow*, GLFWwindow* etc.)
-
} // namespace ImGui
//-----------------------------------------------------------------------------
@@ -754,7 +771,7 @@ enum ImGuiWindowFlags_
ImGuiWindowFlags_NoMove = 1 << 2, // Disable user moving the window
ImGuiWindowFlags_NoScrollbar = 1 << 3, // Disable scrollbars (window can still scroll with mouse or programmatically)
ImGuiWindowFlags_NoScrollWithMouse = 1 << 4, // Disable user vertically scrolling with mouse wheel. On child window, mouse wheel will be forwarded to the parent unless NoScrollbar is also set.
- ImGuiWindowFlags_NoCollapse = 1 << 5, // Disable user collapsing window by double-clicking on it. Also referred to as "window menu button" within a docking node.
+ ImGuiWindowFlags_NoCollapse = 1 << 5, // Disable user collapsing window by double-clicking on it
ImGuiWindowFlags_AlwaysAutoResize = 1 << 6, // Resize every window to its content every frame
ImGuiWindowFlags_NoBackground = 1 << 7, // Disable drawing background color (WindowBg, etc.) and outside border. Similar as using SetNextWindowBgAlpha(0.0f).
ImGuiWindowFlags_NoSavedSettings = 1 << 8, // Never load/save settings in .ini file
@@ -769,8 +786,6 @@ enum ImGuiWindowFlags_
ImGuiWindowFlags_NoNavInputs = 1 << 18, // No gamepad/keyboard navigation within the window
ImGuiWindowFlags_NoNavFocus = 1 << 19, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB)
ImGuiWindowFlags_UnsavedDocument = 1 << 20, // Append '*' to title without affecting the ID, as a convenience to avoid using the ### operator. When used in a tab/docking context, tab is selected on closure and closure is deferred by one frame to allow code to cancel the closure (with a confirmation popup, etc.) without flicker.
- ImGuiWindowFlags_NoDocking = 1 << 21, // Disable docking of this window
-
ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse,
ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
@@ -781,12 +796,11 @@ enum ImGuiWindowFlags_
ImGuiWindowFlags_Tooltip = 1 << 25, // Don't use! For internal use by BeginTooltip()
ImGuiWindowFlags_Popup = 1 << 26, // Don't use! For internal use by BeginPopup()
ImGuiWindowFlags_Modal = 1 << 27, // Don't use! For internal use by BeginPopupModal()
- ImGuiWindowFlags_ChildMenu = 1 << 28, // Don't use! For internal use by BeginMenu()
- ImGuiWindowFlags_DockNodeHost = 1 << 29 // Don't use! For internal use by Begin()/NewFrame()
+ ImGuiWindowFlags_ChildMenu = 1 << 28 // Don't use! For internal use by BeginMenu()
// [Obsolete]
- //ImGuiWindowFlags_ShowBorders = 1 << 7, // --> Set style.FrameBorderSize=1.0f / style.WindowBorderSize=1.0f to enable borders around windows and items
- //ImGuiWindowFlags_ResizeFromAnySide = 1 << 17, // --> Set io.ConfigWindowsResizeFromEdges and make sure mouse cursors are supported by back-end (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors)
+ //ImGuiWindowFlags_ShowBorders = 1 << 7, // --> Set style.FrameBorderSize=1.0f or style.WindowBorderSize=1.0f to enable borders around items or windows.
+ //ImGuiWindowFlags_ResizeFromAnySide = 1 << 17, // --> Set io.ConfigWindowsResizeFromEdges=true and make sure mouse cursors are supported by back-end (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors)
};
// Flags for ImGui::InputText()
@@ -837,11 +851,6 @@ enum ImGuiTreeNodeFlags_
ImGuiTreeNodeFlags_NavLeftJumpsBackHere = 1 << 13, // (WIP) Nav: left direction may move to this TreeNode() from any of its child (items submitted between TreeNode and TreePop)
//ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 14, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible
ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_NoAutoOpenOnLog
-
- // Obsolete names (will be removed)
-#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
- , ImGuiTreeNodeFlags_AllowOverlapMode = ImGuiTreeNodeFlags_AllowItemOverlap // [renamed in 1.53]
-#endif
};
// Flags for ImGui::Selectable()
@@ -901,12 +910,12 @@ enum ImGuiFocusedFlags_
ImGuiFocusedFlags_None = 0,
ImGuiFocusedFlags_ChildWindows = 1 << 0, // IsWindowFocused(): Return true if any children of the window is focused
ImGuiFocusedFlags_RootWindow = 1 << 1, // IsWindowFocused(): Test from root window (top most parent of the current hierarchy)
- ImGuiFocusedFlags_AnyWindow = 1 << 2, // IsWindowFocused(): Return true if any window is focused. Important: If you are trying to tell how to dispatch your low-level inputs, do NOT use this. Use ImGui::GetIO().WantCaptureMouse instead.
+ ImGuiFocusedFlags_AnyWindow = 1 << 2, // IsWindowFocused(): Return true if any window is focused. Important: If you are trying to tell how to dispatch your low-level inputs, do NOT use this. Use 'io.WantCaptureMouse' instead! Please read the FAQ!
ImGuiFocusedFlags_RootAndChildWindows = ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows
};
// Flags for ImGui::IsItemHovered(), ImGui::IsWindowHovered()
-// Note: if you are trying to check whether your mouse should be dispatched to imgui or to your app, you should use the 'io.WantCaptureMouse' boolean for that. Please read the FAQ!
+// Note: if you are trying to check whether your mouse should be dispatched to Dear ImGui or to your app, you should use 'io.WantCaptureMouse' instead! Please read the FAQ!
// Note: windows with the ImGuiWindowFlags_NoInputs flag are ignored by IsWindowHovered() calls.
enum ImGuiHoveredFlags_
{
@@ -923,21 +932,6 @@ enum ImGuiHoveredFlags_
ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows
};
-// Flags for ImGui::DockSpace(), shared/inherited by child nodes.
-// (Some flags can be applied to individual nodes directly)
-// FIXME-DOCK: Also see ImGuiDockNodeFlagsPrivate_ which may involve using the WIP and internal DockBuilder api.
-enum ImGuiDockNodeFlags_
-{
- ImGuiDockNodeFlags_None = 0,
- ImGuiDockNodeFlags_KeepAliveOnly = 1 << 0, // Shared // Don't display the dockspace node but keep it alive. Windows docked into this dockspace node won't be undocked.
- //ImGuiDockNodeFlags_NoCentralNode = 1 << 1, // Shared // Disable Central Node (the node which can stay empty)
- ImGuiDockNodeFlags_NoDockingInCentralNode = 1 << 2, // Shared // Disable docking inside the Central Node, which will be always kept empty.
- ImGuiDockNodeFlags_PassthruCentralNode = 1 << 3, // Shared // Enable passthru dockspace: 1) DockSpace() will render a ImGuiCol_WindowBg background covering everything excepted the Central Node when empty. Meaning the host window should probably use SetNextWindowBgAlpha(0.0f) prior to Begin() when using this. 2) When Central Node is empty: let inputs pass-through + won't display a DockingEmptyBg background. See demo for details.
- ImGuiDockNodeFlags_NoSplit = 1 << 4, // Shared/Local // Disable splitting the node into smaller nodes. Useful e.g. when embedding dockspaces into a main root one (the root one may have splitting disabled to reduce confusion). Note: when turned off, existing splits will be preserved.
- ImGuiDockNodeFlags_NoResize = 1 << 5, // Shared/Local // Disable resizing node using the splitter/separators. Useful with programatically setup dockspaces.
- ImGuiDockNodeFlags_AutoHideTabBar = 1 << 6 // Shared/Local // Tab bar will automatically hide when there is a single window in the dock node.
-};
-
// Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload()
enum ImGuiDragDropFlags_
{
@@ -1006,16 +1000,26 @@ enum ImGuiKey_
ImGuiKey_Enter,
ImGuiKey_Escape,
ImGuiKey_KeyPadEnter,
- ImGuiKey_A, // for text edit CTRL+A: select all
- ImGuiKey_C, // for text edit CTRL+C: copy
- ImGuiKey_V, // for text edit CTRL+V: paste
- ImGuiKey_X, // for text edit CTRL+X: cut
- ImGuiKey_Y, // for text edit CTRL+Y: redo
- ImGuiKey_Z, // for text edit CTRL+Z: undo
+ ImGuiKey_A, // for text edit CTRL+A: select all
+ ImGuiKey_C, // for text edit CTRL+C: copy
+ ImGuiKey_V, // for text edit CTRL+V: paste
+ ImGuiKey_X, // for text edit CTRL+X: cut
+ ImGuiKey_Y, // for text edit CTRL+Y: redo
+ ImGuiKey_Z, // for text edit CTRL+Z: undo
ImGuiKey_COUNT
};
-// Gamepad/Keyboard directional navigation
+// To test io.KeyMods (which is a combination of individual fields io.KeyCtrl, io.KeyShift, io.KeyAlt set by user/back-end)
+enum ImGuiKeyModFlags_
+{
+ ImGuiKeyModFlags_None = 0,
+ ImGuiKeyModFlags_Ctrl = 1 << 0,
+ ImGuiKeyModFlags_Shift = 1 << 1,
+ ImGuiKeyModFlags_Alt = 1 << 2,
+ ImGuiKeyModFlags_Super = 1 << 3
+};
+
+// Gamepad/Keyboard navigation
// Keyboard: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays.
// Gamepad: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. Back-end: set ImGuiBackendFlags_HasGamepad and fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
// Read instructions in imgui.cpp for more details. Download PNG/PSD at http://goo.gl/9LgVZW.
@@ -1061,15 +1065,6 @@ enum ImGuiConfigFlags_
ImGuiConfigFlags_NoMouse = 1 << 4, // Instruct imgui to clear mouse position/buttons in NewFrame(). This allows ignoring the mouse information set by the back-end.
ImGuiConfigFlags_NoMouseCursorChange = 1 << 5, // Instruct back-end to not alter mouse cursor shape and visibility. Use if the back-end cursor changes are interfering with yours and you don't want to use SetMouseCursor() to change mouse cursor. You may want to honor requests from imgui by reading GetMouseCursor() yourself instead.
- // [BETA] Docking
- ImGuiConfigFlags_DockingEnable = 1 << 6, // Docking enable flags.
-
- // [BETA] Viewports
- // When using viewports it is recommended that your default value for ImGuiCol_WindowBg is opaque (Alpha=1.0) so transition to a viewport won't be noticeable.
- ImGuiConfigFlags_ViewportsEnable = 1 << 10, // Viewport enable flags (require both ImGuiConfigFlags_PlatformHasViewports + ImGuiConfigFlags_RendererHasViewports set by the respective back-ends)
- ImGuiConfigFlags_DpiEnableScaleViewports= 1 << 14, // [BETA: Don't use] FIXME-DPI: Reposition and resize imgui windows when the DpiScale of a viewport changed (mostly useful for the main viewport hosting other window). Note that resizing the main window itself is up to your application.
- ImGuiConfigFlags_DpiEnableScaleFonts = 1 << 15, // [BETA: Don't use] FIXME-DPI: Request bitmap-scaled fonts to match DpiScale. This is a very low-quality workaround. The correct way to handle DPI is _currently_ to replace the atlas and/or fonts in the Platform_OnChangedViewport callback, but this is all early work in progress.
-
// User storage (to allow your back-end/engine to communicate to code that may be shared between multiple projects. Those flags are not used by core Dear ImGui)
ImGuiConfigFlags_IsSRGB = 1 << 20, // Application is SRGB-aware.
ImGuiConfigFlags_IsTouchScreen = 1 << 21 // Application is using a touch screen instead of a mouse.
@@ -1082,12 +1077,7 @@ enum ImGuiBackendFlags_
ImGuiBackendFlags_HasGamepad = 1 << 0, // Back-end Platform supports gamepad and currently has one connected.
ImGuiBackendFlags_HasMouseCursors = 1 << 1, // Back-end Platform supports honoring GetMouseCursor() value to change the OS cursor shape.
ImGuiBackendFlags_HasSetMousePos = 1 << 2, // Back-end Platform supports io.WantSetMousePos requests to reposition the OS mouse position (only used if ImGuiConfigFlags_NavEnableSetMousePos is set).
- ImGuiBackendFlags_RendererHasVtxOffset = 1 << 3, // Back-end Renderer supports ImDrawCmd::VtxOffset. This enables output of large meshes (64K+ vertices) while still using 16-bits indices.
-
- // [BETA] Viewports
- ImGuiBackendFlags_PlatformHasViewports = 1 << 10, // Back-end Platform supports multiple viewports.
- ImGuiBackendFlags_HasMouseHoveredViewport=1 << 11, // Back-end Platform supports setting io.MouseHoveredViewport to the viewport directly under the mouse _IGNORING_ viewports with the ImGuiViewportFlags_NoInputs flag and _REGARDLESS_ of whether another viewport is focused and may be capturing the mouse. This information is _NOT EASY_ to provide correctly with most high-level engines! Don't set this without studying how the examples/ back-end handle it!
- ImGuiBackendFlags_RendererHasViewports = 1 << 12 // Back-end Renderer supports multiple viewports.
+ ImGuiBackendFlags_RendererHasVtxOffset = 1 << 3 // Back-end Renderer supports ImDrawCmd::VtxOffset. This enables output of large meshes (64K+ vertices) while still using 16-bit indices.
};
// Enumeration for PushStyleColor() / PopStyleColor()
@@ -1131,8 +1121,6 @@ enum ImGuiCol_
ImGuiCol_TabActive,
ImGuiCol_TabUnfocused,
ImGuiCol_TabUnfocusedActive,
- ImGuiCol_DockingPreview,
- ImGuiCol_DockingEmptyBg, // Background color for empty node (e.g. CentralNode with no window docked into it)
ImGuiCol_PlotLines,
ImGuiCol_PlotLinesHovered,
ImGuiCol_PlotHistogram,
@@ -1148,15 +1136,17 @@ enum ImGuiCol_
// Obsolete names (will be removed)
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
, ImGuiCol_ModalWindowDarkening = ImGuiCol_ModalWindowDimBg // [renamed in 1.63]
- , ImGuiCol_ChildWindowBg = ImGuiCol_ChildBg // [renamed in 1.53]
- //ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered, // [unused since 1.60+] the close button now uses regular button colors.
- //ImGuiCol_ComboBg, // [unused since 1.53+] ComboBg has been merged with PopupBg, so a redirect isn't accurate.
+ //, ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered// [unused since 1.60+] the close button now uses regular button colors.
#endif
};
// Enumeration for PushStyleVar() / PopStyleVar() to temporarily modify the ImGuiStyle structure.
-// NB: the enum only refers to fields of ImGuiStyle which makes sense to be pushed/popped inside UI code. During initialization, feel free to just poke into ImGuiStyle directly.
-// NB: if changing this enum, you need to update the associated internal table GStyleVarInfo[] accordingly. This is where we link enum values to members offset/type.
+// - The enum only refers to fields of ImGuiStyle which makes sense to be pushed/popped inside UI code.
+// During initialization or between frames, feel free to just poke into ImGuiStyle directly.
+// - Tip: Use your programming IDE navigation facilities on the names in the _second column_ below to find the actual members and their description.
+// In Visual Studio IDE: CTRL+comma ("Edit.NavigateTo") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
+// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments.
+// - When changing this enum, you need to update the associated internal table GStyleVarInfo[] accordingly. This is where we link enum values to members offset/type.
enum ImGuiStyleVar_
{
// Enum name --------------------- // Member in ImGuiStyle structure (see ImGuiStyle for descriptions)
@@ -1187,8 +1177,7 @@ enum ImGuiStyleVar_
// Obsolete names (will be removed)
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
- , ImGuiStyleVar_Count_ = ImGuiStyleVar_COUNT // [renamed in 1.60]
- , ImGuiStyleVar_ChildWindowRounding = ImGuiStyleVar_ChildRounding // [renamed in 1.53]
+ , ImGuiStyleVar_Count_ = ImGuiStyleVar_COUNT // [renamed in 1.60]
#endif
};
@@ -1205,6 +1194,7 @@ enum ImGuiColorEditFlags_
ImGuiColorEditFlags_NoLabel = 1 << 7, // // ColorEdit, ColorPicker: disable display of inline text label (the label is still forwarded to the tooltip and picker).
ImGuiColorEditFlags_NoSidePreview = 1 << 8, // // ColorPicker: disable bigger color preview on right side of the picker, use small colored square preview instead.
ImGuiColorEditFlags_NoDragDrop = 1 << 9, // // ColorEdit: disable drag and drop target. ColorButton: disable drag and drop source.
+ ImGuiColorEditFlags_NoBorder = 1 << 10, // // ColorButton: disable border (which is enforced by default)
// User Options (right-click on widget to change some of them).
ImGuiColorEditFlags_AlphaBar = 1 << 16, // // ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker.
@@ -1237,6 +1227,16 @@ enum ImGuiColorEditFlags_
#endif
};
+// Identify a mouse button.
+// Those values are guaranteed to be stable and we frequently use 0/1 directly. Named enums provided for convenience.
+enum ImGuiMouseButton_
+{
+ ImGuiMouseButton_Left = 0,
+ ImGuiMouseButton_Right = 1,
+ ImGuiMouseButton_Middle = 2,
+ ImGuiMouseButton_COUNT = 5
+};
+
// Enumeration for GetMouseCursor()
// User code may request binding to display given cursor by calling SetMouseCursor(), which is why we have some cursors that are marked unused here
enum ImGuiMouseCursor_
@@ -1250,6 +1250,7 @@ enum ImGuiMouseCursor_
ImGuiMouseCursor_ResizeNESW, // When hovering over the bottom-left corner of a window
ImGuiMouseCursor_ResizeNWSE, // When hovering over the bottom-right corner of a window
ImGuiMouseCursor_Hand, // (Unused by Dear ImGui functions. Use for e.g. hyperlinks)
+ ImGuiMouseCursor_NotAllowed, // When hovering something with disallowed interaction. Usually a crossed circle.
ImGuiMouseCursor_COUNT
// Obsolete names (will be removed)
@@ -1258,7 +1259,7 @@ enum ImGuiMouseCursor_
#endif
};
-// Enumateration for ImGui::SetWindow***(), SetNextWindow***(), SetNextItem***() functions
+// Enumeration for ImGui::SetWindow***(), SetNextWindow***(), SetNextItem***() functions
// Represent a condition.
// Important: Treat as a regular enum! Do NOT combine multiple values using binary operators! All the functions above treat 0 as a shortcut to ImGuiCond_Always.
enum ImGuiCond_
@@ -1288,10 +1289,12 @@ template void IM_DELETE(T* p) { if (p) { p->~T(); ImGui::MemFree(p
//-----------------------------------------------------------------------------
// Helper: ImVector<>
// Lightweight std::vector<>-like class to avoid dragging dependencies (also, some implementations of STL with debug enabled are absurdly slow, we bypass it so our code runs fast in debug).
-// You generally do NOT need to care or use this ever. But we need to make it available in imgui.h because some of our data structures are relying on it.
-// Important: clear() frees memory, resize(0) keep the allocated buffer. We use resize(0) a lot to intentionally recycle allocated buffers across frames and amortize our costs.
-// Important: our implementation does NOT call C++ constructors/destructors, we treat everything as raw data! This is intentional but be extra mindful of that,
-// do NOT use this class as a std::vector replacement in your own code! Many of the structures used by dear imgui can be safely initialized by a zero-memset.
+//-----------------------------------------------------------------------------
+// - You generally do NOT need to care or use this ever. But we need to make it available in imgui.h because some of our public structures are relying on it.
+// - We use std-like naming convention here, which is a little unusual for this codebase.
+// - Important: clear() frees memory, resize(0) keep the allocated buffer. We use resize(0) a lot to intentionally recycle allocated buffers across frames and amortize our costs.
+// - Important: our implementation does NOT call C++ constructors/destructors, we treat everything as raw data! This is intentional but be extra mindful of that,
+// Do NOT use this class as a std::vector replacement in your own code! Many of the structures used by dear imgui can be safely initialized by a zero-memset.
//-----------------------------------------------------------------------------
template
@@ -1333,6 +1336,7 @@ struct ImVector
inline int _grow_capacity(int sz) const { int new_capacity = Capacity ? (Capacity + Capacity/2) : 8; return new_capacity > sz ? new_capacity : sz; }
inline void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; }
inline void resize(int new_size, const T& v) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) memcpy(&Data[n], &v, sizeof(v)); Size = new_size; }
+ inline void shrink(int new_size) { IM_ASSERT(new_size <= Size); Size = new_size; } // Resize a vector to a smaller size, guaranteed not to cause a reallocation
inline void reserve(int new_capacity) { if (new_capacity <= Capacity) return; T* new_data = (T*)IM_ALLOC((size_t)new_capacity * sizeof(T)); if (Data) { memcpy(new_data, Data, (size_t)Size * sizeof(T)); IM_FREE(Data); } Data = new_data; Capacity = new_capacity; }
// NB: It is illegal to call push_back/push_front/insert with a reference pointing inside the ImVector data itself! e.g. v.push_back(v[10]) is forbidden.
@@ -1387,13 +1391,14 @@ struct ImGuiStyle
float TabBorderSize; // Thickness of border around tabs.
ImGuiDir ColorButtonPosition; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered).
- ImVec2 SelectableTextAlign; // Alignment of selectable text when selectable is larger than text. Defaults to (0.0f, 0.0f) (top-left aligned).
- ImVec2 DisplayWindowPadding; // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows.
+ ImVec2 SelectableTextAlign; // Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line.
+ ImVec2 DisplayWindowPadding; // Window position are clamped to be visible within the display area by at least this amount. Only applies to regular windows.
ImVec2 DisplaySafeAreaPadding; // If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets correctly!
float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later.
bool AntiAliasedLines; // Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU.
bool AntiAliasedFill; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
+ float CircleSegmentMaxError; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry.
ImVec4 Colors[ImGuiCol_COUNT];
IMGUI_API ImGuiStyle();
@@ -1414,7 +1419,7 @@ struct ImGuiIO
ImGuiConfigFlags ConfigFlags; // = 0 // See ImGuiConfigFlags_ enum. Set by user/application. Gamepad/keyboard navigation options, etc.
ImGuiBackendFlags BackendFlags; // = 0 // See ImGuiBackendFlags_ enum. Set by back-end (imgui_impl_xxx files or custom back-end) to communicate features supported by the back-end.
- ImVec2 DisplaySize; // // Main display size, in pixels. This is for the default viewport. Use BeginViewport() for other viewports.
+ ImVec2 DisplaySize; // // Main display size, in pixels.
float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds.
float IniSavingRate; // = 5.0f // Minimum time between saving positions/sizes to .ini file, in seconds.
const char* IniFilename; // = "imgui.ini" // Path to .ini file. Set NULL to disable automatic .ini loading/saving, if e.g. you want to manually load/save from memory.
@@ -1433,18 +1438,6 @@ struct ImGuiIO
ImFont* FontDefault; // = NULL // Font to use on NewFrame(). Use NULL to uses Fonts->Fonts[0].
ImVec2 DisplayFramebufferScale; // = (1, 1) // For retina display or other situations where window coordinates are different from framebuffer coordinates. This generally ends up in ImDrawData::FramebufferScale.
- // Docking options (when ImGuiConfigFlags_DockingEnable is set)
- bool ConfigDockingNoSplit; // = false // Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.
- bool ConfigDockingWithShift; // = false // Enable docking with holding Shift key (reduce visual noise, allows dropping in wider space)
- bool ConfigDockingAlwaysTabBar; // = false // [BETA] [FIXME: This currently creates regression with auto-sizing and general overhead] Make every single floating window display within a docking node.
- bool ConfigDockingTransparentPayload;// = false // [BETA] Make window or viewport transparent when docking and only display docking boxes on the target viewport. Useful if rendering of multiple viewport cannot be synced. Best used with ConfigViewportsNoAutoMerge.
-
- // Viewport options (when ImGuiConfigFlags_ViewportsEnable is set)
- bool ConfigViewportsNoAutoMerge; // = false; // Set to make all floating imgui windows always create their own viewport. Otherwise, they are merged into the main host viewports when overlapping it. May also set ImGuiViewportFlags_NoAutoMerge on individual viewport.
- bool ConfigViewportsNoTaskBarIcon; // = false // Disable default OS task bar icon flag for secondary viewports. When a viewport doesn't want a task bar icon, ImGuiViewportFlags_NoTaskBarIcon will be set on it.
- bool ConfigViewportsNoDecoration; // = true // [BETA] Disable default OS window decoration flag for secondary viewports. When a viewport doesn't want window decorations, ImGuiViewportFlags_NoDecoration will be set on it. Enabling decoration can create subsequent issues at OS levels (e.g. minimum window size).
- bool ConfigViewportsNoDefaultParent; // = false // Disable default OS parenting to main viewport for secondary viewports. By default, viewports are marked with ParentViewportId = , expecting the platform back-end to setup a parent/child relationship between the OS windows (some back-end may ignore this). Set to true if you want the default to be 0, then all viewports will be top-level OS windows.
-
// Miscellaneous options
bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by back-end implementations.
bool ConfigMacOSXBehaviors; // = defined(__APPLE__) // OS X style: Text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl (was called io.OptMacOSXBehaviors prior to 1.63)
@@ -1461,9 +1454,9 @@ struct ImGuiIO
// Optional: Platform/Renderer back-end name (informational only! will be displayed in About Window) + User data for back-end/wrappers to store their own stuff.
const char* BackendPlatformName; // = NULL
const char* BackendRendererName; // = NULL
- void* BackendPlatformUserData; // = NULL
- void* BackendRendererUserData; // = NULL
- void* BackendLanguageUserData; // = NULL
+ void* BackendPlatformUserData; // = NULL // User data for platform back-end
+ void* BackendRendererUserData; // = NULL // User data for renderer back-end
+ void* BackendLanguageUserData; // = NULL // User data for non C++ programming language back-end
// Optional: Access OS clipboard
// (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
@@ -1471,6 +1464,11 @@ struct ImGuiIO
void (*SetClipboardTextFn)(void* user_data, const char* text);
void* ClipboardUserData;
+ // Optional: Notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME on Windows)
+ // (default to use native imm32 api on Windows)
+ void (*ImeSetInputScreenPosFn)(int x, int y);
+ void* ImeWindowHandle; // = NULL // (Windows) Set this to your HWND to get automatic IME cursor positioning.
+
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
// [OBSOLETE since 1.60+] Rendering function, will be automatically called in Render(). Please call your rendering function yourself now!
// You can obtain the ImDrawData* by calling ImGui::GetDrawData() after Render(). See example applications if you are unsure of how to implement this.
@@ -1488,7 +1486,6 @@ struct ImGuiIO
bool MouseDown[5]; // Mouse buttons: 0=left, 1=right, 2=middle + extras. ImGui itself mostly only uses left button (BeginPopupContext** are using right button). Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API.
float MouseWheel; // Mouse wheel Vertical: 1 unit scrolls about 5 lines text.
float MouseWheelH; // Mouse wheel Horizontal. Most users don't have a mouse with an horizontal wheel, may not be filled by all back-ends.
- ImGuiID MouseHoveredViewport; // (Optional) When using multiple viewports: viewport the OS mouse cursor is hovering _IGNORING_ viewports with the ImGuiViewportFlags_NoInputs flag, and _REGARDLESS_ of whether another viewport is focused. Set io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport if you can provide this info. If you don't imgui will infer the value using the rectangles and last focused time of the viewports it knows about (ignoring other OS windows).
bool KeyCtrl; // Keyboard modifier pressed: Control
bool KeyShift; // Keyboard modifier pressed: Shift
bool KeyAlt; // Keyboard modifier pressed: Alt
@@ -1498,21 +1495,24 @@ struct ImGuiIO
// Functions
IMGUI_API void AddInputCharacter(unsigned int c); // Queue new character input
+ IMGUI_API void AddInputCharacterUTF16(ImWchar16 c); // Queue new character input from an UTF-16 character, it can be a surrogate
IMGUI_API void AddInputCharactersUTF8(const char* str); // Queue new characters input from an UTF-8 string
IMGUI_API void ClearInputCharacters(); // Clear the text input buffer manually
//------------------------------------------------------------------
- // Output - Retrieve after calling NewFrame()
+ // Output - Updated by NewFrame() or EndFrame()/Render()
+ // (when reading from the io.WantCaptureMouse, io.WantCaptureKeyboard flags to dispatch your inputs, it is
+ // generally easier and more correct to use their state BEFORE calling NewFrame(). See FAQ for details!)
//------------------------------------------------------------------
- bool WantCaptureMouse; // When io.WantCaptureMouse is true, imgui will use the mouse inputs, do not dispatch them to your main game/application (in both cases, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.).
- bool WantCaptureKeyboard; // When io.WantCaptureKeyboard is true, imgui will use the keyboard inputs, do not dispatch them to your main game/application (in both cases, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.).
- bool WantTextInput; // Mobile/console: when io.WantTextInput is true, you may display an on-screen keyboard. This is set by ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
- bool WantSetMousePos; // MousePos has been altered, back-end should reposition mouse on next frame. Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled.
- bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. IMPORTANT: You need to clear io.WantSaveIniSettings yourself.
- bool NavActive; // Directional navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
- bool NavVisible; // Directional navigation is visible and allowed (will handle ImGuiKey_NavXXX events).
- float Framerate; // Application framerate estimation, in frame per second. Solely for convenience. Rolling average estimation based on IO.DeltaTime over 120 frames
+ bool WantCaptureMouse; // Set when Dear ImGui will use mouse inputs, in this case do not dispatch them to your main game/application (either way, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.).
+ bool WantCaptureKeyboard; // Set when Dear ImGui will use keyboard inputs, in this case do not dispatch them to your main game/application (either way, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.).
+ bool WantTextInput; // Mobile/console: when set, you may display an on-screen keyboard. This is set by Dear ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
+ bool WantSetMousePos; // MousePos has been altered, back-end should reposition mouse on next frame. Rarely used! Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled.
+ bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. Important: clear io.WantSaveIniSettings yourself after saving!
+ bool NavActive; // Keyboard/Gamepad navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
+ bool NavVisible; // Keyboard/Gamepad navigation is visible and allowed (will handle ImGuiKey_NavXXX events).
+ float Framerate; // Application framerate estimate, in frame per second. Solely for convenience. Rolling average estimation based on io.DeltaTime over 120 frames.
int MetricsRenderVertices; // Vertices output during last call to Render()
int MetricsRenderIndices; // Indices output during last call to Render() = number of triangles * 3
int MetricsRenderWindows; // Number of visible windows
@@ -1521,9 +1521,10 @@ struct ImGuiIO
ImVec2 MouseDelta; // Mouse delta. Note that this is zero if either current or previous position are invalid (-FLT_MAX,-FLT_MAX), so a disappearing/reappearing mouse won't have a huge delta.
//------------------------------------------------------------------
- // [Internal] ImGui will maintain those fields. Forward compatibility not guaranteed!
+ // [Internal] Dear ImGui will maintain those fields. Forward compatibility not guaranteed!
//------------------------------------------------------------------
+ ImGuiKeyModFlags KeyMods; // Key mods flags (same as io.KeyCtrl/KeyShift/KeyAlt/KeySuper but merged into flags), updated by NewFrame()
ImVec2 MousePosPrev; // Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid)
ImVec2 MouseClickedPos[5]; // Position at time of clicking
double MouseClickedTime[5]; // Time of last click (used to figure out double-click)
@@ -1540,6 +1541,7 @@ struct ImGuiIO
float KeysDownDurationPrev[512]; // Previous duration the key has been down
float NavInputsDownDuration[ImGuiNavInput_COUNT];
float NavInputsDownDurationPrev[ImGuiNavInput_COUNT];
+ ImWchar16 InputQueueSurrogate; // For AddInputCharacterUTF16
ImVector InputQueueCharacters; // Queue of _characters_ input (obtained by platform back-end). Fill using AddInputCharacter() helper.
IMGUI_API ImGuiIO();
@@ -1594,20 +1596,6 @@ struct ImGuiSizeCallbackData
ImVec2 DesiredSize; // Read-write. Desired size, based on user's mouse position. Write to this field to restrain resizing.
};
-// [BETA] Rarely used / very advanced uses only. Use with SetNextWindowClass() and DockSpace() functions.
-// Provide hints to the platform back-end via altered viewport flags (enable/disable OS decoration, OS task bar icons, etc.) and OS level parent/child relationships.
-struct ImGuiWindowClass
-{
- ImGuiID ClassId; // User data. 0 = Default class (unclassed)
- ImGuiID ParentViewportId; // Hint for the platform back-end. If non-zero, the platform back-end can create a parent<>child relationship between the platform windows. Not conforming back-ends are free to e.g. parent every viewport to the main viewport or not.
- ImGuiViewportFlags ViewportFlagsOverrideSet; // Viewport flags to set when a window of this class owns a viewport. This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
- ImGuiViewportFlags ViewportFlagsOverrideClear; // Viewport flags to clear when a window of this class owns a viewport. This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
- bool DockingAlwaysTabBar; // Set to true to enforce windows of this class always having their own tab (equivalent of setting the global io.ConfigDockingAlwaysTabBar)
- bool DockingAllowUnclassed; // Set to true to allow windows of this class to be docked/merged with an unclassed window.
-
- ImGuiWindowClass() { ClassId = 0; ParentViewportId = 0; ViewportFlagsOverrideSet = ViewportFlagsOverrideClear = 0x00; DockingAlwaysTabBar = false; DockingAllowUnclassed = true; }
-};
-
// Data payload for Drag and Drop operations: AcceptDragDropPayload(), GetDragDropPayload()
struct ImGuiPayload
{
@@ -1659,17 +1647,6 @@ namespace ImGui
static inline bool IsAnyWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_AnyWindow); }
static inline bool IsAnyWindowHovered() { return IsWindowHovered(ImGuiHoveredFlags_AnyWindow); }
static inline ImVec2 CalcItemRectClosestPoint(const ImVec2& pos, bool on_edge = false, float outward = 0.f) { IM_UNUSED(on_edge); IM_UNUSED(outward); IM_ASSERT(0); return pos; }
- // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
- static inline void ShowTestWindow() { return ShowDemoWindow(); }
- static inline bool IsRootWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootWindow); }
- static inline bool IsRootWindowOrAnyChildFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); }
- static inline void SetNextWindowContentWidth(float w) { SetNextWindowContentSize(ImVec2(w, 0.0f)); }
- static inline float GetItemsLineHeightWithSpacing() { return GetFrameHeightWithSpacing(); }
- // OBSOLETED in 1.52 (between Aug 2017 and Oct 2017)
- IMGUI_API bool Begin(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha_override = -1.0f, ImGuiWindowFlags flags = 0); // Use SetNextWindowSize(size, ImGuiCond_FirstUseEver) + SetNextWindowBgAlpha() instead.
- static inline bool IsRootWindowOrAnyChildHovered() { return IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows); }
- static inline void AlignFirstTextHeightToWidgets() { AlignTextToFramePadding(); }
- void SetNextWindowPosCenter(ImGuiCond cond);
}
typedef ImGuiInputTextCallback ImGuiTextEditCallback; // OBSOLETED in 1.63 (from Aug 2018): made the names consistent
typedef ImGuiInputTextCallbackData ImGuiTextEditCallbackData;
@@ -1679,6 +1656,14 @@ typedef ImGuiInputTextCallbackData ImGuiTextEditCallbackData;
// Helpers
//-----------------------------------------------------------------------------
+// Helper: Unicode defines
+#define IM_UNICODE_CODEPOINT_INVALID 0xFFFD // Invalid Unicode code point (standard value).
+#ifdef IMGUI_USE_WCHAR32
+#define IM_UNICODE_CODEPOINT_MAX 0x10FFFF // Maximum Unicode code point supported by this build.
+#else
+#define IM_UNICODE_CODEPOINT_MAX 0xFFFF // Maximum Unicode code point supported by this build.
+#endif
+
// Helper: Execute a block of code at maximum once a frame. Convenient if you want to quickly create an UI within deep-nested code that runs multiple times every frame.
// Usage: static ImGuiOnceUponAFrame oaf; if (oaf) ImGui::Text("This will be called only once per frame");
struct ImGuiOnceUponAFrame
@@ -1722,11 +1707,11 @@ struct ImGuiTextBuffer
IMGUI_API static char EmptyString[1];
ImGuiTextBuffer() { }
- inline char operator[](int i) { IM_ASSERT(Buf.Data != NULL); return Buf.Data[i]; }
+ inline char operator[](int i) const { IM_ASSERT(Buf.Data != NULL); return Buf.Data[i]; }
const char* begin() const { return Buf.Data ? &Buf.front() : EmptyString; }
const char* end() const { return Buf.Data ? &Buf.back() : EmptyString; } // Buf is zero-terminated, so end() will point on the zero-terminator
int size() const { return Buf.Size ? Buf.Size - 1 : 0; }
- bool empty() { return Buf.Size <= 1; }
+ bool empty() const { return Buf.Size <= 1; }
void clear() { Buf.clear(); }
void reserve(int capacity) { Buf.reserve(capacity); }
const char* c_str() const { return Buf.Data ? Buf.Data : EmptyString; }
@@ -1801,9 +1786,13 @@ struct ImGuiStorage
// - Step 3: the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd), advance the cursor to the end of the list and then returns 'false' to end the loop.
struct ImGuiListClipper
{
- float StartPosY;
+ int DisplayStart, DisplayEnd;
+ int ItemsCount;
+
+ // [Internal]
+ int StepNo;
float ItemsHeight;
- int ItemsCount, StepNo, DisplayStart, DisplayEnd;
+ float StartPosY;
// items_count: Use -1 to ignore (you can call Begin later). Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step).
// items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing().
@@ -1816,7 +1805,7 @@ struct ImGuiListClipper
IMGUI_API void End(); // Automatically called on the last call of Step() that returns false.
};
-// Helpers macros to generate 32-bits encoded colors
+// Helpers macros to generate 32-bit encoded colors
#ifdef IMGUI_USE_BGRA_PACKED_COLOR
#define IM_COL32_R_SHIFT 16
#define IM_COL32_G_SHIFT 8
@@ -1861,7 +1850,7 @@ struct ImColor
// Hold a series of drawing commands. The user provides a renderer for ImDrawData which essentially contains an array of ImDrawList.
//-----------------------------------------------------------------------------
-// Draw callbacks for advanced uses.
+// ImDrawCallback: Draw callbacks for advanced uses [configurable type: override in imconfig.h]
// NB: You most likely do NOT need to use draw callbacks just to create your own widget or customized UI rendering,
// you can poke into the draw list for that! Draw callback may be useful for example to:
// A) Change your GPU render state,
@@ -1880,13 +1869,13 @@ typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* c
// Typically, 1 command = 1 GPU draw call (unless command is a callback)
// Pre 1.71 back-ends will typically ignore the VtxOffset/IdxOffset fields. When 'io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset'
-// is enabled, those fields allow us to render meshes larger than 64K vertices while keeping 16-bits indices.
+// is enabled, those fields allow us to render meshes larger than 64K vertices while keeping 16-bit indices.
struct ImDrawCmd
{
unsigned int ElemCount; // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[].
ImVec4 ClipRect; // Clipping rectangle (x1, y1, x2, y2). Subtract ImDrawData->DisplayPos to get clipping rectangle in "viewport" coordinates
ImTextureID TextureId; // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
- unsigned int VtxOffset; // Start offset in vertex buffer. Pre-1.71 or without ImGuiBackendFlags_RendererHasVtxOffset: always 0. With ImGuiBackendFlags_RendererHasVtxOffset: may be >0 to support meshes larger than 64K vertices with 16-bits indices.
+ unsigned int VtxOffset; // Start offset in vertex buffer. Pre-1.71 or without ImGuiBackendFlags_RendererHasVtxOffset: always 0. With ImGuiBackendFlags_RendererHasVtxOffset: may be >0 to support meshes larger than 64K vertices with 16-bit indices.
unsigned int IdxOffset; // Start offset in index buffer. Always equal to sum of ElemCount drawn so far.
ImDrawCallback UserCallback; // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally.
void* UserCallbackData; // The draw callback code can access this.
@@ -1894,9 +1883,9 @@ struct ImDrawCmd
ImDrawCmd() { ElemCount = 0; TextureId = (ImTextureID)NULL; VtxOffset = IdxOffset = 0; UserCallback = NULL; UserCallbackData = NULL; }
};
-// Vertex index
-// (to allow large meshes with 16-bits indices: set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset' and handle ImDrawCmd::VtxOffset in the renderer back-end)
-// (to use 32-bits indices: override with '#define ImDrawIdx unsigned int' in imconfig.h)
+// Vertex index, default to 16-bit
+// To allow large meshes with 16-bit indices: set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset' and handle ImDrawCmd::VtxOffset in the renderer back-end (recommended).
+// To use 32-bit indices: override with '#define ImDrawIdx unsigned int' in imconfig.h.
#ifndef ImDrawIdx
typedef unsigned short ImDrawIdx;
#endif
@@ -1969,7 +1958,7 @@ enum ImDrawListFlags_
// Each dear imgui window contains its own ImDrawList. You can use ImGui::GetWindowDrawList() to
// access the current window draw list and draw custom primitives.
// You can interleave normal ImGui:: calls and adding primitives to the current draw list.
-// All positions are generally in pixel coordinates (generally top-left at 0,0, bottom-right at io.DisplaySize, unless multiple viewports are used), but you are totally free to apply whatever transformation matrix to want to the data (if you apply such transformation you'll want to apply it to ClipRect as well)
+// All positions are generally in pixel coordinates (top-left at (0,0), bottom-right at io.DisplaySize), but you are totally free to apply whatever transformation matrix to want to the data (if you apply such transformation you'll want to apply it to ClipRect as well)
// Important: Primitives are always added to the list and not culled (culling is done at higher-level by ImGui:: functions), if you use this API a lot consider coarse culling your drawn objects.
struct ImDrawList
{
@@ -2004,8 +1993,11 @@ struct ImDrawList
// Primitives
// - For rectangular primitives, "p_min" and "p_max" represent the upper-left and lower-right corners.
+ // - For circle primitives, use "num_segments == 0" to automatically calculate tessellation (preferred).
+ // In future versions we will use textures to provide cheaper and higher-quality circles.
+ // Use AddNgon() and AddNgonFilled() functions if you need to guaranteed a specific number of sides.
IMGUI_API void AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness = 1.0f);
- IMGUI_API void AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding = 0.0f, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All, float thickness = 1.0f); // a: upper-left, b: lower-right (== upper-left + size), rounding_corners_flags: 4-bits corresponding to which corner to round
+ IMGUI_API void AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding = 0.0f, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All, float thickness = 1.0f); // a: upper-left, b: lower-right (== upper-left + size), rounding_corners_flags: 4 bits corresponding to which corner to round
IMGUI_API void AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding = 0.0f, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All); // a: upper-left, b: lower-right (== upper-left + size)
IMGUI_API void AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left);
IMGUI_API void AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness = 1.0f);
@@ -2014,11 +2006,13 @@ struct ImDrawList
IMGUI_API void AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col);
IMGUI_API void AddCircle(const ImVec2& center, float radius, ImU32 col, int num_segments = 12, float thickness = 1.0f);
IMGUI_API void AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments = 12);
+ IMGUI_API void AddNgon(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness = 1.0f);
+ IMGUI_API void AddNgonFilled(const ImVec2& center, float radius, ImU32 col, int num_segments);
IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL);
IMGUI_API void AddPolyline(const ImVec2* points, int num_points, ImU32 col, bool closed, float thickness);
IMGUI_API void AddConvexPolyFilled(const ImVec2* points, int num_points, ImU32 col); // Note: Anti-aliased filling requires points to be in clockwise order.
- IMGUI_API void AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments = 0);
+ IMGUI_API void AddBezierCurve(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments = 0);
// Image primitives
// - Read FAQ to understand what ImTextureID is.
@@ -2036,7 +2030,7 @@ struct ImDrawList
inline void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness); _Path.Size = 0; }
IMGUI_API void PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments = 10);
IMGUI_API void PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle
- IMGUI_API void PathBezierCurveTo(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, int num_segments = 0);
+ IMGUI_API void PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments = 0);
IMGUI_API void PathRect(const ImVec2& rect_min, const ImVec2& rect_max, float rounding = 0.0f, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All);
// Advanced
@@ -2045,8 +2039,11 @@ struct ImDrawList
IMGUI_API ImDrawList* CloneOutput() const; // Create a clone of the CmdBuffer/IdxBuffer/VtxBuffer.
// Advanced: Channels
- // - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit foreground primitives before background primitives)
- // - Use to minimize draw calls (e.g. if going back-and-forth between multiple non-overlapping clipping rectangles, prefer to append into separate channels then merge at the end)
+ // - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit FG primitives before BG primitives)
+ // - Use to minimize draw calls (e.g. if going back-and-forth between multiple clipping rectangles, prefer to append into separate channels then merge at the end)
+ // - FIXME-OBSOLETE: This API shouldn't have been in ImDrawList in the first place!
+ // Prefer using your own persistent copy of ImDrawListSplitter as you can stack them.
+ // Using the ImDrawList::ChannelsXXXX you cannot stack a split over another.
inline void ChannelsSplit(int count) { _Splitter.Split(this, count); }
inline void ChannelsMerge() { _Splitter.Merge(this); }
inline void ChannelsSetCurrent(int n) { _Splitter.SetCurrentChannel(this, n); }
@@ -2056,6 +2053,7 @@ struct ImDrawList
IMGUI_API void Clear();
IMGUI_API void ClearFreeMemory();
IMGUI_API void PrimReserve(int idx_count, int vtx_count);
+ IMGUI_API void PrimUnreserve(int idx_count, int vtx_count);
IMGUI_API void PrimRect(const ImVec2& a, const ImVec2& b, ImU32 col); // Axis aligned rectangle (composed of two triangles)
IMGUI_API void PrimRectUV(const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col);
IMGUI_API void PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col);
@@ -2079,12 +2077,11 @@ struct ImDrawData
ImVec2 DisplayPos; // Upper-left position of the viewport to render (== upper-left of the orthogonal projection matrix to use)
ImVec2 DisplaySize; // Size of the viewport to render (== io.DisplaySize for the main viewport) (DisplayPos + DisplaySize == lower-right of the orthogonal projection matrix to use)
ImVec2 FramebufferScale; // Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
- ImGuiViewport* OwnerViewport; // Viewport carrying the ImDrawData instance, might be of use to the renderer (generally not).
// Functions
ImDrawData() { Valid = false; Clear(); }
~ImDrawData() { Clear(); }
- void Clear() { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; DisplayPos = DisplaySize = FramebufferScale = ImVec2(0.f, 0.f); OwnerViewport = NULL; } // The ImDrawList are owned by ImGuiContext!
+ void Clear() { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; DisplayPos = DisplaySize = FramebufferScale = ImVec2(0.f, 0.f); } // The ImDrawList are owned by ImGuiContext!
IMGUI_API void DeIndexAllBuffers(); // Helper to convert all buffers from indexed to non-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
IMGUI_API void ScaleClipRects(const ImVec2& fb_scale); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than Dear ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
};
@@ -2120,9 +2117,12 @@ struct ImFontConfig
IMGUI_API ImFontConfig();
};
+// Hold rendering data for one glyph.
+// (Note: some language parsers may fail to convert the 31+1 bitfield members, in this case maybe drop store a single u32 or we can rework this)
struct ImFontGlyph
{
- ImWchar Codepoint; // 0x0000..0xFFFF
+ unsigned int Codepoint : 31; // 0x0000..0xFFFF
+ unsigned int Visible : 1; // Flag to allow early out when rendering
float AdvanceX; // Distance to next character (= data from font + ImFontConfig::GlyphExtraSpacing.x baked in)
float X0, Y0, X1, Y1; // Glyph corners
float U0, V0, U1, V1; // Texture coordinates
@@ -2134,11 +2134,11 @@ struct ImFontGlyphRangesBuilder
{
ImVector UsedChars; // Store 1-bit per Unicode code point (0=unused, 1=used)
- ImFontGlyphRangesBuilder() { Clear(); }
- inline void Clear() { int size_in_bytes = 0x10000 / 8; UsedChars.resize(size_in_bytes / (int)sizeof(ImU32)); memset(UsedChars.Data, 0, (size_t)size_in_bytes); }
- inline bool GetBit(int n) const { int off = (n >> 5); ImU32 mask = 1u << (n & 31); return (UsedChars[off] & mask) != 0; } // Get bit n in the array
- inline void SetBit(int n) { int off = (n >> 5); ImU32 mask = 1u << (n & 31); UsedChars[off] |= mask; } // Set bit n in the array
- inline void AddChar(ImWchar c) { SetBit(c); } // Add character
+ ImFontGlyphRangesBuilder() { Clear(); }
+ inline void Clear() { int size_in_bytes = (IM_UNICODE_CODEPOINT_MAX + 1) / 8; UsedChars.resize(size_in_bytes / (int)sizeof(ImU32)); memset(UsedChars.Data, 0, (size_t)size_in_bytes); }
+ inline bool GetBit(size_t n) const { int off = (int)(n >> 5); ImU32 mask = 1u << (n & 31); return (UsedChars[off] & mask) != 0; } // Get bit n in the array
+ inline void SetBit(size_t n) { int off = (int)(n >> 5); ImU32 mask = 1u << (n & 31); UsedChars[off] |= mask; } // Set bit n in the array
+ inline void AddChar(ImWchar c) { SetBit(c); } // Add character
IMGUI_API void AddText(const char* text, const char* text_end = NULL); // Add string (each character of the UTF-8 string are added)
IMGUI_API void AddRanges(const ImWchar* ranges); // Add ranges, e.g. builder.AddRanges(ImFontAtlas::GetGlyphRangesDefault()) to force add all of ASCII/Latin+Ext
IMGUI_API void BuildRanges(ImVector* out_ranges); // Output new ranges
@@ -2147,12 +2147,12 @@ struct ImFontGlyphRangesBuilder
// See ImFontAtlas::AddCustomRectXXX functions.
struct ImFontAtlasCustomRect
{
- unsigned int ID; // Input // User ID. Use <0x10000 to map into a font glyph, >=0x10000 for other/internal/custom texture data.
+ unsigned int ID; // Input // User ID. Use < 0x110000 to map into a font glyph, >= 0x110000 for other/internal/custom texture data.
unsigned short Width, Height; // Input // Desired rectangle dimension
unsigned short X, Y; // Output // Packed position in Atlas
- float GlyphAdvanceX; // Input // For custom font glyphs only (ID<0x10000): glyph xadvance
- ImVec2 GlyphOffset; // Input // For custom font glyphs only (ID<0x10000): glyph display offset
- ImFont* Font; // Input // For custom font glyphs only (ID<0x10000): target font
+ float GlyphAdvanceX; // Input // For custom font glyphs only (ID < 0x110000): glyph xadvance
+ ImVec2 GlyphOffset; // Input // For custom font glyphs only (ID < 0x110000): glyph display offset
+ ImFont* Font; // Input // For custom font glyphs only (ID < 0x110000): target font
ImFontAtlasCustomRect() { ID = 0xFFFFFFFF; Width = Height = 0; X = Y = 0xFFFF; GlyphAdvanceX = 0.0f; GlyphOffset = ImVec2(0,0); Font = NULL; }
bool IsPacked() const { return X != 0xFFFF; }
};
@@ -2204,7 +2204,7 @@ struct ImFontAtlas
IMGUI_API bool Build(); // Build pixels data. This is called automatically for you by the GetTexData*** functions.
IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel
IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel
- bool IsBuilt() { return Fonts.Size > 0 && (TexPixelsAlpha8 != NULL || TexPixelsRGBA32 != NULL); }
+ bool IsBuilt() const { return Fonts.Size > 0 && (TexPixelsAlpha8 != NULL || TexPixelsRGBA32 != NULL); }
void SetTexID(ImTextureID id) { TexID = id; }
//-------------------------------------------
@@ -2231,13 +2231,13 @@ struct ImFontAtlas
// After calling Build(), you can query the rectangle position and render your pixels.
// You can also request your rectangles to be mapped as font glyph (given a font + Unicode point),
// so you can render e.g. custom colorful icons and use them as regular glyphs.
- // Read misc/fonts/README.txt for more details about using colorful icons.
- IMGUI_API int AddCustomRectRegular(unsigned int id, int width, int height); // Id needs to be >= 0x10000. Id >= 0x80000000 are reserved for ImGui and ImDrawList
- IMGUI_API int AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset = ImVec2(0,0)); // Id needs to be < 0x10000 to register a rectangle to map into a specific font.
+ // Read docs/FONTS.txt for more details about using colorful icons.
+ IMGUI_API int AddCustomRectRegular(unsigned int id, int width, int height); // Id needs to be >= 0x110000. Id >= 0x80000000 are reserved for ImGui and ImDrawList
+ IMGUI_API int AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset = ImVec2(0,0)); // Id needs to be < 0x110000 to register a rectangle to map into a specific font.
const ImFontAtlasCustomRect*GetCustomRectByIndex(int index) const { if (index < 0) return NULL; return &CustomRects[index]; }
// [Internal]
- IMGUI_API void CalcCustomRectUV(const ImFontAtlasCustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max);
+ IMGUI_API void CalcCustomRectUV(const ImFontAtlasCustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max) const;
IMGUI_API bool GetMouseCursorTexData(ImGuiMouseCursor cursor, ImVec2* out_offset, ImVec2* out_size, ImVec2 out_uv_border[2], ImVec2 out_uv_fill[2]);
//-------------------------------------------
@@ -2290,10 +2290,11 @@ struct ImFont
short ConfigDataCount; // 2 // in // ~ 1 // Number of ImFontConfig involved in creating this font. Bigger than 1 when merging multiple font sources into one ImFont.
ImWchar FallbackChar; // 2 // in // = '?' // Replacement character if a glyph isn't found. Only set via SetFallbackChar()
ImWchar EllipsisChar; // 2 // out // = -1 // Character used for ellipsis rendering.
+ bool DirtyLookupTables; // 1 // out //
float Scale; // 4 // in // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
float Ascent, Descent; // 4+4 // out // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
int MetricsTotalSurface;// 4 // out // // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
- bool DirtyLookupTables; // 1 // out //
+ ImU8 Used4kPagesMap[(IM_UNICODE_CODEPOINT_MAX+1)/4096/8]; // 2 bytes if ImWchar=ImWchar16, 34 bytes if ImWchar==ImWchar32. Store 1-bit for each block of 4K codepoints that has one active glyph. This is mainly used to facilitate iterations accross all used codepoints.
// Methods
IMGUI_API ImFont();
@@ -2317,126 +2318,9 @@ struct ImFont
IMGUI_API void GrowIndex(int new_size);
IMGUI_API void AddGlyph(ImWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x);
IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built.
+ IMGUI_API void SetGlyphVisible(ImWchar c, bool visible);
IMGUI_API void SetFallbackChar(ImWchar c);
-
-#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
- typedef ImFontGlyph Glyph; // OBSOLETED in 1.52+
-#endif
-};
-
-//-----------------------------------------------------------------------------
-// [BETA] Platform interface for multi-viewport support
-// - completely optional, for advanced users!
-// - this is used for back-ends aiming to support the seamless creation of multiple viewport (= multiple Platform/OS windows)
-// dear imgui manages the viewports, and the back-end create one Platform/OS windows for each secondary viewport.
-// - if you are new to dear imgui and trying to integrate it into your engine, you should probably ignore this for now.
-//-----------------------------------------------------------------------------
-
-// (Optional) This is required when enabling multi-viewport. Represent the bounds of each connected monitor/display and their DPI.
-// We use this information for multiple DPI support + clamping the position of popups and tooltips so they don't straddle multiple monitors.
-struct ImGuiPlatformMonitor
-{
- ImVec2 MainPos, MainSize; // Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
- ImVec2 WorkPos, WorkSize; // (Optional) Coordinates without task bars / side bars / menu bars. imgui uses this to avoid positioning popups/tooltips inside this region.
- float DpiScale; // 1.0f = 96 DPI
- ImGuiPlatformMonitor() { MainPos = MainSize = WorkPos = WorkSize = ImVec2(0,0); DpiScale = 1.0f; }
-};
-
-// (Optional) Setup required only if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) is enabled.
-// Access via ImGui::GetPlatformIO(). This is designed so we can mix and match two imgui_impl_xxxx files,
-// one for the Platform (~window handling), one for Renderer. Custom engine back-ends will often provide
-// both Platform and Renderer interfaces and so may not need to use all functions.
-// Platform functions are typically called before their Renderer counterpart,
-// apart from Destroy which are called the other way.
-// RenderPlatformWindowsDefault() is that helper that iterate secondary viewports and call, in this order:
-// Platform_RenderWindow(), Renderer_RenderWindow(), Platform_SwapBuffers(), Renderer_SwapBuffers()
-// You may skip using RenderPlatformWindowsDefault() and call your draw/swap functions yourself if you need
-// specific behavior for your multi-window rendering.
-struct ImGuiPlatformIO
-{
- //------------------------------------------------------------------
- // Input - Back-end interface/functions + Monitor List
- //------------------------------------------------------------------
-
- // (Optional) Platform functions (e.g. Win32, GLFW, SDL2)
- // Most of them are called by ImGui::UpdatePlatformWindows() and ImGui::RenderPlatformWindowsDefault().
- void (*Platform_CreateWindow)(ImGuiViewport* vp); // Create a new platform window for the given viewport
- void (*Platform_DestroyWindow)(ImGuiViewport* vp);
- void (*Platform_ShowWindow)(ImGuiViewport* vp); // Newly created windows are initially hidden so SetWindowPos/Size/Title can be called on them first
- void (*Platform_SetWindowPos)(ImGuiViewport* vp, ImVec2 pos);
- ImVec2 (*Platform_GetWindowPos)(ImGuiViewport* vp);
- void (*Platform_SetWindowSize)(ImGuiViewport* vp, ImVec2 size);
- ImVec2 (*Platform_GetWindowSize)(ImGuiViewport* vp);
- void (*Platform_SetWindowFocus)(ImGuiViewport* vp); // Move window to front and set input focus
- bool (*Platform_GetWindowFocus)(ImGuiViewport* vp);
- bool (*Platform_GetWindowMinimized)(ImGuiViewport* vp);
- void (*Platform_SetWindowTitle)(ImGuiViewport* vp, const char* title);
- void (*Platform_SetWindowAlpha)(ImGuiViewport* vp, float alpha); // (Optional) Setup window transparency
- void (*Platform_UpdateWindow)(ImGuiViewport* vp); // (Optional) Called in UpdatePlatforms(). Optional hook to allow the platform back-end from doing general book-keeping every frame.
- void (*Platform_RenderWindow)(ImGuiViewport* vp, void* render_arg); // (Optional) Setup for render
- void (*Platform_SwapBuffers)(ImGuiViewport* vp, void* render_arg); // (Optional) Call Present/SwapBuffers (platform side)
- float (*Platform_GetWindowDpiScale)(ImGuiViewport* vp); // (Optional) [BETA] (FIXME-DPI) DPI handling: Return DPI scale for this viewport. 1.0f = 96 DPI.
- void (*Platform_OnChangedViewport)(ImGuiViewport* vp); // (Optional) [BETA] (FIXME-DPI) DPI handling: Called during Begin() every time the viewport we are outputting into changes, so back-end has a chance to swap fonts to adjust style.
- void (*Platform_SetImeInputPos)(ImGuiViewport* vp, ImVec2 pos); // (Optional) Set IME (Input Method Editor, e.g. for Asian languages) input position, so text preview appears over the imgui input box.
- int (*Platform_CreateVkSurface)(ImGuiViewport* vp, ImU64 vk_inst, const void* vk_allocators, ImU64* out_vk_surface); // (Optional) For Renderer to call into Platform code
-
- // (Optional) Renderer functions (e.g. DirectX, OpenGL3, Vulkan)
- void (*Renderer_CreateWindow)(ImGuiViewport* vp); // Create swap chains, frame buffers etc.
- void (*Renderer_DestroyWindow)(ImGuiViewport* vp);
- void (*Renderer_SetWindowSize)(ImGuiViewport* vp, ImVec2 size); // Resize swap chain, frame buffers etc.
- void (*Renderer_RenderWindow)(ImGuiViewport* vp, void* render_arg); // (Optional) Clear targets, Render viewport->DrawData
- void (*Renderer_SwapBuffers)(ImGuiViewport* vp, void* render_arg); // (Optional) Call Present/SwapBuffers (renderer side)
-
- // (Optional) List of monitors (updated by: app/back-end, used by: imgui to clamp popups/tooltips within same monitor and not have them straddle monitors)
- ImVector Monitors;
-
- //------------------------------------------------------------------
- // Output - List of viewports to render into platform windows
- //------------------------------------------------------------------
-
- // List of viewports (the list is updated by calling ImGui::EndFrame or ImGui::Render)
- ImGuiViewport* MainViewport; // Guaranteed to be == Viewports[0]
- ImVector Viewports; // Main viewports, followed by all secondary viewports.
- ImGuiPlatformIO() { memset(this, 0, sizeof(*this)); } // Zero clear
-};
-
-// Flags stored in ImGuiViewport::Flags, giving indications to the platform back-ends.
-enum ImGuiViewportFlags_
-{
- ImGuiViewportFlags_None = 0,
- ImGuiViewportFlags_NoDecoration = 1 << 0, // Platform Window: Disable platform decorations: title bar, borders, etc. (generally set all windows, but if ImGuiConfigFlags_ViewportsDecoration is set we only set this on popups/tooltips)
- ImGuiViewportFlags_NoTaskBarIcon = 1 << 1, // Platform Window: Disable platform task bar icon (generally set on popups/tooltips, or all windows if ImGuiConfigFlags_ViewportsNoTaskBarIcon is set)
- ImGuiViewportFlags_NoFocusOnAppearing = 1 << 2, // Platform Window: Don't take focus when created.
- ImGuiViewportFlags_NoFocusOnClick = 1 << 3, // Platform Window: Don't take focus when clicked on.
- ImGuiViewportFlags_NoInputs = 1 << 4, // Platform Window: Make mouse pass through so we can drag this window while peaking behind it.
- ImGuiViewportFlags_NoRendererClear = 1 << 5, // Platform Window: Renderer doesn't need to clear the framebuffer ahead (because we will fill it entirely).
- ImGuiViewportFlags_TopMost = 1 << 6, // Platform Window: Display on top (for tooltips only).
- ImGuiViewportFlags_Minimized = 1 << 7, // Platform Window: Window is minimized, can skip render. When minimized we tend to avoid using the viewport pos/size for clipping window or testing if they are contained in the viewport.
- ImGuiViewportFlags_NoAutoMerge = 1 << 8, // Platform Window: Avoid merging this widow into another host window. This can only be set via ImGuiWindowClass viewport flags override (because we need to now ahead if we are going to create a viewport in the first place!).
- ImGuiViewportFlags_CanHostOtherWindows = 1 << 9 // Main viewport: can host multiple imgui windows (secondary viewports are associated to a single window).
-};
-
-// The viewports created and managed by imgui. The role of the platform back-end is to create the platform/OS windows corresponding to each viewport.
-struct ImGuiViewport
-{
- ImGuiID ID; // Unique identifier for the viewport
- ImGuiViewportFlags Flags; // See ImGuiViewportFlags_
- ImVec2 Pos; // Position of viewport both in imgui space and in OS desktop/native space
- ImVec2 Size; // Size of viewport in pixel
- float DpiScale; // 1.0f = 96 DPI = No extra scale
- ImDrawData* DrawData; // The ImDrawData corresponding to this viewport. Valid after Render() and until the next call to NewFrame().
- ImGuiID ParentViewportId; // (Advanced) 0: no parent. Instruct the platform back-end to setup a parent/child relationship between platform windows.
-
- void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, frame-buffers etc.)
- void* PlatformUserData; // void* to hold custom data structure for the OS / platform (e.g. windowing info, render context)
- void* PlatformHandle; // void* for FindViewportByPlatformHandle(). (e.g. suggested to use natural platform handle such as HWND, GLFWWindow*, SDL_Window*)
- void* PlatformHandleRaw; // void* to hold low-level, platform-native window handle (e.g. the HWND) when using an abstraction layer like GLFW or SDL (where PlatformHandle would be a SDL_Window*)
- bool PlatformRequestClose; // Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4)
- bool PlatformRequestMove; // Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position)
- bool PlatformRequestResize; // Platform window requested resize (e.g. window was resized by the OS / host window manager, authoritative size will be OS window size)
-
- ImGuiViewport() { ID = 0; Flags = 0; DpiScale = 0.0f; DrawData = NULL; ParentViewportId = 0; RendererUserData = PlatformUserData = PlatformHandle = PlatformHandleRaw = NULL; PlatformRequestClose = PlatformRequestMove = PlatformRequestResize = false; }
- ~ImGuiViewport() { IM_ASSERT(PlatformUserData == NULL && RendererUserData == NULL); }
+ IMGUI_API bool IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last);
};
#if defined(__clang__)
@@ -2449,3 +2333,5 @@ struct ImGuiViewport
#ifdef IMGUI_INCLUDE_IMGUI_USER_H
#include "imgui_user.h"
#endif
+
+#endif // #ifndef IMGUI_DISABLE
diff --git a/Sources/CImGui/imgui/imgui_demo.cpp b/Sources/CImGui/imgui/imgui_demo.cpp
index 339a6db..1e110de 100644
--- a/Sources/CImGui/imgui/imgui_demo.cpp
+++ b/Sources/CImGui/imgui/imgui_demo.cpp
@@ -1,17 +1,24 @@
-// dear imgui, v1.74 WIP
+// dear imgui, v1.76
// (demo code)
+// Help:
+// - Read FAQ at http://dearimgui.org/faq
+// - Newcomers, read 'Programmer guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
+// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code. All applications in examples/ are doing that.
+// Read imgui.cpp for more details, documentation and comments.
+// Get latest version at https://github.com/ocornut/imgui
+
// Message to the person tempted to delete this file when integrating Dear ImGui into their code base:
// Do NOT remove this file from your project! Think again! It is the most useful reference code that you and other coders
// will want to refer to and call. Have the ImGui::ShowDemoWindow() function wired in an always-available debug menu of
// your game/app! Removing this file from your project is hindering access to documentation for everyone in your team,
// likely leading you to poorer usage of the library.
// Everything in this file will be stripped out by the linker if you don't call ImGui::ShowDemoWindow().
-// If you want to link core Dear ImGui in your shipped builds but want an easy guarantee that the demo will not be linked,
+// If you want to link core Dear ImGui in your shipped builds but want a thorough guarantee that the demo will not be linked,
// you can setup your imconfig.h with #define IMGUI_DISABLE_DEMO_WINDOWS and those functions will be empty.
// In other situation, whenever you have Dear ImGui available you probably want this to be available for reference.
// Thank you,
-// -Your beloved friend, imgui_demo.cpp (that you won't delete)
+// -Your beloved friend, imgui_demo.cpp (which you won't delete)
// Message to beginner C/C++ programmers about the meaning of the 'static' keyword:
// In this demo code, we frequently we use 'static' variables inside functions. A static variable persist across calls, so it is
@@ -21,13 +28,13 @@
// reentrant or used in multiple threads. This might be a pattern you will want to use in your code, but most of the real data
// you would be editing is likely going to be stored outside your functions.
-// The Demo code is this file is designed to be easy to copy-and-paste in into your application!
+// The Demo code in this file is designed to be easy to copy-and-paste in into your application!
// Because of this:
// - We never omit the ImGui:: namespace when calling functions, even though most of our code is already in the same namespace.
// - We try to declare static variables in the local scope, as close as possible to the code using them.
-// - We never use any of the helpers/facilities used internally by dear imgui, unless it has been exposed in the public API (imgui.h).
-// - We never use maths operators on ImVec2/ImVec4. For other imgui sources files, they are provided by imgui_internal.h w/ IMGUI_DEFINE_MATH_OPERATORS,
-// for your own sources file they are optional and require you either enable those, either provide your own via IM_VEC2_CLASS_EXTRA in imconfig.h.
+// - We never use any of the helpers/facilities used internally by Dear ImGui, unless it has been exposed in the public API (imgui.h).
+// - We never use maths operators on ImVec2/ImVec4. For other of our sources files, they are provided by imgui_internal.h w/ IMGUI_DEFINE_MATH_OPERATORS.
+// For your own sources file they are optional and require you either enable those, either provide your own via IM_VEC2_CLASS_EXTRA in imconfig.h.
// Because we don't want to assume anything about your support of maths operators, we don't use them in imgui_demo.cpp.
/*
@@ -49,7 +56,6 @@ Index of this file:
// [SECTION] Example App: Simple Overlay / ShowExampleAppSimpleOverlay()
// [SECTION] Example App: Manipulating Window Titles / ShowExampleAppWindowTitles()
// [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering()
-// [SECTION] Example App: Docking, DockSpace / ShowExampleAppDockSpace()
// [SECTION] Example App: Documents Handling / ShowExampleAppDocuments()
*/
@@ -59,6 +65,8 @@ Index of this file:
#endif
#include "imgui.h"
+#ifndef IMGUI_DISABLE
+
#include // toupper
#include // INT_MIN, INT_MAX
#include // sqrtf, powf, cosf, sinf, floorf, ceilf
@@ -98,27 +106,27 @@ Index of this file:
#pragma GCC diagnostic ignored "-Wmisleading-indentation" // [__GNUC__ >= 6] warning: this 'if' clause does not guard this statement // GCC 6.0+ only. See #883 on GitHub.
#endif
-// Play it nice with Windows users. Notepad in 2017 still doesn't display text data with Unix-style \n.
+// Play it nice with Windows users (Update: since 2018-05, Notepad finally appears to support Unix-style carriage returns!)
#ifdef _WIN32
#define IM_NEWLINE "\r\n"
-#define snprintf _snprintf
-#define vsnprintf _vsnprintf
#else
#define IM_NEWLINE "\n"
#endif
+#if defined(_MSC_VER) && !defined(snprintf)
+#define snprintf _snprintf
+#endif
+#if defined(_MSC_VER) && !defined(vsnprintf)
+#define vsnprintf _vsnprintf
+#endif
+
//-----------------------------------------------------------------------------
// [SECTION] Forward Declarations, Helpers
//-----------------------------------------------------------------------------
-#if !defined(IMGUI_DISABLE_OBSOLETE_FUNCTIONS) && defined(IMGUI_DISABLE_TEST_WINDOWS) && !defined(IMGUI_DISABLE_DEMO_WINDOWS) // Obsolete name since 1.53, TEST->DEMO
-#define IMGUI_DISABLE_DEMO_WINDOWS
-#endif
-
#if !defined(IMGUI_DISABLE_DEMO_WINDOWS)
// Forward Declarations
-static void ShowExampleAppDockSpace(bool* p_open);
static void ShowExampleAppDocuments(bool* p_open);
static void ShowExampleAppMainMenuBar();
static void ShowExampleAppConsole(bool* p_open);
@@ -134,7 +142,7 @@ static void ShowExampleAppCustomRendering(bool* p_open);
static void ShowExampleMenuFile();
// Helper to display a little (?) mark which shows a tooltip when hovered.
-// In your own code you may want to display an actual icon if you are using a merged icon fonts (see misc/fonts/README.txt)
+// In your own code you may want to display an actual icon if you are using a merged icon fonts (see docs/FONTS.txt)
static void HelpMarker(const char* desc)
{
ImGui::TextDisabled("(?)");
@@ -148,41 +156,34 @@ static void HelpMarker(const char* desc)
}
}
-static void ShowDockingDisabledMessage()
-{
- ImGuiIO& io = ImGui::GetIO();
- ImGui::Text("ERROR: Docking is not enabled! See Demo > Configuration.");
- ImGui::Text("Set io.ConfigFlags |= ImGuiConfigFlags_DockingEnable in your code, or ");
- ImGui::SameLine(0.0f, 0.0f);
- if (ImGui::SmallButton("click here"))
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
-}
-
// Helper to display basic user controls.
void ImGui::ShowUserGuide()
{
ImGuiIO& io = ImGui::GetIO();
ImGui::BulletText("Double-click on title bar to collapse window.");
ImGui::BulletText("Click and drag on lower corner to resize window\n(double-click to auto fit window to its contents).");
- if (io.ConfigWindowsMoveFromTitleBarOnly)
- ImGui::BulletText("Click and drag on title bar to move window.");
- else
- ImGui::BulletText("Click and drag on any empty space to move window.");
- ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields.");
ImGui::BulletText("CTRL+Click on a slider or drag box to input value as text.");
+ ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields.");
if (io.FontAllowUserScaling)
ImGui::BulletText("CTRL+Mouse Wheel to zoom window contents.");
- ImGui::BulletText("Mouse Wheel to scroll.");
- ImGui::BulletText("While editing text:\n");
+ ImGui::BulletText("While inputing text:\n");
ImGui::Indent();
- ImGui::BulletText("Hold SHIFT or use mouse to select text.");
ImGui::BulletText("CTRL+Left/Right to word jump.");
ImGui::BulletText("CTRL+A or double-click to select all.");
- ImGui::BulletText("CTRL+X,CTRL+C,CTRL+V to use clipboard.");
+ ImGui::BulletText("CTRL+X/C/V to use clipboard cut/copy/paste.");
ImGui::BulletText("CTRL+Z,CTRL+Y to undo/redo.");
ImGui::BulletText("ESCAPE to revert.");
ImGui::BulletText("You can apply arithmetic operators +,*,/ on numerical values.\nUse +- to subtract.");
ImGui::Unindent();
+ ImGui::BulletText("With keyboard navigation enabled:");
+ ImGui::Indent();
+ ImGui::BulletText("Arrow keys to navigate.");
+ ImGui::BulletText("Space to activate a widget.");
+ ImGui::BulletText("Return to input text into a widget.");
+ ImGui::BulletText("Escape to deactivate a widget, close popup, exit child window.");
+ ImGui::BulletText("Alt to jump to the menu layer of a window.");
+ ImGui::BulletText("CTRL+Tab to select a window.");
+ ImGui::Unindent();
}
//-----------------------------------------------------------------------------
@@ -209,7 +210,6 @@ void ImGui::ShowDemoWindow(bool* p_open)
IM_ASSERT(ImGui::GetCurrentContext() != NULL && "Missing dear imgui context. Refer to examples app!"); // Exceptionally add an extra assert here for people confused with initial dear imgui setup
// Examples Apps (accessible from the "Examples" menu)
- static bool show_app_dockspace = false;
static bool show_app_documents = false;
static bool show_app_main_menu_bar = false;
static bool show_app_console = false;
@@ -223,8 +223,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
static bool show_app_window_titles = false;
static bool show_app_custom_rendering = false;
- if (show_app_dockspace) ShowExampleAppDockSpace(&show_app_dockspace); // Process the Docking app first, as explicit DockSpace() nodes needs to be submitted early (read comments near the DockSpace function)
- if (show_app_documents) ShowExampleAppDocuments(&show_app_documents); // Process the Document app next, as it may also use a DockSpace()
+ if (show_app_documents) ShowExampleAppDocuments(&show_app_documents);
if (show_app_main_menu_bar) ShowExampleAppMainMenuBar();
if (show_app_console) ShowExampleAppConsole(&show_app_console);
if (show_app_log) ShowExampleAppLog(&show_app_log);
@@ -257,7 +256,6 @@ void ImGui::ShowDemoWindow(bool* p_open)
static bool no_nav = false;
static bool no_background = false;
static bool no_bring_to_front = false;
- static bool no_docking = false;
ImGuiWindowFlags window_flags = 0;
if (no_titlebar) window_flags |= ImGuiWindowFlags_NoTitleBar;
@@ -269,12 +267,10 @@ void ImGui::ShowDemoWindow(bool* p_open)
if (no_nav) window_flags |= ImGuiWindowFlags_NoNav;
if (no_background) window_flags |= ImGuiWindowFlags_NoBackground;
if (no_bring_to_front) window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus;
- if (no_docking) window_flags |= ImGuiWindowFlags_NoDocking;
if (no_close) p_open = NULL; // Don't pass our bool* to Begin
// We specify a default position/size in case there's no data in the .ini file. Typically this isn't required! We only do it to make the Demo applications a little more welcoming.
- ImVec2 main_viewport_pos = ImGui::GetMainViewport()->Pos;
- ImGui::SetNextWindowPos(ImVec2(main_viewport_pos.x + 650, main_viewport_pos.y + 20), ImGuiCond_FirstUseEver);
+ ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver);
ImGui::SetNextWindowSize(ImVec2(550, 680), ImGuiCond_FirstUseEver);
// Main body of the Demo window starts here.
@@ -310,7 +306,6 @@ void ImGui::ShowDemoWindow(bool* p_open)
ImGui::MenuItem("Simple overlay", NULL, &show_app_simple_overlay);
ImGui::MenuItem("Manipulating window titles", NULL, &show_app_window_titles);
ImGui::MenuItem("Custom rendering", NULL, &show_app_custom_rendering);
- ImGui::MenuItem("Dockspace", NULL, &show_app_dockspace);
ImGui::MenuItem("Documents", NULL, &show_app_documents);
ImGui::EndMenu();
}
@@ -329,12 +324,20 @@ void ImGui::ShowDemoWindow(bool* p_open)
if (ImGui::CollapsingHeader("Help"))
{
+ ImGui::Text("ABOUT THIS DEMO:");
+ ImGui::BulletText("Sections below are demonstrating many aspects of the library.");
+ ImGui::BulletText("The \"Examples\" menu above leads to more demo contents.");
+ ImGui::BulletText("The \"Tools\" menu above gives access to: About Box, Style Editor,\n"
+ "and Metrics (general purpose Dear ImGui debugging tool).");
+ ImGui::Separator();
+
ImGui::Text("PROGRAMMER GUIDE:");
- ImGui::BulletText("Please see the ShowDemoWindow() code in imgui_demo.cpp. <- you are here!");
- ImGui::BulletText("Please see the comments in imgui.cpp.");
- ImGui::BulletText("Please see the examples/ application.");
- ImGui::BulletText("Enable 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls.");
- ImGui::BulletText("Enable 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls.");
+ ImGui::BulletText("See the ShowDemoWindow() code in imgui_demo.cpp. <- you are here!");
+ ImGui::BulletText("See comments in imgui.cpp.");
+ ImGui::BulletText("See example applications in the examples/ folder.");
+ ImGui::BulletText("Read the FAQ at http://www.dearimgui.org/faq/");
+ ImGui::BulletText("Set 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls.");
+ ImGui::BulletText("Set 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls.");
ImGui::Separator();
ImGui::Text("USER GUIDE:");
@@ -365,39 +368,6 @@ void ImGui::ShowDemoWindow(bool* p_open)
}
ImGui::CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NoMouseCursorChange);
ImGui::SameLine(); HelpMarker("Instruct back-end to not alter mouse cursor shape and visibility.");
-
- ImGui::CheckboxFlags("io.ConfigFlags: DockingEnable", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_DockingEnable);
- ImGui::SameLine(); HelpMarker(io.ConfigDockingWithShift ? "[beta] Use SHIFT to dock window into each others." : "[beta] Drag from title bar to dock windows into each others.");
- if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable)
- {
- ImGui::Indent();
- ImGui::Checkbox("io.ConfigDockingNoSplit", &io.ConfigDockingNoSplit);
- ImGui::SameLine(); HelpMarker("Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.");
- ImGui::Checkbox("io.ConfigDockingWithShift", &io.ConfigDockingWithShift);
- ImGui::SameLine(); HelpMarker("Enable docking when holding Shift only (allows to drop in wider space, reduce visual noise)");
- ImGui::Checkbox("io.ConfigDockingAlwaysTabBar", &io.ConfigDockingAlwaysTabBar);
- ImGui::SameLine(); HelpMarker("Create a docking node and tab-bar on single floating windows.");
- ImGui::Checkbox("io.ConfigDockingTransparentPayload", &io.ConfigDockingTransparentPayload);
- ImGui::SameLine(); HelpMarker("Make window or viewport transparent when docking and only display docking boxes on the target viewport. Useful if rendering of multiple viewport cannot be synced. Best used with ConfigViewportsNoAutoMerge.");
- ImGui::Unindent();
- }
-
- ImGui::CheckboxFlags("io.ConfigFlags: ViewportsEnable", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_ViewportsEnable);
- ImGui::SameLine(); HelpMarker("[beta] Enable beta multi-viewports support. See ImGuiPlatformIO for details.");
- if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
- {
- ImGui::Indent();
- ImGui::Checkbox("io.ConfigViewportsNoAutoMerge", &io.ConfigViewportsNoAutoMerge);
- ImGui::SameLine(); HelpMarker("Set to make all floating imgui windows always create their own viewport. Otherwise, they are merged into the main host viewports when overlapping it.");
- ImGui::Checkbox("io.ConfigViewportsNoTaskBarIcon", &io.ConfigViewportsNoTaskBarIcon);
- ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform back-ends won't refresh the task bar icon state right away).");
- ImGui::Checkbox("io.ConfigViewportsNoDecoration", &io.ConfigViewportsNoDecoration);
- ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform back-ends won't refresh the decoration right away).");
- ImGui::Checkbox("io.ConfigViewportsNoDefaultParent", &io.ConfigViewportsNoDefaultParent);
- ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform back-ends won't refresh the parenting right away).");
- ImGui::Unindent();
- }
-
ImGui::Checkbox("io.ConfigInputTextCursorBlink", &io.ConfigInputTextCursorBlink);
ImGui::SameLine(); HelpMarker("Set to false to disable blinking cursor, for users who consider it distracting");
ImGui::Checkbox("io.ConfigWindowsResizeFromEdges", &io.ConfigWindowsResizeFromEdges);
@@ -411,21 +381,19 @@ void ImGui::ShowDemoWindow(bool* p_open)
if (ImGui::TreeNode("Backend Flags"))
{
- HelpMarker("Those flags are set by the back-ends (imgui_impl_xxx files) to specify their capabilities.");
+ HelpMarker("Those flags are set by the back-ends (imgui_impl_xxx files) to specify their capabilities.\nHere we expose then as read-only fields to avoid breaking interactions with your back-end.");
ImGuiBackendFlags backend_flags = io.BackendFlags; // Make a local copy to avoid modifying actual back-end flags.
ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasGamepad);
ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasMouseCursors);
ImGui::CheckboxFlags("io.BackendFlags: HasSetMousePos", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasSetMousePos);
- ImGui::CheckboxFlags("io.BackendFlags: PlatformHasViewports", (unsigned int *)&backend_flags, ImGuiBackendFlags_PlatformHasViewports);
- ImGui::CheckboxFlags("io.BackendFlags: HasMouseHoveredViewport", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasMouseHoveredViewport);
ImGui::CheckboxFlags("io.BackendFlags: RendererHasVtxOffset", (unsigned int *)&backend_flags, ImGuiBackendFlags_RendererHasVtxOffset);
- ImGui::CheckboxFlags("io.BackendFlags: RendererHasViewports", (unsigned int *)&backend_flags, ImGuiBackendFlags_RendererHasViewports);
ImGui::TreePop();
ImGui::Separator();
}
if (ImGui::TreeNode("Style"))
{
+ HelpMarker("The same contents can be accessed in 'Tools->Style Editor' or by calling the ShowStyleEditor() function.");
ImGui::ShowStyleEditor();
ImGui::TreePop();
ImGui::Separator();
@@ -459,7 +427,6 @@ void ImGui::ShowDemoWindow(bool* p_open)
ImGui::Checkbox("No nav", &no_nav); ImGui::SameLine(300);
ImGui::Checkbox("No background", &no_background);
ImGui::Checkbox("No bring to front", &no_bring_to_front);
- ImGui::Checkbox("No docking", &no_docking);
}
// All demo contents
@@ -556,6 +523,8 @@ static void ShowDemoWindowWidgets()
}
{
+ // To wire InputText() with std::string or any other custom string type,
+ // see the "Text Input > Resize Callback" section of this demo, and the misc/cpp/imgui_stdlib.h file.
static char str0[128] = "Hello, world!";
ImGui::InputText("input text", str0, IM_ARRAYSIZE(str0));
ImGui::SameLine(); HelpMarker("USER:\nHold SHIFT or use mouse to select text.\n" "CTRL+Left/Right to word jump.\n" "CTRL+A or double-click to select all.\n" "CTRL+X,CTRL+C,CTRL+V clipboard.\n" "CTRL+Z,CTRL+Y undo/redo.\n" "ESCAPE to revert.\n\nPROGRAMMER:\nYou can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputText() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example (this is not demonstrated in imgui_demo.cpp).");
@@ -660,7 +629,7 @@ static void ShowDemoWindowWidgets()
{
ImGui::Text("blah blah");
ImGui::SameLine();
- if (ImGui::SmallButton("button")) {};
+ if (ImGui::SmallButton("button")) {}
ImGui::TreePop();
}
}
@@ -674,9 +643,9 @@ static void ShowDemoWindowWidgets()
static bool align_label_with_current_x_position = false;
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_OpenOnArrow", (unsigned int*)&base_flags, ImGuiTreeNodeFlags_OpenOnArrow);
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_OpenOnDoubleClick", (unsigned int*)&base_flags, ImGuiTreeNodeFlags_OpenOnDoubleClick);
- ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanAvailWidth", (unsigned int*)&base_flags, ImGuiTreeNodeFlags_SpanAvailWidth);
+ ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanAvailWidth", (unsigned int*)&base_flags, ImGuiTreeNodeFlags_SpanAvailWidth); ImGui::SameLine(); HelpMarker("Extend hit area to all available width instead of allowing more items to be layed out after the node.");
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanFullWidth", (unsigned int*)&base_flags, ImGuiTreeNodeFlags_SpanFullWidth);
- ImGui::Checkbox("Align label with current X position)", &align_label_with_current_x_position);
+ ImGui::Checkbox("Align label with current X position", &align_label_with_current_x_position);
ImGui::Text("Hello!");
if (align_label_with_current_x_position)
ImGui::Unindent(ImGui::GetTreeNodeToLabelSpacing());
@@ -808,14 +777,14 @@ static void ShowDemoWindowWidgets()
if (ImGui::TreeNode("UTF-8 Text"))
{
// UTF-8 test with Japanese characters
- // (Needs a suitable font, try Noto, or Arial Unicode, or M+ fonts. Read misc/fonts/README.txt for details.)
+ // (Needs a suitable font, try Noto, or Arial Unicode, or M+ fonts. Read docs/FONTS.txt for details.)
// - From C++11 you can use the u8"my text" syntax to encode literal strings as UTF-8
// - For earlier compiler, you may be able to encode your sources as UTF-8 (e.g. Visual Studio save your file as 'UTF-8 without signature')
// - FOR THIS DEMO FILE ONLY, BECAUSE WE WANT TO SUPPORT OLD COMPILERS, WE ARE *NOT* INCLUDING RAW UTF-8 CHARACTERS IN THIS SOURCE FILE.
// Instead we are encoding a few strings with hexadecimal constants. Don't do this in your application!
// Please use u8"text in any language" in your application!
// Note that characters values are preserved even by InputText() if the font cannot be displayed, so you can safely copy & paste garbled characters into another application.
- ImGui::TextWrapped("CJK text will only appears if the font was loaded with the appropriate CJK character ranges. Call io.Font->AddFontFromFileTTF() manually to load extra character ranges. Read misc/fonts/README.txt for details.");
+ ImGui::TextWrapped("CJK text will only appears if the font was loaded with the appropriate CJK character ranges. Call io.Font->AddFontFromFileTTF() manually to load extra character ranges. Read docs/FONTS.txt for details.");
ImGui::Text("Hiragana: \xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91\xe3\x81\x93 (kakikukeko)"); // Normally we would use u8"blah blah" with the proper characters directly in the string.
ImGui::Text("Kanjis: \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e (nihongo)");
static char buf[32] = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e";
@@ -1011,7 +980,7 @@ static void ShowDemoWindowWidgets()
}
if (ImGui::TreeNode("Alignment"))
{
- HelpMarker("Alignment applies when a selectable is larger than its text content.\nBy default, Selectables uses style.SelectableTextAlign but it can be overriden on a per-item basis using PushStyleVar().");
+ HelpMarker("By default, Selectables uses style.SelectableTextAlign but it can be overriden on a per-item basis using PushStyleVar(). You'll probably want to always keep your default situation to left-align otherwise it becomes difficult to layout multiple items on a same line");
static bool selected[3*3] = { true, false, true, false, true, false, true, false, true };
for (int y = 0; y < 3; y++)
{
@@ -1031,6 +1000,8 @@ static void ShowDemoWindowWidgets()
ImGui::TreePop();
}
+ // To wire InputText() with std::string or any other custom string type,
+ // see the "Text Input > Resize Callback" section of this demo, and the misc/cpp/imgui_stdlib.h file.
if (ImGui::TreeNode("Text Input"))
{
if (ImGui::TreeNode("Multi-line Text Input"))
@@ -1050,7 +1021,7 @@ static void ShowDemoWindowWidgets()
"\tlock cmpxchg8b eax\n";
static ImGuiInputTextFlags flags = ImGuiInputTextFlags_AllowTabInput;
- HelpMarker("You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputTextMultiline() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example. (This is not demonstrated in imgui_demo.cpp)");
+ HelpMarker("You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputTextMultiline() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example. (This is not demonstrated in imgui_demo.cpp because we don't want to include in here)");
ImGui::CheckboxFlags("ImGuiInputTextFlags_ReadOnly", (unsigned int*)&flags, ImGuiInputTextFlags_ReadOnly);
ImGui::CheckboxFlags("ImGuiInputTextFlags_AllowTabInput", (unsigned int*)&flags, ImGuiInputTextFlags_AllowTabInput);
ImGui::CheckboxFlags("ImGuiInputTextFlags_CtrlEnterForNewLine", (unsigned int*)&flags, ImGuiInputTextFlags_CtrlEnterForNewLine);
@@ -1069,18 +1040,19 @@ static void ShowDemoWindowWidgets()
static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters);
ImGui::Text("Password input");
- static char bufpass[64] = "password123";
- ImGui::InputText("password", bufpass, 64, ImGuiInputTextFlags_Password | ImGuiInputTextFlags_CharsNoBlank);
+ static char password[64] = "password123";
+ ImGui::InputText("password", password, IM_ARRAYSIZE(password), ImGuiInputTextFlags_Password);
ImGui::SameLine(); HelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n");
- ImGui::InputTextWithHint("password (w/ hint)", "", bufpass, 64, ImGuiInputTextFlags_Password | ImGuiInputTextFlags_CharsNoBlank);
- ImGui::InputText("password (clear)", bufpass, 64, ImGuiInputTextFlags_CharsNoBlank);
+ ImGui::InputTextWithHint("password (w/ hint)", "", password, IM_ARRAYSIZE(password), ImGuiInputTextFlags_Password);
+ ImGui::InputText("password (clear)", password, IM_ARRAYSIZE(password));
ImGui::TreePop();
}
if (ImGui::TreeNode("Resize Callback"))
{
- // If you have a custom string type you would typically create a ImGui::InputText() wrapper than takes your type as input.
- // See misc/cpp/imgui_stdlib.h and .cpp for an implementation of this using std::string.
+ // To wire InputText() with std::string or any other custom string type,
+ // you can use the ImGuiInputTextFlags_CallbackResize flag + create a custom ImGui::InputText() wrapper using your prefered type.
+ // See misc/cpp/imgui_stdlib.h for an implementation of this using std::string.
HelpMarker("Demonstrate using ImGuiInputTextFlags_CallbackResize to wire your resizable string type to InputText().\n\nSee misc/cpp/imgui_stdlib.h for an implementation of this for std::string.");
struct Funcs
{
@@ -1292,7 +1264,9 @@ static void ShowDemoWindowWidgets()
}
ImGui::Text("Color button only:");
- ImGui::ColorButton("MyColor##3c", *(ImVec4*)&color, misc_flags, ImVec2(80,80));
+ static bool no_border = false;
+ ImGui::Checkbox("ImGuiColorEditFlags_NoBorder", &no_border);
+ ImGui::ColorButton("MyColor##3c", *(ImVec4*)&color, misc_flags | (no_border ? ImGuiColorEditFlags_NoBorder : 0), ImVec2(80,80));
ImGui::Text("Color picker:");
static bool alpha = true;
@@ -1663,7 +1637,7 @@ static void ShowDemoWindowWidgets()
{
// Submit an item (various types available) so we can query their status in the following block.
static int item_type = 1;
- ImGui::Combo("Item Type", &item_type, "Text\0Button\0Button (w/ repeat)\0Checkbox\0SliderFloat\0InputText\0InputFloat\0InputFloat3\0ColorEdit4\0MenuItem\0TreeNode (w/ double-click)\0ListBox\0");
+ ImGui::Combo("Item Type", &item_type, "Text\0Button\0Button (w/ repeat)\0Checkbox\0SliderFloat\0InputText\0InputFloat\0InputFloat3\0ColorEdit4\0MenuItem\0TreeNode\0TreeNode (w/ double-click)\0ListBox\0", 20);
ImGui::SameLine();
HelpMarker("Testing how various types of items are interacting with the IsItemXXX functions.");
bool ret = false;
@@ -1680,8 +1654,9 @@ static void ShowDemoWindowWidgets()
if (item_type == 7) { ret = ImGui::InputFloat3("ITEM: InputFloat3", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
if (item_type == 8) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
if (item_type == 9) { ret = ImGui::MenuItem("ITEM: MenuItem"); } // Testing menu item (they use ImGuiButtonFlags_PressedOnRelease button policy)
- if (item_type == 10){ ret = ImGui::TreeNodeEx("ITEM: TreeNode w/ ImGuiTreeNodeFlags_OpenOnDoubleClick", ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_NoTreePushOnOpen); } // Testing tree node with ImGuiButtonFlags_PressedOnDoubleClick button policy.
- if (item_type == 11){ const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", ¤t, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
+ if (item_type == 10){ ret = ImGui::TreeNode("ITEM: TreeNode"); if (ret) ImGui::TreePop(); } // Testing tree node
+ if (item_type == 11){ ret = ImGui::TreeNodeEx("ITEM: TreeNode w/ ImGuiTreeNodeFlags_OpenOnDoubleClick", ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_NoTreePushOnOpen); } // Testing tree node with ImGuiButtonFlags_PressedOnDoubleClick button policy.
+ if (item_type == 12){ const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", ¤t, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
// Display the value of IsItemHovered() and other common item state functions.
// Note that the ImGuiHoveredFlags_XXX flags can be combined.
@@ -1702,6 +1677,7 @@ static void ShowDemoWindowWidgets()
"IsItemDeactivatedAfterEdit() = %d\n"
"IsItemVisible() = %d\n"
"IsItemClicked() = %d\n"
+ "IsItemToggledOpen() = %d\n"
"GetItemRectMin() = (%.1f, %.1f)\n"
"GetItemRectMax() = (%.1f, %.1f)\n"
"GetItemRectSize() = (%.1f, %.1f)",
@@ -1719,6 +1695,7 @@ static void ShowDemoWindowWidgets()
ImGui::IsItemDeactivatedAfterEdit(),
ImGui::IsItemVisible(),
ImGui::IsItemClicked(),
+ ImGui::IsItemToggledOpen(),
ImGui::GetItemRectMin().x, ImGui::GetItemRectMin().y,
ImGui::GetItemRectMax().x, ImGui::GetItemRectMax().y,
ImGui::GetItemRectSize().x, ImGui::GetItemRectSize().y
@@ -1774,13 +1751,10 @@ static void ShowDemoWindowWidgets()
// Calling IsItemHovered() after begin returns the hovered status of the title bar.
// This is useful in particular if you want to create a context menu (with BeginPopupContextItem) associated to the title bar of a window.
- // This will also work when docked into a Tab (the Tab replace the Title Bar and guarantee the same properties).
static bool test_window = false;
ImGui::Checkbox("Hovered/Active tests after Begin() for title bar testing", &test_window);
if (test_window)
{
- // FIXME-DOCK: This window cannot be docked within the ImGui Demo window, this will cause a feedback loop and get them stuck.
- // Could we fix this through an ImGuiWindowClass feature? Or an API call to tag our parent as "don't skip items"?
ImGui::Begin("Title bar Hovered/Active tests", &test_window);
if (ImGui::BeginPopupContextItem()) // <-- This is using IsItemHovered()
{
@@ -1820,7 +1794,7 @@ static void ShowDemoWindowLayout()
// Child 1: no border, enable horizontal scrollbar
{
ImGuiWindowFlags window_flags = ImGuiWindowFlags_HorizontalScrollbar | (disable_mouse_wheel ? ImGuiWindowFlags_NoScrollWithMouse : 0);
- ImGui::BeginChild("Child1", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f, 260), false, window_flags);
+ ImGui::BeginChild("ChildL", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f, 260), false, window_flags);
for (int i = 0; i < 100; i++)
{
ImGui::Text("%04d: scrollable region", i);
@@ -1838,7 +1812,7 @@ static void ShowDemoWindowLayout()
{
ImGuiWindowFlags window_flags = (disable_mouse_wheel ? ImGuiWindowFlags_NoScrollWithMouse : 0) | (disable_menu ? 0 : ImGuiWindowFlags_MenuBar);
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f);
- ImGui::BeginChild("Child2", ImVec2(0, 260), true, window_flags);
+ ImGui::BeginChild("ChildR", ImVec2(0, 260), true, window_flags);
if (!disable_menu && ImGui::BeginMenuBar())
{
if (ImGui::BeginMenu("Menu"))
@@ -1871,7 +1845,7 @@ static void ShowDemoWindowLayout()
{
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 10);
ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(255, 0, 0, 100));
- ImGui::BeginChild("blah", ImVec2(200, 100), true, ImGuiWindowFlags_None);
+ ImGui::BeginChild("Red", ImVec2(200, 100), true, ImGuiWindowFlags_None);
for (int n = 0; n < 50; n++)
ImGui::Text("Some test %d", n);
ImGui::EndChild();
@@ -2065,7 +2039,7 @@ static void ShowDemoWindowLayout()
if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
{
for (int n = 0; n < IM_ARRAYSIZE(opened); n++)
- if (opened[n] && ImGui::BeginTabItem(names[n], &opened[n]))
+ if (opened[n] && ImGui::BeginTabItem(names[n], &opened[n], ImGuiTabItemFlags_None))
{
ImGui::Text("This is the %s tab!", names[n]);
if (n & 1)
@@ -2243,10 +2217,10 @@ static void ShowDemoWindowLayout()
ImGui::SameLine(140); enable_track |= ImGui::DragInt("##item", &track_item, 0.25f, 0, 99, "Item = %d");
bool scroll_to_off = ImGui::Button("Scroll Offset");
- ImGui::SameLine(140); scroll_to_off |= ImGui::DragFloat("##off", &scroll_to_off_px, 1.00f, 0, 9999, "+%.0f px");
+ ImGui::SameLine(140); scroll_to_off |= ImGui::DragFloat("##off", &scroll_to_off_px, 1.00f, 0, FLT_MAX, "+%.0f px");
bool scroll_to_pos = ImGui::Button("Scroll To Pos");
- ImGui::SameLine(140); scroll_to_pos |= ImGui::DragFloat("##pos", &scroll_to_pos_px, 1.00f, -10, 9999, "X/Y = %.0f px");
+ ImGui::SameLine(140); scroll_to_pos |= ImGui::DragFloat("##pos", &scroll_to_pos_px, 1.00f, -10, FLT_MAX, "X/Y = %.0f px");
ImGui::PopItemWidth();
if (scroll_to_off || scroll_to_pos)
@@ -2265,7 +2239,7 @@ static void ShowDemoWindowLayout()
ImGui::TextUnformatted(names[i]);
ImGuiWindowFlags child_flags = enable_extra_decorations ? ImGuiWindowFlags_MenuBar : 0;
- ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(child_w, 200.0f), true, child_flags);
+ bool window_visible = ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(child_w, 200.0f), true, child_flags);
if (ImGui::BeginMenuBar())
{
ImGui::TextUnformatted("abc");
@@ -2275,16 +2249,19 @@ static void ShowDemoWindowLayout()
ImGui::SetScrollY(scroll_to_off_px);
if (scroll_to_pos)
ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_pos_px, i * 0.25f);
- for (int item = 0; item < 100; item++)
+ if (window_visible) // Avoid calling SetScrollHereY when running with culled items
{
- if (enable_track && item == track_item)
+ for (int item = 0; item < 100; item++)
{
- ImGui::TextColored(ImVec4(1,1,0,1), "Item %d", item);
- ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom
- }
- else
- {
- ImGui::Text("Item %d", item);
+ if (enable_track && item == track_item)
+ {
+ ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item);
+ ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom
+ }
+ else
+ {
+ ImGui::Text("Item %d", item);
+ }
}
}
float scroll_y = ImGui::GetScrollY();
@@ -2303,23 +2280,26 @@ static void ShowDemoWindowLayout()
{
float child_height = ImGui::GetTextLineHeight() + style.ScrollbarSize + style.WindowPadding.y * 2.0f;
ImGuiWindowFlags child_flags = ImGuiWindowFlags_HorizontalScrollbar | (enable_extra_decorations ? ImGuiWindowFlags_AlwaysVerticalScrollbar : 0);
- ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(-100, child_height), true, child_flags);
+ bool window_visible = ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(-100, child_height), true, child_flags);
if (scroll_to_off)
ImGui::SetScrollX(scroll_to_off_px);
if (scroll_to_pos)
ImGui::SetScrollFromPosX(ImGui::GetCursorStartPos().x + scroll_to_pos_px, i * 0.25f);
- for (int item = 0; item < 100; item++)
+ if (window_visible) // Avoid calling SetScrollHereY when running with culled items
{
- if (enable_track && item == track_item)
+ for (int item = 0; item < 100; item++)
{
- ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item);
- ImGui::SetScrollHereX(i * 0.25f); // 0.0f:left, 0.5f:center, 1.0f:right
- }
- else
- {
- ImGui::Text("Item %d", item);
+ if (enable_track && item == track_item)
+ {
+ ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item);
+ ImGui::SetScrollHereX(i * 0.25f); // 0.0f:left, 0.5f:center, 1.0f:right
+ }
+ else
+ {
+ ImGui::Text("Item %d", item);
+ }
+ ImGui::SameLine();
}
- ImGui::SameLine();
}
float scroll_x = ImGui::GetScrollX();
float scroll_max_x = ImGui::GetScrollMaxX();
@@ -2477,7 +2457,7 @@ static void ShowDemoWindowLayout()
ImVec2 pos = ImGui::GetCursorScreenPos();
ImVec4 clip_rect(pos.x, pos.y, pos.x + size.x, pos.y + size.y);
ImGui::InvisibleButton("##dummy", size);
- if (ImGui::IsItemActive() && ImGui::IsMouseDragging()) { offset.x += ImGui::GetIO().MouseDelta.x; offset.y += ImGui::GetIO().MouseDelta.y; }
+ if (ImGui::IsItemActive() && ImGui::IsMouseDragging(0)) { offset.x += ImGui::GetIO().MouseDelta.x; offset.y += ImGui::GetIO().MouseDelta.y; }
ImGui::GetWindowDrawList()->AddRectFilled(pos, ImVec2(pos.x + size.x, pos.y + size.y), IM_COL32(90, 90, 120, 255));
ImGui::GetWindowDrawList()->AddText(ImGui::GetFont(), ImGui::GetFontSize()*2.0f, ImVec2(pos.x + offset.x, pos.y + offset.y), IM_COL32(255, 255, 255, 255), "Line 1 hello\nLine 2 clip me!", NULL, 0.0f, &clip_rect);
ImGui::TreePop();
@@ -3083,7 +3063,7 @@ static void ShowDemoWindowMisc()
if (ImGui::TreeNode("Mouse cursors"))
{
- const char* mouse_cursors_names[] = { "Arrow", "TextInput", "Move", "ResizeNS", "ResizeEW", "ResizeNESW", "ResizeNWSE", "Hand" };
+ const char* mouse_cursors_names[] = { "Arrow", "TextInput", "ResizeAll", "ResizeNS", "ResizeEW", "ResizeNESW", "ResizeNWSE", "Hand", "NotAllowed" };
IM_ASSERT(IM_ARRAYSIZE(mouse_cursors_names) == ImGuiMouseCursor_COUNT);
ImGui::Text("Current mouse cursor = %d: %s", ImGui::GetMouseCursor(), mouse_cursors_names[ImGui::GetMouseCursor()]);
@@ -3150,11 +3130,17 @@ void ImGui::ShowAboutWindow(bool* p_open)
#ifdef IMGUI_DISABLE_WIN32_FUNCTIONS
ImGui::Text("define: IMGUI_DISABLE_WIN32_FUNCTIONS");
#endif
-#ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
- ImGui::Text("define: IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS");
+#ifdef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
+ ImGui::Text("define: IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS");
#endif
-#ifdef IMGUI_DISABLE_MATH_FUNCTIONS
- ImGui::Text("define: IMGUI_DISABLE_MATH_FUNCTIONS");
+#ifdef IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
+ ImGui::Text("define: IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS");
+#endif
+#ifdef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
+ ImGui::Text("define: IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS");
+#endif
+#ifdef IMGUI_DISABLE_FILE_FUNCTIONS
+ ImGui::Text("define: IMGUI_DISABLE_FILE_FUNCTIONS");
#endif
#ifdef IMGUI_DISABLE_DEFAULT_ALLOCATORS
ImGui::Text("define: IMGUI_DISABLE_DEFAULT_ALLOCATORS");
@@ -3188,12 +3174,6 @@ void ImGui::ShowAboutWindow(bool* p_open)
#endif
#ifdef __clang_version__
ImGui::Text("define: __clang_version__=%s", __clang_version__);
-#endif
-#ifdef IMGUI_HAS_VIEWPORT
- ImGui::Text("define: IMGUI_HAS_VIEWPORT");
-#endif
-#ifdef IMGUI_HAS_DOCK
- ImGui::Text("define: IMGUI_HAS_DOCK");
#endif
ImGui::Separator();
ImGui::Text("io.BackendPlatformName: %s", io.BackendPlatformName ? io.BackendPlatformName : "NULL");
@@ -3205,19 +3185,7 @@ void ImGui::ShowAboutWindow(bool* p_open)
if (io.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard) ImGui::Text(" NavNoCaptureKeyboard");
if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) ImGui::Text(" NoMouse");
if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) ImGui::Text(" NoMouseCursorChange");
- if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable) ImGui::Text(" DockingEnable");
- if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) ImGui::Text(" ViewportsEnable");
- if (io.ConfigFlags & ImGuiConfigFlags_DpiEnableScaleViewports) ImGui::Text(" DpiEnableScaleViewports");
- if (io.ConfigFlags & ImGuiConfigFlags_DpiEnableScaleFonts) ImGui::Text(" DpiEnableScaleFonts");
if (io.MouseDrawCursor) ImGui::Text("io.MouseDrawCursor");
- if (io.ConfigViewportsNoAutoMerge) ImGui::Text("io.ConfigViewportsNoAutoMerge");
- if (io.ConfigViewportsNoTaskBarIcon) ImGui::Text("io.ConfigViewportsNoTaskBarIcon");
- if (io.ConfigViewportsNoDecoration) ImGui::Text("io.ConfigViewportsNoDecoration");
- if (io.ConfigViewportsNoDefaultParent) ImGui::Text("io.ConfigViewportsNoDefaultParent");
- if (io.ConfigDockingNoSplit) ImGui::Text("io.ConfigDockingNoSplit");
- if (io.ConfigDockingWithShift) ImGui::Text("io.ConfigDockingWithShift");
- if (io.ConfigDockingAlwaysTabBar) ImGui::Text("io.ConfigDockingAlwaysTabBar");
- if (io.ConfigDockingTransparentPayload) ImGui::Text("io.ConfigDockingTransparentPayload");
if (io.ConfigMacOSXBehaviors) ImGui::Text("io.ConfigMacOSXBehaviors");
if (io.ConfigInputTextCursorBlink) ImGui::Text("io.ConfigInputTextCursorBlink");
if (io.ConfigWindowsResizeFromEdges) ImGui::Text("io.ConfigWindowsResizeFromEdges");
@@ -3227,10 +3195,7 @@ void ImGui::ShowAboutWindow(bool* p_open)
if (io.BackendFlags & ImGuiBackendFlags_HasGamepad) ImGui::Text(" HasGamepad");
if (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) ImGui::Text(" HasMouseCursors");
if (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos) ImGui::Text(" HasSetMousePos");
- if (io.BackendFlags & ImGuiBackendFlags_PlatformHasViewports) ImGui::Text(" PlatformHasViewports");
- if (io.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport)ImGui::Text(" HasMouseHoveredViewport");
if (io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) ImGui::Text(" RendererHasVtxOffset");
- if (io.BackendFlags & ImGuiBackendFlags_RendererHasViewports) ImGui::Text(" RendererHasViewports");
ImGui::Separator();
ImGui::Text("io.Fonts: %d fonts, Flags: 0x%08X, TexSize: %d,%d", io.Fonts->Fonts.Size, io.Fonts->Flags, io.Fonts->TexWidth, io.Fonts->TexHeight);
ImGui::Text("io.DisplaySize: %.2f,%.2f", io.DisplaySize.x, io.DisplaySize.y);
@@ -3302,7 +3267,7 @@ void ImGui::ShowFontSelector(const char* label)
HelpMarker(
"- Load additional fonts with io.Fonts->AddFontFromFileTTF().\n"
"- The font atlas is built when calling io.Fonts->GetTexDataAsXXXX() or io.Fonts->Build().\n"
- "- Read FAQ and documentation in misc/fonts/ for more details.\n"
+ "- Read FAQ and docs/FONTS.txt for more details.\n"
"- If you need to add/remove fonts at runtime (e.g. for DPI change), do it before calling NewFrame().");
}
@@ -3342,7 +3307,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
if (ImGui::Button("Revert Ref"))
style = *ref;
ImGui::SameLine();
- HelpMarker("Save/Revert in local non-persistent storage. Default Colors definition are not affected. Use \"Export Colors\" below to save them somewhere.");
+ HelpMarker("Save/Revert in local non-persistent storage. Default Colors definition are not affected. Use \"Export\" below to save them somewhere.");
ImGui::Separator();
@@ -3390,7 +3355,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
{
static int output_dest = 0;
static bool output_only_modified = true;
- if (ImGui::Button("Export Unsaved"))
+ if (ImGui::Button("Export"))
{
if (output_dest == 0)
ImGui::LogToClipboard();
@@ -3413,9 +3378,9 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
filter.Draw("Filter colors", ImGui::GetFontSize() * 16);
static ImGuiColorEditFlags alpha_flags = 0;
- ImGui::RadioButton("Opaque", &alpha_flags, 0); ImGui::SameLine();
- ImGui::RadioButton("Alpha", &alpha_flags, ImGuiColorEditFlags_AlphaPreview); ImGui::SameLine();
- ImGui::RadioButton("Both", &alpha_flags, ImGuiColorEditFlags_AlphaPreviewHalf); ImGui::SameLine();
+ if (ImGui::RadioButton("Opaque", alpha_flags == 0)) { alpha_flags = 0; } ImGui::SameLine();
+ if (ImGui::RadioButton("Alpha", alpha_flags == ImGuiColorEditFlags_AlphaPreview)) { alpha_flags = ImGuiColorEditFlags_AlphaPreview; } ImGui::SameLine();
+ if (ImGui::RadioButton("Both", alpha_flags == ImGuiColorEditFlags_AlphaPreviewHalf)) { alpha_flags = ImGuiColorEditFlags_AlphaPreviewHalf; } ImGui::SameLine();
HelpMarker("In the color list:\nLeft-click on colored square to open color picker,\nRight-click to open edit options menu.");
ImGui::BeginChild("##colors", ImVec2(0, 0), true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NavFlattened);
@@ -3430,7 +3395,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
if (memcmp(&style.Colors[i], &ref->Colors[i], sizeof(ImVec4)) != 0)
{
// Tips: in a real user application, you may want to merge and use an icon font into the main font, so instead of "Save"/"Revert" you'd use icons.
- // Read the FAQ and misc/fonts/README.txt about using icon fonts. It's really easy and super convenient!
+ // Read the FAQ and docs/FONTS.txt about using icon fonts. It's really easy and super convenient!
ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Save")) ref->Colors[i] = style.Colors[i];
ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Revert")) style.Colors[i] = ref->Colors[i];
}
@@ -3448,7 +3413,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
{
ImGuiIO& io = ImGui::GetIO();
ImFontAtlas* atlas = io.Fonts;
- HelpMarker("Read FAQ and misc/fonts/README.txt for details on font loading.");
+ HelpMarker("Read FAQ and docs/FONTS.txt for details on font loading.");
ImGui::PushItemWidth(120);
for (int i = 0; i < atlas->Fonts.Size; i++)
{
@@ -3468,17 +3433,27 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
ImGui::Text("Fallback character: '%c' (U+%04X)", font->FallbackChar, font->FallbackChar);
ImGui::Text("Ellipsis character: '%c' (U+%04X)", font->EllipsisChar, font->EllipsisChar);
const float surface_sqrt = sqrtf((float)font->MetricsTotalSurface);
- ImGui::Text("Texture surface: %d pixels (approx) ~ %dx%d", font->MetricsTotalSurface, (int)surface_sqrt, (int)surface_sqrt);
+ ImGui::Text("Texture Area: about %d px ~%dx%d px", font->MetricsTotalSurface, (int)surface_sqrt, (int)surface_sqrt);
for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
- if (const ImFontConfig* cfg = &font->ConfigData[config_i])
- ImGui::BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d", config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH);
+ if (font->ConfigData)
+ if (const ImFontConfig* cfg = &font->ConfigData[config_i])
+ ImGui::BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d", config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH);
if (ImGui::TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
{
// Display all glyphs of the fonts in separate pages of 256 characters
- for (int base = 0; base < 0x10000; base += 256)
+ for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
{
+ // Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k)
+ // This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT is large.
+ // (if ImWchar==ImWchar32 we will do at least about 272 queries here)
+ if (!(base & 4095) && font->IsGlyphRangeUnused(base, base + 4095))
+ {
+ base += 4096 - 256;
+ continue;
+ }
+
int count = 0;
- for (int n = 0; n < 256; n++)
+ for (unsigned int n = 0; n < 256; n++)
count += font->FindGlyphNoFallback((ImWchar)(base + n)) ? 1 : 0;
if (count > 0 && ImGui::TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph"))
{
@@ -3486,7 +3461,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
float cell_spacing = style.ItemSpacing.y;
ImVec2 base_pos = ImGui::GetCursorScreenPos();
ImDrawList* draw_list = ImGui::GetWindowDrawList();
- for (int n = 0; n < 256; n++)
+ for (unsigned int n = 0; n < 256; n++)
{
ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing));
ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);
@@ -3499,6 +3474,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
ImGui::BeginTooltip();
ImGui::Text("Codepoint: U+%04X", base + n);
ImGui::Separator();
+ ImGui::Text("Visible: %d", glyph->Visible);
ImGui::Text("AdvanceX: %.1f", glyph->AdvanceX);
ImGui::Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1);
ImGui::Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph->U0, glyph->V0, glyph->U1, glyph->V1);
@@ -3538,8 +3514,9 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
ImGui::Checkbox("Anti-aliased lines", &style.AntiAliasedLines); ImGui::SameLine(); HelpMarker("When disabling anti-aliasing lines, you'll probably want to disable borders in your style as well.");
ImGui::Checkbox("Anti-aliased fill", &style.AntiAliasedFill);
ImGui::PushItemWidth(100);
- ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, FLT_MAX, "%.2f", 2.0f);
+ ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, 10.0f, "%.2f");
if (style.CurveTessellationTol < 0.10f) style.CurveTessellationTol = 0.10f;
+ ImGui::DragFloat("Circle segment Max Error", &style.CircleSegmentMaxError, 0.01f, 0.10f, 10.0f, "%.2f");
ImGui::DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero.
ImGui::PopItemWidth();
@@ -3612,6 +3589,7 @@ static void ShowExampleMenuFile()
}
if (ImGui::MenuItem("Save", "Ctrl+S")) {}
if (ImGui::MenuItem("Save As..")) {}
+
ImGui::Separator();
if (ImGui::BeginMenu("Options"))
{
@@ -3623,13 +3601,12 @@ static void ShowExampleMenuFile()
ImGui::EndChild();
static float f = 0.5f;
static int n = 0;
- static bool b = true;
ImGui::SliderFloat("Value", &f, 0.0f, 1.0f);
ImGui::InputFloat("Input", &f, 0.1f);
ImGui::Combo("Combo", &n, "Yes\0No\0Maybe\0\0");
- ImGui::Checkbox("Check", &b);
ImGui::EndMenu();
}
+
if (ImGui::BeginMenu("Colors"))
{
float sz = ImGui::GetTextLineHeight();
@@ -3644,6 +3621,17 @@ static void ShowExampleMenuFile()
}
ImGui::EndMenu();
}
+
+ // Here we demonstrate appending again to the "Options" menu (which we already created above)
+ // Of course in this demo it is a little bit silly that this function calls BeginMenu("Options") twice.
+ // In a real code-base using it would make senses to use this feature from very different code locations.
+ if (ImGui::BeginMenu("Options")) // <-- Append!
+ {
+ static bool b = true;
+ ImGui::Checkbox("SomeOption", &b);
+ ImGui::EndMenu();
+ }
+
if (ImGui::BeginMenu("Disabled", false)) // Disabled
{
IM_ASSERT(0);
@@ -4381,8 +4369,6 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
"Custom: Always Square",
"Custom: Fixed Steps (100)",
};
- if (ImGui::IsWindowDocked())
- ImGui::Text("Warning: Sizing Constraints won't work if the window is docked!");
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("800x200")) { ImGui::SetWindowSize(ImVec2(800, 200)); }
@@ -4404,20 +4390,17 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
// Demonstrate creating a simple static window with no decoration + a context-menu to choose which corner of the screen to use.
static void ShowExampleAppSimpleOverlay(bool* p_open)
{
- // FIXME-VIEWPORT: Select a default viewport
const float DISTANCE = 10.0f;
static int corner = 0;
ImGuiIO& io = ImGui::GetIO();
if (corner != -1)
{
- ImGuiViewport* viewport = ImGui::GetMainViewport();
- ImVec2 window_pos = ImVec2((corner & 1) ? (viewport->Pos.x + viewport->Size.x - DISTANCE) : (viewport->Pos.x + DISTANCE), (corner & 2) ? (viewport->Pos.y + viewport->Size.y - DISTANCE) : (viewport->Pos.y + DISTANCE));
+ ImVec2 window_pos = ImVec2((corner & 1) ? io.DisplaySize.x - DISTANCE : DISTANCE, (corner & 2) ? io.DisplaySize.y - DISTANCE : DISTANCE);
ImVec2 window_pos_pivot = ImVec2((corner & 1) ? 1.0f : 0.0f, (corner & 2) ? 1.0f : 0.0f);
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
- ImGui::SetNextWindowViewport(viewport->ID);
}
ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background
- if (ImGui::Begin("Example: Simple overlay", p_open, (corner != -1 ? ImGuiWindowFlags_NoMove : 0) | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav))
+ if (ImGui::Begin("Example: Simple overlay", p_open, (corner != -1 ? ImGuiWindowFlags_NoMove : 0) | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav))
{
ImGui::Text("Simple overlay\n" "in the corner of the screen.\n" "(right-click to change position)");
ImGui::Separator();
@@ -4491,28 +4474,59 @@ static void ShowExampleAppCustomRendering(bool* p_open)
if (ImGui::BeginTabBar("##TabBar"))
{
- // Primitives
if (ImGui::BeginTabItem("Primitives"))
{
+ ImGui::PushItemWidth(-ImGui::GetFontSize() * 10);
+
+ // Draw gradients
+ // (note that those are currently exacerbating our sRGB/Linear issues)
+ ImGui::Text("Gradients");
+ ImVec2 gradient_size = ImVec2(ImGui::CalcItemWidth(), ImGui::GetFrameHeight());
+ {
+ ImVec2 p = ImGui::GetCursorScreenPos();
+ ImU32 col_a = ImGui::GetColorU32(ImVec4(0.0f, 0.0f, 0.0f, 1.0f));
+ ImU32 col_b = ImGui::GetColorU32(ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
+ draw_list->AddRectFilledMultiColor(p, ImVec2(p.x + gradient_size.x, p.y + gradient_size.y), col_a, col_b, col_b, col_a);
+ ImGui::InvisibleButton("##gradient1", gradient_size);
+ }
+ {
+ ImVec2 p = ImGui::GetCursorScreenPos();
+ ImU32 col_a = ImGui::GetColorU32(ImVec4(0.0f, 1.0f, 0.0f, 1.0f));
+ ImU32 col_b = ImGui::GetColorU32(ImVec4(1.0f, 0.0f, 0.0f, 1.0f));
+ draw_list->AddRectFilledMultiColor(p, ImVec2(p.x + gradient_size.x, p.y + gradient_size.y), col_a, col_b, col_b, col_a);
+ ImGui::InvisibleButton("##gradient2", gradient_size);
+ }
+
+ // Draw a bunch of primitives
+ ImGui::Text("All primitives");
static float sz = 36.0f;
static float thickness = 3.0f;
+ static int ngon_sides = 6;
+ static bool circle_segments_override = false;
+ static int circle_segments_override_v = 12;
static ImVec4 colf = ImVec4(1.0f, 1.0f, 0.4f, 1.0f);
ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 72.0f, "%.0f");
ImGui::DragFloat("Thickness", &thickness, 0.05f, 1.0f, 8.0f, "%.02f");
+ ImGui::SliderInt("N-gon sides", &ngon_sides, 3, 12);
+ ImGui::Checkbox("##circlesegmentoverride", &circle_segments_override);
+ ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
+ if (ImGui::SliderInt("Circle segments", &circle_segments_override_v, 3, 40))
+ circle_segments_override = true;
ImGui::ColorEdit4("Color", &colf.x);
const ImVec2 p = ImGui::GetCursorScreenPos();
const ImU32 col = ImColor(colf);
+ const float spacing = 10.0f;
+ const ImDrawCornerFlags corners_none = 0;
+ const ImDrawCornerFlags corners_all = ImDrawCornerFlags_All;
+ const ImDrawCornerFlags corners_tl_br = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_BotRight;
+ const int circle_segments = circle_segments_override ? circle_segments_override_v : 0;
float x = p.x + 4.0f, y = p.y + 4.0f;
- float spacing = 10.0f;
- ImDrawCornerFlags corners_none = 0;
- ImDrawCornerFlags corners_all = ImDrawCornerFlags_All;
- ImDrawCornerFlags corners_tl_br = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_BotRight;
for (int n = 0; n < 2; n++)
{
// First line uses a thickness of 1.0f, second line uses the configurable thickness
float th = (n == 0) ? 1.0f : thickness;
- draw_list->AddCircle(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, 6, th); x += sz + spacing; // Hexagon
- draw_list->AddCircle(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, 20, th); x += sz + spacing; // Circle
+ draw_list->AddNgon(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, ngon_sides, th); x += sz + spacing; // N-gon
+ draw_list->AddCircle(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, circle_segments, th); x += sz + spacing; // Circle
draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 0.0f, corners_none, th); x += sz + spacing; // Square
draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 10.0f, corners_all, th); x += sz + spacing; // Square with all rounded corners
draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 10.0f, corners_tl_br, th); x += sz + spacing; // Square with two rounded corners
@@ -4525,8 +4539,8 @@ static void ShowExampleAppCustomRendering(bool* p_open)
x = p.x + 4;
y += sz + spacing;
}
- draw_list->AddCircleFilled(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, 6); x += sz + spacing; // Hexagon
- draw_list->AddCircleFilled(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, 32); x += sz + spacing; // Circle
+ draw_list->AddNgonFilled(ImVec2(x + sz * 0.5f, y + sz * 0.5f), sz*0.5f, col, ngon_sides); x += sz + spacing; // N-gon
+ draw_list->AddCircleFilled(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, circle_segments);x += sz + spacing; // Circle
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col); x += sz + spacing; // Square
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 10.0f); x += sz + spacing; // Square with all rounded corners
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 10.0f, corners_tl_br); x += sz + spacing; // Square with two rounded corners
@@ -4537,6 +4551,8 @@ static void ShowExampleAppCustomRendering(bool* p_open)
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + 1, y + 1), col); x += sz; // Pixel (faster than AddLine)
draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x + sz, y + sz), IM_COL32(0, 0, 0, 255), IM_COL32(255, 0, 0, 255), IM_COL32(255, 255, 0, 255), IM_COL32(0, 255, 0, 255));
ImGui::Dummy(ImVec2((sz + spacing) * 9.8f, (sz + spacing) * 3));
+
+ ImGui::PopItemWidth();
ImGui::EndTabItem();
}
@@ -4603,9 +4619,9 @@ static void ShowExampleAppCustomRendering(bool* p_open)
ImVec2 window_size = ImGui::GetWindowSize();
ImVec2 window_center = ImVec2(window_pos.x + window_size.x * 0.5f, window_pos.y + window_size.y * 0.5f);
if (draw_bg)
- ImGui::GetBackgroundDrawList()->AddCircle(window_center, window_size.x * 0.6f, IM_COL32(255, 0, 0, 200), 48, 10+4);
+ ImGui::GetBackgroundDrawList()->AddCircle(window_center, window_size.x * 0.6f, IM_COL32(255, 0, 0, 200), 0, 10+4);
if (draw_fg)
- ImGui::GetForegroundDrawList()->AddCircle(window_center, window_size.y * 0.6f, IM_COL32(0, 255, 0, 200), 48, 10);
+ ImGui::GetForegroundDrawList()->AddCircle(window_center, window_size.y * 0.6f, IM_COL32(0, 255, 0, 200), 0, 10);
ImGui::EndTabItem();
}
@@ -4615,99 +4631,6 @@ static void ShowExampleAppCustomRendering(bool* p_open)
ImGui::End();
}
-//-----------------------------------------------------------------------------
-// [SECTION] Example App: Docking, DockSpace / ShowExampleAppDockSpace()
-//-----------------------------------------------------------------------------
-
-// Demonstrate using DockSpace() to create an explicit docking node within an existing window.
-// Note that you already dock windows into each others _without_ a DockSpace() by just moving windows
-// from their title bar (or by holding SHIFT if io.ConfigDockingWithShift is set).
-// DockSpace() is only useful to construct to a central location for your application.
-void ShowExampleAppDockSpace(bool* p_open)
-{
- static bool opt_fullscreen_persistant = true;
- bool opt_fullscreen = opt_fullscreen_persistant;
- static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None;
-
- // We are using the ImGuiWindowFlags_NoDocking flag to make the parent window not dockable into,
- // because it would be confusing to have two docking targets within each others.
- ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
- if (opt_fullscreen)
- {
- ImGuiViewport* viewport = ImGui::GetMainViewport();
- ImGui::SetNextWindowPos(viewport->Pos);
- ImGui::SetNextWindowSize(viewport->Size);
- ImGui::SetNextWindowViewport(viewport->ID);
- ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
- ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
- window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
- window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
- }
-
- // When using ImGuiDockNodeFlags_PassthruCentralNode, DockSpace() will render our background and handle the pass-thru hole, so we ask Begin() to not render a background.
- if (dockspace_flags & ImGuiDockNodeFlags_PassthruCentralNode)
- window_flags |= ImGuiWindowFlags_NoBackground;
-
- // Important: note that we proceed even if Begin() returns false (aka window is collapsed).
- // This is because we want to keep our DockSpace() active. If a DockSpace() is inactive,
- // all active windows docked into it will lose their parent and become undocked.
- // We cannot preserve the docking relationship between an active window and an inactive docking, otherwise
- // any change of dockspace/settings would lead to windows being stuck in limbo and never being visible.
- ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
- ImGui::Begin("DockSpace Demo", p_open, window_flags);
- ImGui::PopStyleVar();
-
- if (opt_fullscreen)
- ImGui::PopStyleVar(2);
-
- // DockSpace
- ImGuiIO& io = ImGui::GetIO();
- if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable)
- {
- ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
- ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
- }
- else
- {
- ShowDockingDisabledMessage();
- }
-
- if (ImGui::BeginMenuBar())
- {
- if (ImGui::BeginMenu("Docking"))
- {
- // Disabling fullscreen would allow the window to be moved to the front of other windows,
- // which we can't undo at the moment without finer window depth/z control.
- //ImGui::MenuItem("Fullscreen", NULL, &opt_fullscreen_persistant);
-
- if (ImGui::MenuItem("Flag: NoSplit", "", (dockspace_flags & ImGuiDockNodeFlags_NoSplit) != 0)) dockspace_flags ^= ImGuiDockNodeFlags_NoSplit;
- if (ImGui::MenuItem("Flag: NoResize", "", (dockspace_flags & ImGuiDockNodeFlags_NoResize) != 0)) dockspace_flags ^= ImGuiDockNodeFlags_NoResize;
- if (ImGui::MenuItem("Flag: NoDockingInCentralNode", "", (dockspace_flags & ImGuiDockNodeFlags_NoDockingInCentralNode) != 0)) dockspace_flags ^= ImGuiDockNodeFlags_NoDockingInCentralNode;
- if (ImGui::MenuItem("Flag: PassthruCentralNode", "", (dockspace_flags & ImGuiDockNodeFlags_PassthruCentralNode) != 0)) dockspace_flags ^= ImGuiDockNodeFlags_PassthruCentralNode;
- if (ImGui::MenuItem("Flag: AutoHideTabBar", "", (dockspace_flags & ImGuiDockNodeFlags_AutoHideTabBar) != 0)) dockspace_flags ^= ImGuiDockNodeFlags_AutoHideTabBar;
- ImGui::Separator();
- if (ImGui::MenuItem("Close DockSpace", NULL, false, p_open != NULL))
- *p_open = false;
- ImGui::EndMenu();
- }
- HelpMarker(
- "When docking is enabled, you can ALWAYS dock MOST window into another! Try it now!" "\n\n"
- " > if io.ConfigDockingWithShift==false (default):" "\n"
- " drag windows from title bar to dock" "\n"
- " > if io.ConfigDockingWithShift==true:" "\n"
- " drag windows from anywhere and hold Shift to dock" "\n\n"
- "This demo app has nothing to do with it!" "\n\n"
- "This demo app only demonstrate the use of ImGui::DockSpace() which allows you to manually create a docking node _within_ another window. This is useful so you can decorate your main application window (e.g. with a menu bar)." "\n\n"
- "ImGui::DockSpace() comes with one hard constraint: it needs to be submitted _before_ any window which may be docked into it. Therefore, if you use a dock spot as the central point of your application, you'll probably want it to be part of the very first window you are submitting to imgui every frame." "\n\n"
- "(NB: because of this constraint, the implicit \"Debug\" window can not be docked into an explicit DockSpace() node, because that window is submitted as part of the NewFrame() call. An easy workaround is that you can create your own implicit \"Debug##2\" window after calling DockSpace() and leave it in the window stack for anyone to use.)"
- );
-
- ImGui::EndMenuBar();
- }
-
- ImGui::End();
-}
-
//-----------------------------------------------------------------------------
// [SECTION] Example App: Documents Handling / ShowExampleAppDocuments()
//-----------------------------------------------------------------------------
@@ -4806,25 +4729,11 @@ void ShowExampleAppDocuments(bool* p_open)
static ExampleAppDocuments app;
// Options
- enum Target
- {
- Target_None,
- Target_Tab, // Create documents as local tab into a local tab bar
- Target_DockSpaceAndWindow // Create documents as regular windows, and create an embedded dockspace
- };
- static Target opt_target = Target_Tab;
- static bool opt_reorderable = true;
+ static bool opt_reorderable = true;
static ImGuiTabBarFlags opt_fitting_flags = ImGuiTabBarFlags_FittingPolicyDefault_;
- // When (opt_target == Target_DockSpaceAndWindow) there is the possibily that one of our child Document window (e.g. "Eggplant")
- // that we emit gets docked into the same spot as the parent window ("Example: Documents").
- // This would create a problematic feedback loop because selecting the "Eggplant" tab would make the "Example: Documents" tab
- // not visible, which in turn would stop submitting the "Eggplant" window.
- // We avoid this problem by submitting our documents window even if our parent window is not currently visible.
- // Another solution may be to make the "Example: Documents" window use the ImGuiWindowFlags_NoDocking.
-
bool window_contents_visible = ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar);
- if (!window_contents_visible && opt_target != Target_DockSpaceAndWindow)
+ if (!window_contents_visible)
{
ImGui::End();
return;
@@ -4871,17 +4780,10 @@ void ShowExampleAppDocuments(bool* p_open)
doc->DoForceClose();
ImGui::PopID();
}
- ImGui::PushItemWidth(ImGui::GetFontSize() * 12);
- ImGui::Combo("Output", (int*)&opt_target, "None\0TabBar+Tabs\0DockSpace+Window\0");
- ImGui::PopItemWidth();
- bool redock_all = false;
- if (opt_target == Target_Tab) { ImGui::SameLine(); ImGui::Checkbox("Reorderable Tabs", &opt_reorderable); }
- if (opt_target == Target_DockSpaceAndWindow) { ImGui::SameLine(); redock_all = ImGui::Button("Redock all"); }
ImGui::Separator();
- // Tabs
- if (opt_target == Target_Tab)
+ // Submit Tab Bar and Tabs
{
ImGuiTabBarFlags tab_bar_flags = (opt_fitting_flags) | (opt_reorderable ? ImGuiTabBarFlags_Reorderable : 0);
if (ImGui::BeginTabBar("##tabs", tab_bar_flags))
@@ -4921,53 +4823,6 @@ void ShowExampleAppDocuments(bool* p_open)
ImGui::EndTabBar();
}
}
- else if (opt_target == Target_DockSpaceAndWindow)
- {
- if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable)
- {
- NotifyOfDocumentsClosedElsewhere(app);
-
- // Create a DockSpace node where any window can be docked
- ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
- ImGui::DockSpace(dockspace_id);
-
- // Create Windows
- for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
- {
- MyDocument* doc = &app.Documents[doc_n];
- if (!doc->Open)
- continue;
-
- ImGui::SetNextWindowDockID(dockspace_id, redock_all ? ImGuiCond_Always : ImGuiCond_FirstUseEver);
- ImGuiWindowFlags window_flags = (doc->Dirty ? ImGuiWindowFlags_UnsavedDocument : 0);
- bool visible = ImGui::Begin(doc->Name, &doc->Open, window_flags);
-
- // Cancel attempt to close when unsaved add to save queue so we can display a popup.
- if (!doc->Open && doc->Dirty)
- {
- doc->Open = true;
- doc->DoQueueClose();
- }
-
- MyDocument::DisplayContextMenu(doc);
- if (visible)
- MyDocument::DisplayContents(doc);
-
- ImGui::End();
- }
- }
- else
- {
- ShowDockingDisabledMessage();
- }
- }
-
- // Early out other contents
- if (!window_contents_visible)
- {
- ImGui::End();
- return;
- }
// Update closing queue
static ImVector close_queue;
@@ -5058,3 +4913,5 @@ void ImGui::ShowUserGuide() {}
void ImGui::ShowStyleEditor(ImGuiStyle*) {}
#endif
+
+#endif // #ifndef IMGUI_DISABLE
diff --git a/Sources/CImGui/imgui/imgui_draw.cpp b/Sources/CImGui/imgui/imgui_draw.cpp
index ec27dac..1e08bfd 100644
--- a/Sources/CImGui/imgui/imgui_draw.cpp
+++ b/Sources/CImGui/imgui/imgui_draw.cpp
@@ -1,4 +1,4 @@
-// dear imgui, v1.74 WIP
+// dear imgui, v1.76
// (drawing and font code)
/*
@@ -16,7 +16,7 @@ Index of this file:
// [SECTION] ImFontAtlas glyph ranges helpers
// [SECTION] ImFontGlyphRangesBuilder
// [SECTION] ImFont
-// [SECTION] Internal Render Helpers
+// [SECTION] ImGui Internal Render Helpers
// [SECTION] Decompression code
// [SECTION] Default font data (ProggyClean.ttf)
@@ -27,6 +27,8 @@ Index of this file:
#endif
#include "imgui.h"
+#ifndef IMGUI_DISABLE
+
#ifndef IMGUI_DEFINE_MATH_OPERATORS
#define IMGUI_DEFINE_MATH_OPERATORS
#endif
@@ -118,7 +120,7 @@ namespace IMGUI_STB_NAMESPACE
#ifndef STB_RECT_PACK_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds)
#ifndef IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
#define STBRP_STATIC
-#define STBRP_ASSERT(x) IM_ASSERT(x)
+#define STBRP_ASSERT(x) do { IM_ASSERT(x); } while (0)
#define STBRP_SORT ImQsort
#define STB_RECT_PACK_IMPLEMENTATION
#endif
@@ -133,7 +135,7 @@ namespace IMGUI_STB_NAMESPACE
#ifndef IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
#define STBTT_malloc(x,u) ((void)(u), IM_ALLOC(x))
#define STBTT_free(x,u) ((void)(u), IM_FREE(x))
-#define STBTT_assert(x) IM_ASSERT(x)
+#define STBTT_assert(x) do { IM_ASSERT(x); } while(0)
#define STBTT_fmod(x,y) ImFmod(x,y)
#define STBTT_sqrt(x) ImSqrt(x)
#define STBTT_pow(x,y) ImPow(x,y)
@@ -216,8 +218,6 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst)
colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
- colors[ImGuiCol_DockingPreview] = colors[ImGuiCol_HeaderActive] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
- colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
@@ -273,8 +273,6 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst)
colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
- colors[ImGuiCol_DockingPreview] = colors[ImGuiCol_Header] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
- colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
@@ -331,8 +329,6 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst)
colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
- colors[ImGuiCol_DockingPreview] = colors[ImGuiCol_Header] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
- colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
@@ -354,14 +350,29 @@ ImDrawListSharedData::ImDrawListSharedData()
Font = NULL;
FontSize = 0.0f;
CurveTessellationTol = 0.0f;
+ CircleSegmentMaxError = 0.0f;
ClipRectFullscreen = ImVec4(-8192.0f, -8192.0f, +8192.0f, +8192.0f);
InitialFlags = ImDrawListFlags_None;
- // Const data
- for (int i = 0; i < IM_ARRAYSIZE(CircleVtx12); i++)
+ // Lookup tables
+ for (int i = 0; i < IM_ARRAYSIZE(ArcFastVtx); i++)
+ {
+ const float a = ((float)i * 2 * IM_PI) / (float)IM_ARRAYSIZE(ArcFastVtx);
+ ArcFastVtx[i] = ImVec2(ImCos(a), ImSin(a));
+ }
+ memset(CircleSegmentCounts, 0, sizeof(CircleSegmentCounts)); // This will be set by SetCircleSegmentMaxError()
+}
+
+void ImDrawListSharedData::SetCircleSegmentMaxError(float max_error)
+{
+ if (CircleSegmentMaxError == max_error)
+ return;
+ CircleSegmentMaxError = max_error;
+ for (int i = 0; i < IM_ARRAYSIZE(CircleSegmentCounts); i++)
{
- const float a = ((float)i * 2 * IM_PI) / (float)IM_ARRAYSIZE(CircleVtx12);
- CircleVtx12[i] = ImVec2(ImCos(a), ImSin(a));
+ const float radius = i + 1.0f;
+ const int segment_count = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, CircleSegmentMaxError);
+ CircleSegmentCounts[i] = (ImU8)ImMin(segment_count, 255);
}
}
@@ -522,10 +533,13 @@ void ImDrawList::PopTextureID()
UpdateTextureID();
}
-// NB: this can be called with negative count for removing primitives (as long as the result does not underflow)
+// Reserve space for a number of vertices and indices.
+// You must finish filling your reserved data before calling PrimReserve() again, as it may reallocate or
+// submit the intermediate results. PrimUnreserve() can be used to release unused allocations.
void ImDrawList::PrimReserve(int idx_count, int vtx_count)
{
// Large mesh support (when enabled)
+ IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset))
{
_VtxCurrentOffset = VtxBuffer.Size;
@@ -533,7 +547,7 @@ void ImDrawList::PrimReserve(int idx_count, int vtx_count)
AddDrawCmd();
}
- ImDrawCmd& draw_cmd = CmdBuffer.Data[CmdBuffer.Size-1];
+ ImDrawCmd& draw_cmd = CmdBuffer.Data[CmdBuffer.Size - 1];
draw_cmd.ElemCount += idx_count;
int vtx_buffer_old_size = VtxBuffer.Size;
@@ -545,6 +559,17 @@ void ImDrawList::PrimReserve(int idx_count, int vtx_count)
_IdxWritePtr = IdxBuffer.Data + idx_buffer_old_size;
}
+// Release the a number of reserved vertices/indices from the end of the last reservation made with PrimReserve().
+void ImDrawList::PrimUnreserve(int idx_count, int vtx_count)
+{
+ IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
+
+ ImDrawCmd& draw_cmd = CmdBuffer.Data[CmdBuffer.Size - 1];
+ draw_cmd.ElemCount -= idx_count;
+ VtxBuffer.shrink(VtxBuffer.Size - vtx_count);
+ IdxBuffer.shrink(IdxBuffer.Size - idx_count);
+}
+
// Fully unrolled with inline call to keep our debug builds decently fast.
void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, ImU32 col)
{
@@ -592,8 +617,8 @@ void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, c
// On AddPolyline() and AddConvexPolyFilled() we intentionally avoid using ImVec2 and superflous function calls to optimize debug/non-inlined builds.
// Those macros expects l-values.
-#define IM_NORMALIZE2F_OVER_ZERO(VX,VY) { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = 1.0f / ImSqrt(d2); VX *= inv_len; VY *= inv_len; } }
-#define IM_FIXNORMAL2F(VX,VY) { float d2 = VX*VX + VY*VY; if (d2 < 0.5f) d2 = 0.5f; float inv_lensq = 1.0f / d2; VX *= inv_lensq; VY *= inv_lensq; }
+#define IM_NORMALIZE2F_OVER_ZERO(VX,VY) do { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = 1.0f / ImSqrt(d2); VX *= inv_len; VY *= inv_len; } } while (0)
+#define IM_FIXNORMAL2F(VX,VY) do { float d2 = VX*VX + VY*VY; if (d2 < 0.5f) d2 = 0.5f; float inv_lensq = 1.0f / d2; VX *= inv_lensq; VY *= inv_lensq; } while (0)
// TODO: Thickness anti-aliased lines cap are missing their AA fringe.
// We avoid using the ImVec2 math operators here to reduce cost to a minimum for debug/non-inlined builds.
@@ -655,7 +680,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
// Average normals
float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f;
float dm_y = (temp_normals[i1].y + temp_normals[i2].y) * 0.5f;
- IM_FIXNORMAL2F(dm_x, dm_y)
+ IM_FIXNORMAL2F(dm_x, dm_y);
dm_x *= AA_SIZE;
dm_y *= AA_SIZE;
@@ -873,10 +898,18 @@ void ImDrawList::PathArcToFast(const ImVec2& center, float radius, int a_min_of_
_Path.push_back(center);
return;
}
+
+ // For legacy reason the PathArcToFast() always takes angles where 2*PI is represented by 12,
+ // but it is possible to set IM_DRAWLIST_ARCFAST_TESSELATION_MULTIPLIER to a higher value. This should compile to a no-op otherwise.
+#if IM_DRAWLIST_ARCFAST_TESSELLATION_MULTIPLIER != 1
+ a_min_of_12 *= IM_DRAWLIST_ARCFAST_TESSELLATION_MULTIPLIER;
+ a_max_of_12 *= IM_DRAWLIST_ARCFAST_TESSELLATION_MULTIPLIER;
+#endif
+
_Path.reserve(_Path.Size + (a_max_of_12 - a_min_of_12 + 1));
for (int a = a_min_of_12; a <= a_max_of_12; a++)
{
- const ImVec2& c = _Data->CircleVtx12[a % IM_ARRAYSIZE(_Data->CircleVtx12)];
+ const ImVec2& c = _Data->ArcFastVtx[a % IM_ARRAYSIZE(_Data->ArcFastVtx)];
_Path.push_back(ImVec2(center.x + c.x * radius, center.y + c.y * radius));
}
}
@@ -899,6 +932,17 @@ void ImDrawList::PathArcTo(const ImVec2& center, float radius, float a_min, floa
}
}
+ImVec2 ImBezierCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, float t)
+{
+ float u = 1.0f - t;
+ float w1 = u*u*u;
+ float w2 = 3*u*u*t;
+ float w3 = 3*u*t*t;
+ float w4 = t*t*t;
+ return ImVec2(w1*p1.x + w2*p2.x + w3*p3.x + w4*p4.x, w1*p1.y + w2*p2.y + w3*p3.y + w4*p4.y);
+}
+
+// Closely mimics BezierClosestPointCasteljauStep() in imgui.cpp
static void PathBezierToCasteljau(ImVector* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level)
{
float dx = x4 - x1;
@@ -919,7 +963,6 @@ static void PathBezierToCasteljau(ImVector* path, float x1, float y1, fl
float x123 = (x12+x23)*0.5f, y123 = (y12+y23)*0.5f;
float x234 = (x23+x34)*0.5f, y234 = (y23+y34)*0.5f;
float x1234 = (x123+x234)*0.5f, y1234 = (y123+y234)*0.5f;
-
PathBezierToCasteljau(path, x1,y1, x12,y12, x123,y123, x1234,y1234, tess_tol, level+1);
PathBezierToCasteljau(path, x1234,y1234, x234,y234, x34,y34, x4,y4, tess_tol, level+1);
}
@@ -930,22 +973,13 @@ void ImDrawList::PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImV
ImVec2 p1 = _Path.back();
if (num_segments == 0)
{
- // Auto-tessellated
- PathBezierToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, _Data->CurveTessellationTol, 0);
+ PathBezierToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, _Data->CurveTessellationTol, 0); // Auto-tessellated
}
else
{
float t_step = 1.0f / (float)num_segments;
for (int i_step = 1; i_step <= num_segments; i_step++)
- {
- float t = t_step * i_step;
- float u = 1.0f - t;
- float w1 = u*u*u;
- float w2 = 3*u*u*t;
- float w3 = 3*u*t*t;
- float w4 = t*t*t;
- _Path.push_back(ImVec2(w1*p1.x + w2*p2.x + w3*p3.x + w4*p4.x, w1*p1.y + w2*p2.y + w3*p3.y + w4*p4.y));
- }
+ _Path.push_back(ImBezierCalc(p1, p2, p3, p4, t_step * i_step));
}
}
@@ -1075,6 +1109,67 @@ void ImDrawList::AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImV
}
void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness)
+{
+ if ((col & IM_COL32_A_MASK) == 0 || radius <= 0.0f)
+ return;
+
+ // Obtain segment count
+ if (num_segments <= 0)
+ {
+ // Automatic segment count
+ const int radius_idx = (int)radius - 1;
+ if (radius_idx < IM_ARRAYSIZE(_Data->CircleSegmentCounts))
+ num_segments = _Data->CircleSegmentCounts[radius_idx]; // Use cached value
+ else
+ num_segments = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, _Data->CircleSegmentMaxError);
+ }
+ else
+ {
+ // Explicit segment count (still clamp to avoid drawing insanely tessellated shapes)
+ num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX);
+ }
+
+ // Because we are filling a closed shape we remove 1 from the count of segments/points
+ const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
+ if (num_segments == 12)
+ PathArcToFast(center, radius - 0.5f, 0, 12);
+ else
+ PathArcTo(center, radius - 0.5f, 0.0f, a_max, num_segments - 1);
+ PathStroke(col, true, thickness);
+}
+
+void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments)
+{
+ if ((col & IM_COL32_A_MASK) == 0 || radius <= 0.0f)
+ return;
+
+ // Obtain segment count
+ if (num_segments <= 0)
+ {
+ // Automatic segment count
+ const int radius_idx = (int)radius - 1;
+ if (radius_idx < IM_ARRAYSIZE(_Data->CircleSegmentCounts))
+ num_segments = _Data->CircleSegmentCounts[radius_idx]; // Use cached value
+ else
+ num_segments = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, _Data->CircleSegmentMaxError);
+ }
+ else
+ {
+ // Explicit segment count (still clamp to avoid drawing insanely tessellated shapes)
+ num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX);
+ }
+
+ // Because we are filling a closed shape we remove 1 from the count of segments/points
+ const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
+ if (num_segments == 12)
+ PathArcToFast(center, radius, 0, 12);
+ else
+ PathArcTo(center, radius, 0.0f, a_max, num_segments - 1);
+ PathFillConvex(col);
+}
+
+// Guaranteed to honor 'num_segments'
+void ImDrawList::AddNgon(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness)
{
if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2)
return;
@@ -1085,7 +1180,8 @@ void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int nu
PathStroke(col, true, thickness);
}
-void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments)
+// Guaranteed to honor 'num_segments'
+void ImDrawList::AddNgonFilled(const ImVec2& center, float radius, ImU32 col, int num_segments)
{
if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2)
return;
@@ -1096,13 +1192,14 @@ void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col,
PathFillConvex(col);
}
-void ImDrawList::AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments)
+// Cubic Bezier takes 4 controls points
+void ImDrawList::AddBezierCurve(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments)
{
if ((col & IM_COL32_A_MASK) == 0)
return;
- PathLineTo(pos0);
- PathBezierCurveTo(cp0, cp1, pos1, num_segments);
+ PathLineTo(p1);
+ PathBezierCurveTo(p2, p3, p4, num_segments);
PathStroke(col, false, thickness);
}
@@ -1220,7 +1317,7 @@ void ImDrawListSplitter::ClearFreeMemory()
void ImDrawListSplitter::Split(ImDrawList* draw_list, int channels_count)
{
- IM_ASSERT(_Current == 0 && _Count <= 1);
+ IM_ASSERT(_Current == 0 && _Count <= 1 && "Nested channel splitting is not supported. Please use separate instances of ImDrawListSplitter.");
int old_channels_count = _Channels.Size;
if (old_channels_count < channels_count)
_Channels.resize(channels_count);
@@ -1281,7 +1378,7 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list)
// Merge previous channel last draw command with current channel first draw command if matching.
last_cmd->ElemCount += ch._CmdBuffer[0].ElemCount;
idx_offset += ch._CmdBuffer[0].ElemCount;
- ch._CmdBuffer.erase(ch._CmdBuffer.Data);
+ ch._CmdBuffer.erase(ch._CmdBuffer.Data); // FIXME-OPT: Improve for multiple merges.
}
if (ch._CmdBuffer.Size > 0)
last_cmd = &ch._CmdBuffer.back();
@@ -1679,7 +1776,7 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels,
void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0);
if (!data)
{
- IM_ASSERT(0); // Could not load file.
+ IM_ASSERT_USER_ERROR(0, "Could not load font file!");
return NULL;
}
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
@@ -1731,7 +1828,8 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed
int ImFontAtlas::AddCustomRectRegular(unsigned int id, int width, int height)
{
- IM_ASSERT(id >= 0x10000);
+ // Breaking change on 2019/11/21 (1.74): ImFontAtlas::AddCustomRectRegular() now requires an ID >= 0x110000 (instead of >= 0x10000)
+ IM_ASSERT(id >= 0x110000);
IM_ASSERT(width > 0 && width <= 0xFFFF);
IM_ASSERT(height > 0 && height <= 0xFFFF);
ImFontAtlasCustomRect r;
@@ -1758,7 +1856,7 @@ int ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int
return CustomRects.Size - 1; // Return index
}
-void ImFontAtlas::CalcCustomRectUV(const ImFontAtlasCustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max)
+void ImFontAtlas::CalcCustomRectUV(const ImFontAtlasCustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max) const
{
IM_ASSERT(TexWidth > 0 && TexHeight > 0); // Font atlas needs to be built before we can calculate UV coordinates
IM_ASSERT(rect->IsPacked()); // Make sure the rectangle has been packed
@@ -1823,7 +1921,7 @@ struct ImFontBuildSrcData
int DstIndex; // Index into atlas->Fonts[] and dst_tmp_array[]
int GlyphsHighest; // Highest requested codepoint
int GlyphsCount; // Glyph count (excluding missing glyphs and glyphs already set by an earlier source font)
- ImBoolVector GlyphsSet; // Glyph bit map (random access, 1-bit per codepoint. This will be a maximum of 8KB)
+ ImBitVector GlyphsSet; // Glyph bit map (random access, 1-bit per codepoint. This will be a maximum of 8KB)
ImVector GlyphsList; // Glyph codepoints list (flattened version of GlyphsMap)
};
@@ -1833,26 +1931,26 @@ struct ImFontBuildDstData
int SrcCount; // Number of source fonts targeting this destination font.
int GlyphsHighest;
int GlyphsCount;
- ImBoolVector GlyphsSet; // This is used to resolve collision when multiple sources are merged into a same destination font.
+ ImBitVector GlyphsSet; // This is used to resolve collision when multiple sources are merged into a same destination font.
};
-static void UnpackBoolVectorToFlatIndexList(const ImBoolVector* in, ImVector* out)
+static void UnpackBitVectorToFlatIndexList(const ImBitVector* in, ImVector* out)
{
IM_ASSERT(sizeof(in->Storage.Data[0]) == sizeof(int));
- const int* it_begin = in->Storage.begin();
- const int* it_end = in->Storage.end();
- for (const int* it = it_begin; it < it_end; it++)
- if (int entries_32 = *it)
- for (int bit_n = 0; bit_n < 32; bit_n++)
- if (entries_32 & (1u << bit_n))
- out->push_back((int)((it - it_begin) << 5) + bit_n);
+ const ImU32* it_begin = in->Storage.begin();
+ const ImU32* it_end = in->Storage.end();
+ for (const ImU32* it = it_begin; it < it_end; it++)
+ if (ImU32 entries_32 = *it)
+ for (ImU32 bit_n = 0; bit_n < 32; bit_n++)
+ if (entries_32 & ((ImU32)1 << bit_n))
+ out->push_back((int)(((it - it_begin) << 5) + bit_n));
}
bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
{
IM_ASSERT(atlas->ConfigData.Size > 0);
- ImFontAtlasBuildRegisterDefaultCustomRects(atlas);
+ ImFontAtlasBuildInit(atlas);
// Clear atlas
atlas->TexID = (ImTextureID)NULL;
@@ -1906,14 +2004,14 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
{
ImFontBuildSrcData& src_tmp = src_tmp_array[src_i];
ImFontBuildDstData& dst_tmp = dst_tmp_array[src_tmp.DstIndex];
- src_tmp.GlyphsSet.Resize(src_tmp.GlyphsHighest + 1);
+ src_tmp.GlyphsSet.Create(src_tmp.GlyphsHighest + 1);
if (dst_tmp.GlyphsSet.Storage.empty())
- dst_tmp.GlyphsSet.Resize(dst_tmp.GlyphsHighest + 1);
+ dst_tmp.GlyphsSet.Create(dst_tmp.GlyphsHighest + 1);
for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2)
- for (int codepoint = src_range[0]; codepoint <= src_range[1]; codepoint++)
+ for (unsigned int codepoint = src_range[0]; codepoint <= src_range[1]; codepoint++)
{
- if (dst_tmp.GlyphsSet.GetBit(codepoint)) // Don't overwrite existing glyphs. We could make this an option for MergeMode (e.g. MergeOverwrite==true)
+ if (dst_tmp.GlyphsSet.TestBit(codepoint)) // Don't overwrite existing glyphs. We could make this an option for MergeMode (e.g. MergeOverwrite==true)
continue;
if (!stbtt_FindGlyphIndex(&src_tmp.FontInfo, codepoint)) // It is actually in the font?
continue;
@@ -1921,8 +2019,8 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
// Add to avail set/counters
src_tmp.GlyphsCount++;
dst_tmp.GlyphsCount++;
- src_tmp.GlyphsSet.SetBit(codepoint, true);
- dst_tmp.GlyphsSet.SetBit(codepoint, true);
+ src_tmp.GlyphsSet.SetBit(codepoint);
+ dst_tmp.GlyphsSet.SetBit(codepoint);
total_glyphs_count++;
}
}
@@ -1932,7 +2030,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
{
ImFontBuildSrcData& src_tmp = src_tmp_array[src_i];
src_tmp.GlyphsList.reserve(src_tmp.GlyphsCount);
- UnpackBoolVectorToFlatIndexList(&src_tmp.GlyphsSet, &src_tmp.GlyphsList);
+ UnpackBitVectorToFlatIndexList(&src_tmp.GlyphsSet, &src_tmp.GlyphsList);
src_tmp.GlyphsSet.Clear();
IM_ASSERT(src_tmp.GlyphsList.Size == src_tmp.GlyphsCount);
}
@@ -2075,7 +2173,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
const float descent = ImFloor(unscaled_descent * font_scale + ((unscaled_descent > 0.0f) ? +1 : -1));
ImFontAtlasBuildSetupFont(atlas, dst_font, &cfg, ascent, descent);
const float font_off_x = cfg.GlyphOffset.x;
- const float font_off_y = cfg.GlyphOffset.y + ImFloor(dst_font->Ascent + 0.5f);
+ const float font_off_y = cfg.GlyphOffset.y + IM_ROUND(dst_font->Ascent);
for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++)
{
@@ -2104,7 +2202,8 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
return true;
}
-void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas)
+// Register default custom rectangles (this is called/shared by both the stb_truetype and the FreeType builder)
+void ImFontAtlasBuildInit(ImFontAtlas* atlas)
{
if (atlas->CustomRectIds[0] >= 0)
return;
@@ -2195,7 +2294,7 @@ void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
for (int i = 0; i < atlas->CustomRects.Size; i++)
{
const ImFontAtlasCustomRect& r = atlas->CustomRects[i];
- if (r.Font == NULL || r.ID > 0x10000)
+ if (r.Font == NULL || r.ID >= 0x110000)
continue;
IM_ASSERT(r.Font->ContainerAtlas == atlas);
@@ -2459,8 +2558,7 @@ void ImFontGlyphRangesBuilder::AddText(const char* text, const char* text_end)
text += c_len;
if (c_len == 0)
break;
- if (c < 0x10000)
- AddChar((ImWchar)c);
+ AddChar((ImWchar)c);
}
}
@@ -2473,12 +2571,12 @@ void ImFontGlyphRangesBuilder::AddRanges(const ImWchar* ranges)
void ImFontGlyphRangesBuilder::BuildRanges(ImVector* out_ranges)
{
- int max_codepoint = 0x10000;
- for (int n = 0; n < max_codepoint; n++)
+ const int max_codepoint = IM_UNICODE_CODEPOINT_MAX;
+ for (int n = 0; n <= max_codepoint; n++)
if (GetBit(n))
{
out_ranges->push_back((ImWchar)n);
- while (n < max_codepoint - 1 && GetBit(n + 1))
+ while (n < max_codepoint && GetBit(n + 1))
n++;
out_ranges->push_back((ImWchar)n);
}
@@ -2504,6 +2602,7 @@ ImFont::ImFont()
Scale = 1.0f;
Ascent = Descent = 0.0f;
MetricsTotalSurface = 0;
+ memset(Used4kPagesMap, 0, sizeof(Used4kPagesMap));
}
ImFont::~ImFont()
@@ -2531,23 +2630,29 @@ void ImFont::BuildLookupTable()
for (int i = 0; i != Glyphs.Size; i++)
max_codepoint = ImMax(max_codepoint, (int)Glyphs[i].Codepoint);
+ // Build lookup table
IM_ASSERT(Glyphs.Size < 0xFFFF); // -1 is reserved
IndexAdvanceX.clear();
IndexLookup.clear();
DirtyLookupTables = false;
+ memset(Used4kPagesMap, 0, sizeof(Used4kPagesMap));
GrowIndex(max_codepoint + 1);
for (int i = 0; i < Glyphs.Size; i++)
{
int codepoint = (int)Glyphs[i].Codepoint;
IndexAdvanceX[codepoint] = Glyphs[i].AdvanceX;
IndexLookup[codepoint] = (ImWchar)i;
+
+ // Mark 4K page as used
+ const int page_n = codepoint / 4096;
+ Used4kPagesMap[page_n >> 3] |= 1 << (page_n & 7);
}
// Create a glyph to handle TAB
// FIXME: Needs proper TAB handling but it needs to be contextualized (or we could arbitrary say that each string starts at "column 0" ?)
if (FindGlyph((ImWchar)' '))
{
- if (Glyphs.back().Codepoint != '\t') // So we can call this function multiple times
+ if (Glyphs.back().Codepoint != '\t') // So we can call this function multiple times (FIXME: Flaky)
Glyphs.resize(Glyphs.Size + 1);
ImFontGlyph& tab_glyph = Glyphs.back();
tab_glyph = *FindGlyph((ImWchar)' ');
@@ -2557,6 +2662,11 @@ void ImFont::BuildLookupTable()
IndexLookup[(int)tab_glyph.Codepoint] = (ImWchar)(Glyphs.Size-1);
}
+ // Mark special glyphs as not visible (note that AddGlyph already mark as non-visible glyphs with zero-size polygons)
+ SetGlyphVisible((ImWchar)' ', false);
+ SetGlyphVisible((ImWchar)'\t', false);
+
+ // Setup fall-backs
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
FallbackAdvanceX = FallbackGlyph ? FallbackGlyph->AdvanceX : 0.0f;
for (int i = 0; i < max_codepoint + 1; i++)
@@ -2564,6 +2674,25 @@ void ImFont::BuildLookupTable()
IndexAdvanceX[i] = FallbackAdvanceX;
}
+// API is designed this way to avoid exposing the 4K page size
+// e.g. use with IsGlyphRangeUnused(0, 255)
+bool ImFont::IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last)
+{
+ unsigned int page_begin = (c_begin / 4096);
+ unsigned int page_last = (c_last / 4096);
+ for (unsigned int page_n = page_begin; page_n <= page_last; page_n++)
+ if ((page_n >> 3) < sizeof(Used4kPagesMap))
+ if (Used4kPagesMap[page_n >> 3] & (1 << (page_n & 7)))
+ return false;
+ return true;
+}
+
+void ImFont::SetGlyphVisible(ImWchar c, bool visible)
+{
+ if (ImFontGlyph* glyph = (ImFontGlyph*)(void*)FindGlyph((ImWchar)c))
+ glyph->Visible = visible ? 1 : 0;
+}
+
void ImFont::SetFallbackChar(ImWchar c)
{
FallbackChar = c;
@@ -2585,7 +2714,8 @@ void ImFont::AddGlyph(ImWchar codepoint, float x0, float y0, float x1, float y1,
{
Glyphs.resize(Glyphs.Size + 1);
ImFontGlyph& glyph = Glyphs.back();
- glyph.Codepoint = (ImWchar)codepoint;
+ glyph.Codepoint = (unsigned int)codepoint;
+ glyph.Visible = (x0 != x1) && (y0 != y1);
glyph.X0 = x0;
glyph.Y0 = y0;
glyph.X1 = x1;
@@ -2597,7 +2727,7 @@ void ImFont::AddGlyph(ImWchar codepoint, float x0, float y0, float x1, float y1,
glyph.AdvanceX = advance_x + ConfigData->GlyphExtraSpacing.x; // Bake spacing into AdvanceX
if (ConfigData->PixelSnapH)
- glyph.AdvanceX = IM_FLOOR(glyph.AdvanceX + 0.5f);
+ glyph.AdvanceX = IM_ROUND(glyph.AdvanceX);
// Compute rough surface usage metrics (+1 to account for average padding, +0.99 to round)
DirtyLookupTables = true;
@@ -2607,7 +2737,7 @@ void ImFont::AddGlyph(ImWchar codepoint, float x0, float y0, float x1, float y1,
void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
{
IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function.
- int index_size = IndexLookup.Size;
+ unsigned int index_size = (unsigned int)IndexLookup.Size;
if (dst < index_size && IndexLookup.Data[dst] == (ImWchar)-1 && !overwrite_dst) // 'dst' already exists
return;
@@ -2621,7 +2751,7 @@ void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const
{
- if (c >= IndexLookup.Size)
+ if (c >= (size_t)IndexLookup.Size)
return FallbackGlyph;
const ImWchar i = IndexLookup.Data[c];
if (i == (ImWchar)-1)
@@ -2631,7 +2761,7 @@ const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const
const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const
{
- if (c >= IndexLookup.Size)
+ if (c >= (size_t)IndexLookup.Size)
return NULL;
const ImWchar i = IndexLookup.Data[c];
if (i == (ImWchar)-1)
@@ -2834,16 +2964,14 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const
{
- if (c == ' ' || c == '\t' || c == '\n' || c == '\r') // Match behavior of RenderText(), those 4 codepoints are hard-coded.
+ const ImFontGlyph* glyph = FindGlyph(c);
+ if (!glyph || !glyph->Visible)
return;
- if (const ImFontGlyph* glyph = FindGlyph(c))
- {
- float scale = (size >= 0.0f) ? (size / FontSize) : 1.0f;
- pos.x = IM_FLOOR(pos.x + DisplayOffset.x);
- pos.y = IM_FLOOR(pos.y + DisplayOffset.y);
- draw_list->PrimReserve(6, 4);
- draw_list->PrimRectUV(ImVec2(pos.x + glyph->X0 * scale, pos.y + glyph->Y0 * scale), ImVec2(pos.x + glyph->X1 * scale, pos.y + glyph->Y1 * scale), ImVec2(glyph->U0, glyph->V0), ImVec2(glyph->U1, glyph->V1), col);
- }
+ float scale = (size >= 0.0f) ? (size / FontSize) : 1.0f;
+ pos.x = IM_FLOOR(pos.x + DisplayOffset.x);
+ pos.y = IM_FLOOR(pos.y + DisplayOffset.y);
+ draw_list->PrimReserve(6, 4);
+ draw_list->PrimRectUV(ImVec2(pos.x + glyph->X0 * scale, pos.y + glyph->Y0 * scale), ImVec2(pos.x + glyph->X1 * scale, pos.y + glyph->Y1 * scale), ImVec2(glyph->U0, glyph->V0), ImVec2(glyph->U1, glyph->V1), col);
}
void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, bool cpu_fine_clip) const
@@ -2956,79 +3084,76 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
continue;
}
- float char_width = 0.0f;
- if (const ImFontGlyph* glyph = FindGlyph((ImWchar)c))
- {
- char_width = glyph->AdvanceX * scale;
+ const ImFontGlyph* glyph = FindGlyph((ImWchar)c);
+ if (glyph == NULL)
+ continue;
- // Arbitrarily assume that both space and tabs are empty glyphs as an optimization
- if (c != ' ' && c != '\t')
+ float char_width = glyph->AdvanceX * scale;
+ if (glyph->Visible)
+ {
+ // We don't do a second finer clipping test on the Y axis as we've already skipped anything before clip_rect.y and exit once we pass clip_rect.w
+ float x1 = x + glyph->X0 * scale;
+ float x2 = x + glyph->X1 * scale;
+ float y1 = y + glyph->Y0 * scale;
+ float y2 = y + glyph->Y1 * scale;
+ if (x1 <= clip_rect.z && x2 >= clip_rect.x)
{
- // We don't do a second finer clipping test on the Y axis as we've already skipped anything before clip_rect.y and exit once we pass clip_rect.w
- float x1 = x + glyph->X0 * scale;
- float x2 = x + glyph->X1 * scale;
- float y1 = y + glyph->Y0 * scale;
- float y2 = y + glyph->Y1 * scale;
- if (x1 <= clip_rect.z && x2 >= clip_rect.x)
+ // Render a character
+ float u1 = glyph->U0;
+ float v1 = glyph->V0;
+ float u2 = glyph->U1;
+ float v2 = glyph->V1;
+
+ // CPU side clipping used to fit text in their frame when the frame is too small. Only does clipping for axis aligned quads.
+ if (cpu_fine_clip)
{
- // Render a character
- float u1 = glyph->U0;
- float v1 = glyph->V0;
- float u2 = glyph->U1;
- float v2 = glyph->V1;
-
- // CPU side clipping used to fit text in their frame when the frame is too small. Only does clipping for axis aligned quads.
- if (cpu_fine_clip)
+ if (x1 < clip_rect.x)
{
- if (x1 < clip_rect.x)
- {
- u1 = u1 + (1.0f - (x2 - clip_rect.x) / (x2 - x1)) * (u2 - u1);
- x1 = clip_rect.x;
- }
- if (y1 < clip_rect.y)
- {
- v1 = v1 + (1.0f - (y2 - clip_rect.y) / (y2 - y1)) * (v2 - v1);
- y1 = clip_rect.y;
- }
- if (x2 > clip_rect.z)
- {
- u2 = u1 + ((clip_rect.z - x1) / (x2 - x1)) * (u2 - u1);
- x2 = clip_rect.z;
- }
- if (y2 > clip_rect.w)
- {
- v2 = v1 + ((clip_rect.w - y1) / (y2 - y1)) * (v2 - v1);
- y2 = clip_rect.w;
- }
- if (y1 >= y2)
- {
- x += char_width;
- continue;
- }
+ u1 = u1 + (1.0f - (x2 - clip_rect.x) / (x2 - x1)) * (u2 - u1);
+ x1 = clip_rect.x;
}
-
- // We are NOT calling PrimRectUV() here because non-inlined causes too much overhead in a debug builds. Inlined here:
+ if (y1 < clip_rect.y)
+ {
+ v1 = v1 + (1.0f - (y2 - clip_rect.y) / (y2 - y1)) * (v2 - v1);
+ y1 = clip_rect.y;
+ }
+ if (x2 > clip_rect.z)
+ {
+ u2 = u1 + ((clip_rect.z - x1) / (x2 - x1)) * (u2 - u1);
+ x2 = clip_rect.z;
+ }
+ if (y2 > clip_rect.w)
+ {
+ v2 = v1 + ((clip_rect.w - y1) / (y2 - y1)) * (v2 - v1);
+ y2 = clip_rect.w;
+ }
+ if (y1 >= y2)
{
- idx_write[0] = (ImDrawIdx)(vtx_current_idx); idx_write[1] = (ImDrawIdx)(vtx_current_idx+1); idx_write[2] = (ImDrawIdx)(vtx_current_idx+2);
- idx_write[3] = (ImDrawIdx)(vtx_current_idx); idx_write[4] = (ImDrawIdx)(vtx_current_idx+2); idx_write[5] = (ImDrawIdx)(vtx_current_idx+3);
- vtx_write[0].pos.x = x1; vtx_write[0].pos.y = y1; vtx_write[0].col = col; vtx_write[0].uv.x = u1; vtx_write[0].uv.y = v1;
- vtx_write[1].pos.x = x2; vtx_write[1].pos.y = y1; vtx_write[1].col = col; vtx_write[1].uv.x = u2; vtx_write[1].uv.y = v1;
- vtx_write[2].pos.x = x2; vtx_write[2].pos.y = y2; vtx_write[2].col = col; vtx_write[2].uv.x = u2; vtx_write[2].uv.y = v2;
- vtx_write[3].pos.x = x1; vtx_write[3].pos.y = y2; vtx_write[3].col = col; vtx_write[3].uv.x = u1; vtx_write[3].uv.y = v2;
- vtx_write += 4;
- vtx_current_idx += 4;
- idx_write += 6;
+ x += char_width;
+ continue;
}
}
+
+ // We are NOT calling PrimRectUV() here because non-inlined causes too much overhead in a debug builds. Inlined here:
+ {
+ idx_write[0] = (ImDrawIdx)(vtx_current_idx); idx_write[1] = (ImDrawIdx)(vtx_current_idx+1); idx_write[2] = (ImDrawIdx)(vtx_current_idx+2);
+ idx_write[3] = (ImDrawIdx)(vtx_current_idx); idx_write[4] = (ImDrawIdx)(vtx_current_idx+2); idx_write[5] = (ImDrawIdx)(vtx_current_idx+3);
+ vtx_write[0].pos.x = x1; vtx_write[0].pos.y = y1; vtx_write[0].col = col; vtx_write[0].uv.x = u1; vtx_write[0].uv.y = v1;
+ vtx_write[1].pos.x = x2; vtx_write[1].pos.y = y1; vtx_write[1].col = col; vtx_write[1].uv.x = u2; vtx_write[1].uv.y = v1;
+ vtx_write[2].pos.x = x2; vtx_write[2].pos.y = y2; vtx_write[2].col = col; vtx_write[2].uv.x = u2; vtx_write[2].uv.y = v2;
+ vtx_write[3].pos.x = x1; vtx_write[3].pos.y = y2; vtx_write[3].col = col; vtx_write[3].uv.x = u1; vtx_write[3].uv.y = v2;
+ vtx_write += 4;
+ vtx_current_idx += 4;
+ idx_write += 6;
+ }
}
}
-
x += char_width;
}
- // Give back unused vertices
- draw_list->VtxBuffer.resize((int)(vtx_write - draw_list->VtxBuffer.Data));
- draw_list->IdxBuffer.resize((int)(idx_write - draw_list->IdxBuffer.Data));
+ // Give back unused vertices (clipped ones, blanks) ~ this is essentially a PrimUnreserve() action.
+ draw_list->VtxBuffer.Size = (int)(vtx_write - draw_list->VtxBuffer.Data); // Same as calling shrink()
+ draw_list->IdxBuffer.Size = (int)(idx_write - draw_list->IdxBuffer.Data);
draw_list->CmdBuffer[draw_list->CmdBuffer.Size-1].ElemCount -= (idx_expected_size - draw_list->IdxBuffer.Size);
draw_list->_VtxWritePtr = vtx_write;
draw_list->_IdxWritePtr = idx_write;
@@ -3036,15 +3161,71 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
}
//-----------------------------------------------------------------------------
-// [SECTION] Internal Render Helpers
-// (progressively moved from imgui.cpp to here when they are redesigned to stop accessing ImGui global state)
+// [SECTION] ImGui Internal Render Helpers
//-----------------------------------------------------------------------------
+// Vaguely redesigned to stop accessing ImGui global state:
+// - RenderArrow()
+// - RenderBullet()
+// - RenderCheckMark()
// - RenderMouseCursor()
-// - RenderArrowDockMenu()
// - RenderArrowPointingAt()
// - RenderRectFilledRangeH()
-// - RenderRectFilledWithHole()
//-----------------------------------------------------------------------------
+// Function in need of a redesign (legacy mess)
+// - RenderColorRectWithAlphaCheckerboard()
+//-----------------------------------------------------------------------------
+
+// Render an arrow aimed to be aligned with text (p_min is a position in the same space text would be positioned). To e.g. denote expanded/collapsed state
+void ImGui::RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir dir, float scale)
+{
+ const float h = draw_list->_Data->FontSize * 1.00f;
+ float r = h * 0.40f * scale;
+ ImVec2 center = pos + ImVec2(h * 0.50f, h * 0.50f * scale);
+
+ ImVec2 a, b, c;
+ switch (dir)
+ {
+ case ImGuiDir_Up:
+ case ImGuiDir_Down:
+ if (dir == ImGuiDir_Up) r = -r;
+ a = ImVec2(+0.000f, +0.750f) * r;
+ b = ImVec2(-0.866f, -0.750f) * r;
+ c = ImVec2(+0.866f, -0.750f) * r;
+ break;
+ case ImGuiDir_Left:
+ case ImGuiDir_Right:
+ if (dir == ImGuiDir_Left) r = -r;
+ a = ImVec2(+0.750f, +0.000f) * r;
+ b = ImVec2(-0.750f, +0.866f) * r;
+ c = ImVec2(-0.750f, -0.866f) * r;
+ break;
+ case ImGuiDir_None:
+ case ImGuiDir_COUNT:
+ IM_ASSERT(0);
+ break;
+ }
+ draw_list->AddTriangleFilled(center + a, center + b, center + c, col);
+}
+
+void ImGui::RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col)
+{
+ draw_list->AddCircleFilled(pos, draw_list->_Data->FontSize * 0.20f, col, 8);
+}
+
+void ImGui::RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz)
+{
+ float thickness = ImMax(sz / 5.0f, 1.0f);
+ sz -= thickness * 0.5f;
+ pos += ImVec2(thickness * 0.25f, thickness * 0.25f);
+
+ float third = sz / 3.0f;
+ float bx = pos.x + third;
+ float by = pos.y + sz - third * 0.5f;
+ draw_list->PathLineTo(ImVec2(bx - third, by - third));
+ draw_list->PathLineTo(ImVec2(bx, by));
+ draw_list->PathLineTo(ImVec2(bx + third * 2.0f, by - third * 2.0f));
+ draw_list->PathStroke(col, false, thickness);
+}
void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow)
{
@@ -3059,10 +3240,10 @@ void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, Im
pos -= offset;
const ImTextureID tex_id = font_atlas->TexID;
draw_list->PushTextureID(tex_id);
- draw_list->AddImage(tex_id, pos + ImVec2(1, 0)*scale, pos + ImVec2(1, 0)*scale + size*scale, uv[2], uv[3], col_shadow);
- draw_list->AddImage(tex_id, pos + ImVec2(2, 0)*scale, pos + ImVec2(2, 0)*scale + size*scale, uv[2], uv[3], col_shadow);
- draw_list->AddImage(tex_id, pos, pos + size*scale, uv[2], uv[3], col_border);
- draw_list->AddImage(tex_id, pos, pos + size*scale, uv[0], uv[1], col_fill);
+ draw_list->AddImage(tex_id, pos + ImVec2(1,0)*scale, pos + ImVec2(1,0)*scale + size*scale, uv[2], uv[3], col_shadow);
+ draw_list->AddImage(tex_id, pos + ImVec2(2,0)*scale, pos + ImVec2(2,0)*scale + size*scale, uv[2], uv[3], col_shadow);
+ draw_list->AddImage(tex_id, pos, pos + size*scale, uv[2], uv[3], col_border);
+ draw_list->AddImage(tex_id, pos, pos + size*scale, uv[0], uv[1], col_fill);
draw_list->PopTextureID();
}
}
@@ -3080,14 +3261,6 @@ void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half
}
}
-// This is less wide than RenderArrow() and we use in dock nodes instead of the regular RenderArrow() to denote a change of functionality,
-// and because the saved space means that the left-most tab label can stay at exactly the same position as the label of a loose window.
-void ImGui::RenderArrowDockMenu(ImDrawList* draw_list, ImVec2 p_min, float sz, ImU32 col)
-{
- draw_list->AddRectFilled(p_min + ImVec2(sz * 0.10f, sz * 0.15f), p_min + ImVec2(sz * 0.70f, sz * 0.30f), col);
- RenderArrowPointingAt(draw_list, p_min + ImVec2(sz * 0.40f, sz * 0.85f), ImVec2(sz * 0.30f, sz * 0.40f), ImGuiDir_Down, col);
-}
-
static inline float ImAcos01(float x)
{
if (x <= 0.0f) return IM_PI * 0.5f;
@@ -3157,22 +3330,41 @@ void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, Im
draw_list->PathFillConvex(col);
}
-// For CTRL+TAB within a docking node we need to render the dimming background in 8 steps
-// (Because the root node renders the background in one shot, in order to avoid flickering when a child dock node is not submitted)
-void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect inner, ImU32 col, float rounding)
+// Helper for ColorPicker4()
+// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that.
+// Spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding alltogether.
+// FIXME: uses ImGui::GetColorU32
+void ImGui::RenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list, ImVec2 p_min, ImVec2 p_max, ImU32 col, float grid_step, ImVec2 grid_off, float rounding, int rounding_corners_flags)
{
- const bool fill_L = (inner.Min.x > outer.Min.x);
- const bool fill_R = (inner.Max.x < outer.Max.x);
- const bool fill_U = (inner.Min.y > outer.Min.y);
- const bool fill_D = (inner.Max.y < outer.Max.y);
- if (fill_L) draw_list->AddRectFilled(ImVec2(outer.Min.x, inner.Min.y), ImVec2(inner.Min.x, inner.Max.y), col, rounding, (fill_U ? 0 : ImDrawCornerFlags_TopLeft) | (fill_D ? 0 : ImDrawCornerFlags_BotLeft));
- if (fill_R) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Min.y), ImVec2(outer.Max.x, inner.Max.y), col, rounding, (fill_U ? 0 : ImDrawCornerFlags_TopRight) | (fill_D ? 0 : ImDrawCornerFlags_BotRight));
- if (fill_U) draw_list->AddRectFilled(ImVec2(inner.Min.x, outer.Min.y), ImVec2(inner.Max.x, inner.Min.y), col, rounding, (fill_L ? 0 : ImDrawCornerFlags_TopLeft) | (fill_R ? 0 : ImDrawCornerFlags_TopRight));
- if (fill_D) draw_list->AddRectFilled(ImVec2(inner.Min.x, inner.Max.y), ImVec2(inner.Max.x, outer.Max.y), col, rounding, (fill_L ? 0 : ImDrawCornerFlags_BotLeft) | (fill_R ? 0 : ImDrawCornerFlags_BotRight));
- if (fill_L && fill_U) draw_list->AddRectFilled(ImVec2(outer.Min.x, outer.Min.y), ImVec2(inner.Min.x, inner.Min.y), col, rounding, ImDrawCornerFlags_TopLeft);
- if (fill_R && fill_U) draw_list->AddRectFilled(ImVec2(inner.Max.x, outer.Min.y), ImVec2(outer.Max.x, inner.Min.y), col, rounding, ImDrawCornerFlags_TopRight);
- if (fill_L && fill_D) draw_list->AddRectFilled(ImVec2(outer.Min.x, inner.Max.y), ImVec2(inner.Min.x, outer.Max.y), col, rounding, ImDrawCornerFlags_BotLeft);
- if (fill_R && fill_D) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Max.y), ImVec2(outer.Max.x, outer.Max.y), col, rounding, ImDrawCornerFlags_BotRight);
+ if (((col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT) < 0xFF)
+ {
+ ImU32 col_bg1 = ImGui::GetColorU32(ImAlphaBlendColors(IM_COL32(204, 204, 204, 255), col));
+ ImU32 col_bg2 = ImGui::GetColorU32(ImAlphaBlendColors(IM_COL32(128, 128, 128, 255), col));
+ draw_list->AddRectFilled(p_min, p_max, col_bg1, rounding, rounding_corners_flags);
+
+ int yi = 0;
+ for (float y = p_min.y + grid_off.y; y < p_max.y; y += grid_step, yi++)
+ {
+ float y1 = ImClamp(y, p_min.y, p_max.y), y2 = ImMin(y + grid_step, p_max.y);
+ if (y2 <= y1)
+ continue;
+ for (float x = p_min.x + grid_off.x + (yi & 1) * grid_step; x < p_max.x; x += grid_step * 2.0f)
+ {
+ float x1 = ImClamp(x, p_min.x, p_max.x), x2 = ImMin(x + grid_step, p_max.x);
+ if (x2 <= x1)
+ continue;
+ int rounding_corners_flags_cell = 0;
+ if (y1 <= p_min.y) { if (x1 <= p_min.x) rounding_corners_flags_cell |= ImDrawCornerFlags_TopLeft; if (x2 >= p_max.x) rounding_corners_flags_cell |= ImDrawCornerFlags_TopRight; }
+ if (y2 >= p_max.y) { if (x1 <= p_min.x) rounding_corners_flags_cell |= ImDrawCornerFlags_BotLeft; if (x2 >= p_max.x) rounding_corners_flags_cell |= ImDrawCornerFlags_BotRight; }
+ rounding_corners_flags_cell &= rounding_corners_flags;
+ draw_list->AddRectFilled(ImVec2(x1, y1), ImVec2(x2, y2), col_bg2, rounding_corners_flags_cell ? rounding : 0.0f, rounding_corners_flags_cell);
+ }
+ }
+ }
+ else
+ {
+ draw_list->AddRectFilled(p_min, p_max, col, rounding, rounding_corners_flags);
+ }
}
//-----------------------------------------------------------------------------
@@ -3235,9 +3427,9 @@ static unsigned int stb_adler32(unsigned int adler32, unsigned char *buffer, uns
{
const unsigned long ADLER_MOD = 65521;
unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16;
- unsigned long blocklen, i;
+ unsigned long blocklen = buflen % 5552;
- blocklen = buflen % 5552;
+ unsigned long i;
while (buflen) {
for (i=0; i + 7 < blocklen; i += 8) {
s1 += buffer[0], s2 += s1;
@@ -3264,10 +3456,9 @@ static unsigned int stb_adler32(unsigned int adler32, unsigned char *buffer, uns
static unsigned int stb_decompress(unsigned char *output, const unsigned char *i, unsigned int /*length*/)
{
- unsigned int olen;
if (stb__in4(0) != 0x57bC0000) return 0;
if (stb__in4(4) != 0) return 0; // error! stream is > 4GB
- olen = stb_decompress_length(i);
+ const unsigned int olen = stb_decompress_length(i);
stb__barrier_in_b = i;
stb__barrier_out_e = output + olen;
stb__barrier_out_b = output;
@@ -3399,3 +3590,5 @@ static const char* GetDefaultCompressedFontDataTTFBase85()
{
return proggy_clean_ttf_compressed_data_base85;
}
+
+#endif // #ifndef IMGUI_DISABLE
diff --git a/Sources/CImGui/imgui/imgui_internal.h b/Sources/CImGui/imgui/imgui_internal.h
index 5f31bf1..cef0f9a 100644
--- a/Sources/CImGui/imgui/imgui_internal.h
+++ b/Sources/CImGui/imgui/imgui_internal.h
@@ -1,4 +1,4 @@
-// dear imgui, v1.74 WIP
+// dear imgui, v1.76
// (internal structures/api)
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
@@ -22,6 +22,7 @@ Index of this file:
*/
#pragma once
+#ifndef IMGUI_DISABLE
//-----------------------------------------------------------------------------
// Header mess
@@ -31,7 +32,7 @@ Index of this file:
#error Must include imgui.h before imgui_internal.h
#endif
-#include // FILE*
+#include // FILE*, sscanf
#include // NULL, malloc, free, qsort, atoi, atof
#include // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf
#include // INT_MIN, INT_MAX
@@ -60,10 +61,19 @@ Index of this file:
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
#endif
+// Legacy defines
+#ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Renamed in 1.74
+#error Use IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
+#endif
+#ifdef IMGUI_DISABLE_MATH_FUNCTIONS // Renamed in 1.74
+#error Use IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
+#endif
+
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
+struct ImBitVector; // Store 1-bit per value
struct ImRect; // An axis-aligned rectangle (2 points)
struct ImDrawDataBuilder; // Helper to build a ImDrawData instance
struct ImDrawListSharedData; // Data shared between all ImDrawList instances
@@ -72,14 +82,11 @@ struct ImGuiColumnData; // Storage data for a single column
struct ImGuiColumns; // Storage data for a columns set
struct ImGuiContext; // Main Dear ImGui context
struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum
-struct ImGuiDockContext; // Docking system context
-struct ImGuiDockNode; // Docking system node (hold a list of Windows OR two child dock nodes)
-struct ImGuiDockNodeSettings; // Storage for a dock node in .ini file (we preserve those even if the associated dock node isn't active during the session)
struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup()
struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box
struct ImGuiItemHoveredDataBackup; // Backup and restore IsItemHovered() internal data
struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only
-struct ImGuiNavMoveResult; // Result of a directional navigation move query result
+struct ImGuiNavMoveResult; // Result of a gamepad/keyboard directional navigation move query result
struct ImGuiNextWindowData; // Storage for SetNextWindow** functions
struct ImGuiNextItemData; // Storage for SetNextItem** functions
struct ImGuiPopupData; // Storage for current popup stack
@@ -89,10 +96,9 @@ struct ImGuiTabBar; // Storage for a tab bar
struct ImGuiTabItem; // Storage for a tab item (within a tab bar)
struct ImGuiWindow; // Storage for one window
struct ImGuiWindowTempData; // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame)
-struct ImGuiWindowSettings; // Storage for window settings stored in .ini file (we keep one of those even if the actual window wasn't instanced during this session)
+struct ImGuiWindowSettings; // Storage for a window .ini settings (we keep one of those even if the actual window wasn't instanced during this session)
// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
-typedef int ImGuiDataAuthority; // -> enum ImGuiDataAuthority_ // Enum: for storing the source authority (dock node vs window) of a field
typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical
typedef int ImGuiButtonFlags; // -> enum ImGuiButtonFlags_ // Flags: for ButtonEx(), ButtonBehavior()
typedef int ImGuiColumnsFlags; // -> enum ImGuiColumnsFlags_ // Flags: BeginColumns()
@@ -107,6 +113,7 @@ typedef int ImGuiNextWindowDataFlags; // -> enum ImGuiNextWindowDataFlags_// F
typedef int ImGuiSeparatorFlags; // -> enum ImGuiSeparatorFlags_ // Flags: for SeparatorEx()
typedef int ImGuiSliderFlags; // -> enum ImGuiSliderFlags_ // Flags: for SliderBehavior()
typedef int ImGuiTextFlags; // -> enum ImGuiTextFlags_ // Flags: for TextEx()
+typedef int ImGuiTooltipFlags; // -> enum ImGuiTooltipFlags_ // Flags: for BeginTooltipEx()
//-------------------------------------------------------------------------
// STB libraries includes
@@ -134,33 +141,49 @@ namespace ImStb
extern IMGUI_API ImGuiContext* GImGui; // Current implicit context pointer
#endif
-// Internal Drag and Drop payload types. String starting with '_' are reserved for Dear ImGui.
-#define IMGUI_PAYLOAD_TYPE_WINDOW "_IMWINDOW" // Payload == ImGuiWindow*
-
//-----------------------------------------------------------------------------
-// Generic helpers
+// Macros
//-----------------------------------------------------------------------------
-#define IM_PI 3.14159265358979323846f
+// Debug Logging
+#ifndef IMGUI_DEBUG_LOG
+#define IMGUI_DEBUG_LOG(_FMT,...) printf("[%05d] " _FMT, GImGui->FrameCount, __VA_ARGS__)
+#endif
+
+// Static Asserts
+#if (__cplusplus >= 201100)
+#define IM_STATIC_ASSERT(_COND) static_assert(_COND, "")
+#else
+#define IM_STATIC_ASSERT(_COND) typedef char static_assertion_##__line__[(_COND)?1:-1]
+#endif
+
+// "Paranoid" Debug Asserts are meant to only be enabled during specific debugging/work, otherwise would slow down the code too much.
+// We currently don't have many of those so the effect is currently negligible, but onward intent to add more aggressive ones in the code.
+//#define IMGUI_DEBUG_PARANOID
+#ifdef IMGUI_DEBUG_PARANOID
+#define IM_ASSERT_PARANOID(_EXPR) IM_ASSERT(_EXPR)
+#else
+#define IM_ASSERT_PARANOID(_EXPR)
+#endif
+
+// Error handling
+// Down the line in some frameworks/languages we would like to have a way to redirect those to the programmer and recover from more faults.
+#ifndef IM_ASSERT_USER_ERROR
+#define IM_ASSERT_USER_ERROR(_EXP,_MSG) IM_ASSERT((_EXP) && _MSG) // Recoverable User Error
+#endif
+
+// Misc Macros
+#define IM_PI 3.14159265358979323846f
#ifdef _WIN32
-#define IM_NEWLINE "\r\n" // Play it nice with Windows users (2018/05 news: Microsoft announced that Notepad will finally display Unix-style carriage returns!)
+#define IM_NEWLINE "\r\n" // Play it nice with Windows users (Update: since 2018-05, Notepad finally appears to support Unix-style carriage returns!)
#else
-#define IM_NEWLINE "\n"
+#define IM_NEWLINE "\n"
#endif
-#define IM_TABSIZE (4)
-#define IM_STATIC_ASSERT(_COND) typedef char static_assertion_##__line__[(_COND)?1:-1]
+#define IM_TABSIZE (4)
#define IM_F32_TO_INT8_UNBOUND(_VAL) ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f))) // Unsaturated, for display purpose
#define IM_F32_TO_INT8_SAT(_VAL) ((int)(ImSaturate(_VAL) * 255.0f + 0.5f)) // Saturated, always output 0..255
#define IM_FLOOR(_VAL) ((float)(int)(_VAL)) // ImFloor() is not inlined in MSVC debug builds
-
-// Debug Logging
-#ifndef IMGUI_DEBUG_LOG
-#define IMGUI_DEBUG_LOG(_FMT,...) printf("[%05d] " _FMT, GImGui->FrameCount, __VA_ARGS__)
-#endif
-#define IMGUI_DEBUG_LOG_VIEWPORT(...) ((void)0) // Disable log
-#define IMGUI_DEBUG_LOG_DOCKING(...) ((void)0) // Disable log
-//#define IMGUI_DEBUG_LOG_VIEWPORT IMGUI_DEBUG_LOG // Enable log
-//#define IMGUI_DEBUG_LOG_DOCKING IMGUI_DEBUG_LOG // Enable log
+#define IM_ROUND(_VAL) ((float)(int)((_VAL) + 0.5f)) //
// Enforce cdecl calling convention for functions called by the standard library, in case compilation settings changed the default to e.g. __vectorcall
#ifdef _MSC_VER
@@ -169,36 +192,40 @@ extern IMGUI_API ImGuiContext* GImGui; // Current implicit context pointer
#define IMGUI_CDECL
#endif
-// Helpers: UTF-8 <> wchar
-IMGUI_API int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count
-IMGUI_API int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end); // read one character. return input UTF-8 bytes count
-IMGUI_API int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL); // return input UTF-8 bytes count
-IMGUI_API int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end); // return number of UTF-8 code-points (NOT bytes count)
-IMGUI_API int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end); // return number of bytes to express one char in UTF-8
-IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string in UTF-8
+//-----------------------------------------------------------------------------
+// Generic helpers
+// Note that the ImXXX helpers functions are lower-level than ImGui functions.
+// ImGui functions or the ImGui context are never called/used from other ImXXX functions.
+//-----------------------------------------------------------------------------
+// - Helpers: Misc
+// - Helpers: Bit manipulation
+// - Helpers: String, Formatting
+// - Helpers: UTF-8 <> wchar conversions
+// - Helpers: ImVec2/ImVec4 operators
+// - Helpers: Maths
+// - Helpers: Geometry
+// - Helpers: Bit arrays
+// - Helper: ImBitVector
+// - Helper: ImPool<>
+// - Helper: ImChunkStream<>
+//-----------------------------------------------------------------------------
// Helpers: Misc
+#define ImQsort qsort
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 = 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 FILE* ImFileOpen(const char* filename, const char* file_open_mode);
-static inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; }
-static inline bool ImCharIsBlankW(unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; }
-static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; }
-static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
-#define ImQsort qsort
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
static inline ImU32 ImHash(const void* data, int size, ImU32 seed = 0) { return size ? ImHashData(data, (size_t)size, seed) : ImHashStr((const char*)data, 0, seed); } // [moved to ImHashStr/ImHashData in 1.68]
#endif
-// Helpers: Geometry
-IMGUI_API ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p);
-IMGUI_API bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
-IMGUI_API ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
-IMGUI_API void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w);
-IMGUI_API ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy);
+// Helpers: Color Blending
+IMGUI_API ImU32 ImAlphaBlendColors(ImU32 col_a, ImU32 col_b);
-// Helpers: String
+// Helpers: Bit manipulation
+static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; }
+static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
+
+// Helpers: String, Formatting
IMGUI_API int ImStricmp(const char* str1, const char* str2);
IMGUI_API int ImStrnicmp(const char* str1, const char* str2, size_t count);
IMGUI_API void ImStrncpy(char* dst, const char* src, size_t count);
@@ -217,6 +244,16 @@ IMGUI_API const char* ImParseFormatFindStart(const char* format);
IMGUI_API const char* ImParseFormatFindEnd(const char* format);
IMGUI_API const char* ImParseFormatTrimDecorations(const char* format, char* buf, size_t buf_size);
IMGUI_API int ImParseFormatPrecision(const char* format, int default_value);
+static inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; }
+static inline bool ImCharIsBlankW(unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; }
+
+// Helpers: UTF-8 <> wchar conversions
+IMGUI_API int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count
+IMGUI_API int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end); // read one character. return input UTF-8 bytes count
+IMGUI_API int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL); // return input UTF-8 bytes count
+IMGUI_API int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end); // return number of UTF-8 code-points (NOT bytes count)
+IMGUI_API int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end); // return number of bytes to express one char in UTF-8
+IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string in UTF-8
// Helpers: ImVec2/ImVec4 operators
// We are keeping those disabled by default so they don't leak in user space, to allow user enabling implicit cast operators between ImVec2 and their own types (using IM_VEC2_CLASS_EXTRA etc.)
@@ -228,34 +265,58 @@ static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs)
static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x-rhs.x, lhs.y-rhs.y); }
static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x*rhs.x, lhs.y*rhs.y); }
static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x/rhs.x, lhs.y/rhs.y); }
-static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
-static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
+static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
+static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
+static inline ImVec2& operator*=(ImVec2& lhs, const ImVec2& rhs) { lhs.x *= rhs.x; lhs.y *= rhs.y; return lhs; }
+static inline ImVec2& operator/=(ImVec2& lhs, const ImVec2& rhs) { lhs.x /= rhs.x; lhs.y /= rhs.y; return lhs; }
static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x+rhs.x, lhs.y+rhs.y, lhs.z+rhs.z, lhs.w+rhs.w); }
static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x-rhs.x, lhs.y-rhs.y, lhs.z-rhs.z, lhs.w-rhs.w); }
static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z, lhs.w*rhs.w); }
#endif
+// Helpers: File System
+#ifdef IMGUI_DISABLE_FILE_FUNCTIONS
+#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
+typedef void* ImFileHandle;
+static inline ImFileHandle ImFileOpen(const char*, const char*) { return NULL; }
+static inline bool ImFileClose(ImFileHandle) { return false; }
+static inline ImU64 ImFileGetSize(ImFileHandle) { return (ImU64)-1; }
+static inline ImU64 ImFileRead(void*, ImU64, ImU64, ImFileHandle) { return 0; }
+static inline ImU64 ImFileWrite(const void*, ImU64, ImU64, ImFileHandle) { return 0; }
+#endif
+
+#ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
+typedef FILE* ImFileHandle;
+IMGUI_API ImFileHandle ImFileOpen(const char* filename, const char* mode);
+IMGUI_API bool ImFileClose(ImFileHandle file);
+IMGUI_API ImU64 ImFileGetSize(ImFileHandle file);
+IMGUI_API ImU64 ImFileRead(void* data, ImU64 size, ImU64 count, ImFileHandle file);
+IMGUI_API ImU64 ImFileWrite(const void* data, ImU64 size, ImU64 count, ImFileHandle file);
+#else
+#define IMGUI_DISABLE_TTY_FUNCTIONS // Can't use stdout, fflush if we are not using default file functions
+#endif
+IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_file_size = NULL, int padding_bytes = 0);
+
// Helpers: Maths
// - Wrapper for standard libs functions. (Note that imgui_demo.cpp does _not_ use them to keep the code easy to copy)
-#ifndef IMGUI_DISABLE_MATH_FUNCTIONS
-static inline float ImFabs(float x) { return fabsf(x); }
-static inline float ImSqrt(float x) { return sqrtf(x); }
-static inline float ImPow(float x, float y) { return powf(x, y); }
-static inline double ImPow(double x, double y) { return pow(x, y); }
-static inline float ImFmod(float x, float y) { return fmodf(x, y); }
-static inline double ImFmod(double x, double y) { return fmod(x, y); }
-static inline float ImCos(float x) { return cosf(x); }
-static inline float ImSin(float x) { return sinf(x); }
-static inline float ImAcos(float x) { return acosf(x); }
-static inline float ImAtan2(float y, float x) { return atan2f(y, x); }
-static inline double ImAtof(const char* s) { return atof(s); }
-static inline float ImFloorStd(float x) { return floorf(x); } // we already uses our own ImFloor() { return (float)(int)v } internally so the standard one wrapper is named differently (it's used by stb_truetype)
-static inline float ImCeil(float x) { return ceilf(x); }
+#ifndef IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
+#define ImFabs(X) fabsf(X)
+#define ImSqrt(X) sqrtf(X)
+#define ImFmod(X, Y) fmodf((X), (Y))
+#define ImCos(X) cosf(X)
+#define ImSin(X) sinf(X)
+#define ImAcos(X) acosf(X)
+#define ImAtan2(Y, X) atan2f((Y), (X))
+#define ImAtof(STR) atof(STR)
+#define ImFloorStd(X) floorf(X) // We already uses our own ImFloor() { return (float)(int)v } internally so the standard one wrapper is named differently (it's used by e.g. stb_truetype)
+#define ImCeil(X) ceilf(X)
+static inline float ImPow(float x, float y) { return powf(x, y); } // DragBehaviorT/SliderBehaviorT uses ImPow with either float/double and need the precision
+static inline double ImPow(double x, double y) { return pow(x, y); }
#endif
-// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support for variety of types: signed/unsigned int/long long float/double
-// (Exceptionally using templates here but we could also redefine them for variety of types)
+// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support variety of types: signed/unsigned int/long long float/double
+// (Exceptionally using templates here but we could also redefine them for those types)
template static inline T ImMin(T lhs, T rhs) { return lhs < rhs ? lhs : rhs; }
template static inline T ImMax(T lhs, T rhs) { return lhs >= rhs ? lhs : rhs; }
template static inline T ImClamp(T v, T mn, T mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
@@ -274,49 +335,99 @@ static inline float ImSaturate(float f)
static inline float ImLengthSqr(const ImVec2& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y; }
static inline float ImLengthSqr(const ImVec4& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; }
static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / ImSqrt(d); return fail_value; }
-static inline float ImFloor(float f) { return (float)(int)f; }
-static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)v.x, (float)(int)v.y); }
+static inline float ImFloor(float f) { return (float)(int)(f); }
+static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)(v.x), (float)(int)(v.y)); }
static inline int ImModPositive(int a, int b) { return (a + b) % b; }
static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; }
static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; }
static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
-// Helper: ImBoolVector. Store 1-bit per value.
-// Note that Resize() currently clears the whole vector.
-struct ImBoolVector
+// Helpers: Geometry
+IMGUI_API ImVec2 ImBezierCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, float t); // Cubic Bezier
+IMGUI_API ImVec2 ImBezierClosestPoint(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, int num_segments); // For curves with explicit number of segments
+IMGUI_API ImVec2 ImBezierClosestPointCasteljau(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, float tess_tol);// For auto-tessellated curves you can use tess_tol = style.CurveTessellationTol
+IMGUI_API ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p);
+IMGUI_API bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
+IMGUI_API ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
+IMGUI_API void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w);
+inline float ImTriangleArea(const ImVec2& a, const ImVec2& b, const ImVec2& c) { return ImFabs((a.x * (b.y - c.y)) + (b.x * (c.y - a.y)) + (c.x * (a.y - b.y))) * 0.5f; }
+IMGUI_API ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy);
+
+// Helpers: Bit arrays
+inline bool ImBitArrayTestBit(const ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); return (arr[n >> 5] & mask) != 0; }
+inline void ImBitArrayClearBit(ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); arr[n >> 5] &= ~mask; }
+inline void ImBitArraySetBit(ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); arr[n >> 5] |= mask; }
+inline void ImBitArraySetBitRange(ImU32* arr, int n, int n2)
+{
+ while (n <= n2)
+ {
+ int a_mod = (n & 31);
+ int b_mod = ((n2 >= n + 31) ? 31 : (n2 & 31)) + 1;
+ ImU32 mask = (ImU32)(((ImU64)1 << b_mod) - 1) & ~(ImU32)(((ImU64)1 << a_mod) - 1);
+ arr[n >> 5] |= mask;
+ n = (n + 32) & ~31;
+ }
+}
+
+// Helper: ImBitVector
+// Store 1-bit per value.
+struct IMGUI_API ImBitVector
{
- ImVector Storage;
- ImBoolVector() { }
- void Resize(int sz) { Storage.resize((sz + 31) >> 5); memset(Storage.Data, 0, (size_t)Storage.Size * sizeof(Storage.Data[0])); }
- void Clear() { Storage.clear(); }
- bool GetBit(int n) const { int off = (n >> 5); int mask = 1 << (n & 31); return (Storage[off] & mask) != 0; }
- void SetBit(int n, bool v) { int off = (n >> 5); int mask = 1 << (n & 31); if (v) Storage[off] |= mask; else Storage[off] &= ~mask; }
+ ImVector Storage;
+ void Create(int sz) { Storage.resize((sz + 31) >> 5); memset(Storage.Data, 0, (size_t)Storage.Size * sizeof(Storage.Data[0])); }
+ void Clear() { Storage.clear(); }
+ bool TestBit(int n) const { IM_ASSERT(n < (Storage.Size << 5)); return ImBitArrayTestBit(Storage.Data, n); }
+ void SetBit(int n) { IM_ASSERT(n < (Storage.Size << 5)); ImBitArraySetBit(Storage.Data, n); }
+ void ClearBit(int n) { IM_ASSERT(n < (Storage.Size << 5)); ImBitArrayClearBit(Storage.Data, n); }
};
-// Helper: ImPool<>. Basic keyed storage for contiguous instances, slow/amortized insertion, O(1) indexable, O(Log N) queries by ID over a dense/hot buffer,
+// Helper: ImPool<>
+// Basic keyed storage for contiguous instances, slow/amortized insertion, O(1) indexable, O(Log N) queries by ID over a dense/hot buffer,
// Honor constructor/destructor. Add/remove invalidate all pointers. Indexes have the same lifetime as the associated object.
typedef int ImPoolIdx;
template
struct IMGUI_API ImPool
{
- ImVector Data; // Contiguous data
+ ImVector Buf; // Contiguous data
ImGuiStorage Map; // ID->Index
ImPoolIdx FreeIdx; // Next free idx to use
ImPool() { FreeIdx = 0; }
~ImPool() { Clear(); }
- T* GetByKey(ImGuiID key) { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Data[idx] : NULL; }
- T* GetByIndex(ImPoolIdx n) { return &Data[n]; }
- ImPoolIdx GetIndex(const T* p) const { IM_ASSERT(p >= Data.Data && p < Data.Data + Data.Size); return (ImPoolIdx)(p - Data.Data); }
- T* GetOrAddByKey(ImGuiID key) { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Data[*p_idx]; *p_idx = FreeIdx; return Add(); }
- bool Contains(const T* p) const { return (p >= Data.Data && p < Data.Data + Data.Size); }
- void Clear() { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Data[idx].~T(); } Map.Clear(); Data.clear(); FreeIdx = 0; }
- T* Add() { int idx = FreeIdx; if (idx == Data.Size) { Data.resize(Data.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Data[idx]; } IM_PLACEMENT_NEW(&Data[idx]) T(); return &Data[idx]; }
+ T* GetByKey(ImGuiID key) { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Buf[idx] : NULL; }
+ T* GetByIndex(ImPoolIdx n) { return &Buf[n]; }
+ ImPoolIdx GetIndex(const T* p) const { IM_ASSERT(p >= Buf.Data && p < Buf.Data + Buf.Size); return (ImPoolIdx)(p - Buf.Data); }
+ T* GetOrAddByKey(ImGuiID key) { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Buf[*p_idx]; *p_idx = FreeIdx; return Add(); }
+ bool Contains(const T* p) const { return (p >= Buf.Data && p < Buf.Data + Buf.Size); }
+ void Clear() { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Buf[idx].~T(); } Map.Clear(); Buf.clear(); FreeIdx = 0; }
+ T* Add() { int idx = FreeIdx; if (idx == Buf.Size) { Buf.resize(Buf.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Buf[idx]; } IM_PLACEMENT_NEW(&Buf[idx]) T(); return &Buf[idx]; }
void Remove(ImGuiID key, const T* p) { Remove(key, GetIndex(p)); }
- void Remove(ImGuiID key, ImPoolIdx idx) { Data[idx].~T(); *(int*)&Data[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); }
- void Reserve(int capacity) { Data.reserve(capacity); Map.Data.reserve(capacity); }
- int GetSize() const { return Data.Size; }
+ void Remove(ImGuiID key, ImPoolIdx idx) { Buf[idx].~T(); *(int*)&Buf[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); }
+ void Reserve(int capacity) { Buf.reserve(capacity); Map.Data.reserve(capacity); }
+ int GetSize() const { return Buf.Size; }
+};
+
+// Helper: ImChunkStream<>
+// Build and iterate a contiguous stream of variable-sized structures.
+// This is used by Settings to store persistent data while reducing allocation count.
+// We store the chunk size first, and align the final size on 4 bytes boundaries (this what the '(X + 3) & ~3' statement is for)
+// The tedious/zealous amount of casting is to avoid -Wcast-align warnings.
+template
+struct IMGUI_API ImChunkStream
+{
+ ImVector Buf;
+
+ void clear() { Buf.clear(); }
+ bool empty() const { return Buf.Size == 0; }
+ int size() const { return Buf.Size; }
+ T* alloc_chunk(size_t sz) { size_t HDR_SZ = 4; sz = ((HDR_SZ + sz) + 3u) & ~3u; int off = Buf.Size; Buf.resize(off + (int)sz); ((int*)(void*)(Buf.Data + off))[0] = (int)sz; return (T*)(void*)(Buf.Data + off + (int)HDR_SZ); }
+ T* begin() { size_t HDR_SZ = 4; if (!Buf.Data) return NULL; return (T*)(void*)(Buf.Data + HDR_SZ); }
+ T* next_chunk(T* p) { size_t HDR_SZ = 4; IM_ASSERT(p >= begin() && p < end()); p = (T*)(void*)((char*)(void*)p + chunk_size(p)); if (p == (T*)(void*)((char*)end() + HDR_SZ)) return (T*)0; IM_ASSERT(p < end()); return p; }
+ int chunk_size(const T* p) { return ((const int*)p)[-1]; }
+ T* end() { return (T*)(void*)(Buf.Data + Buf.Size); }
+ int offset_from_ptr(const T* p) { IM_ASSERT(p >= begin() && p < end()); const ptrdiff_t off = (const char*)p - Buf.Data; return (int)off; }
+ T* ptr_from_offset(int off) { IM_ASSERT(off >= 4 && off < Buf.Size); return (T*)(void*)(Buf.Data + off); }
};
//-----------------------------------------------------------------------------
@@ -327,20 +438,30 @@ enum ImGuiButtonFlags_
{
ImGuiButtonFlags_None = 0,
ImGuiButtonFlags_Repeat = 1 << 0, // hold to repeat
- ImGuiButtonFlags_PressedOnClickRelease = 1 << 1, // [Default] return true on click + release on same item
- ImGuiButtonFlags_PressedOnClick = 1 << 2, // return true on click (default requires click+release)
- ImGuiButtonFlags_PressedOnRelease = 1 << 3, // return true on release (default requires click+release)
- ImGuiButtonFlags_PressedOnDoubleClick = 1 << 4, // return true on double-click (default requires click+release)
- ImGuiButtonFlags_FlattenChildren = 1 << 5, // allow interactions even if a child window is overlapping
- ImGuiButtonFlags_AllowItemOverlap = 1 << 6, // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap()
- ImGuiButtonFlags_DontClosePopups = 1 << 7, // disable automatically closing parent popup on press // [UNUSED]
- ImGuiButtonFlags_Disabled = 1 << 8, // disable interactions
- ImGuiButtonFlags_AlignTextBaseLine = 1 << 9, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
- ImGuiButtonFlags_NoKeyModifiers = 1 << 10, // disable interaction if a key modifier is held
- ImGuiButtonFlags_NoHoldingActiveID = 1 << 11, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
- ImGuiButtonFlags_PressedOnDragDropHold = 1 << 12, // press when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers)
- ImGuiButtonFlags_NoNavFocus = 1 << 13, // don't override navigation focus when activated
- ImGuiButtonFlags_NoHoveredOnNav = 1 << 14 // don't report as hovered when navigated on
+ ImGuiButtonFlags_PressedOnClick = 1 << 1, // return true on click (mouse down event)
+ ImGuiButtonFlags_PressedOnClickRelease = 1 << 2, // [Default] return true on click + release on same item <-- this is what the majority of Button are using
+ ImGuiButtonFlags_PressedOnClickReleaseAnywhere = 1 << 3, // return true on click + release even if the release event is not done while hovering the item
+ ImGuiButtonFlags_PressedOnRelease = 1 << 4, // return true on release (default requires click+release)
+ ImGuiButtonFlags_PressedOnDoubleClick = 1 << 5, // return true on double-click (default requires click+release)
+ ImGuiButtonFlags_PressedOnDragDropHold = 1 << 6, // return true when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers)
+ ImGuiButtonFlags_FlattenChildren = 1 << 7, // allow interactions even if a child window is overlapping
+ ImGuiButtonFlags_AllowItemOverlap = 1 << 8, // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap()
+ ImGuiButtonFlags_DontClosePopups = 1 << 9, // disable automatically closing parent popup on press // [UNUSED]
+ ImGuiButtonFlags_Disabled = 1 << 10, // disable interactions
+ ImGuiButtonFlags_AlignTextBaseLine = 1 << 11, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
+ ImGuiButtonFlags_NoKeyModifiers = 1 << 12, // disable mouse interaction if a key modifier is held
+ ImGuiButtonFlags_NoHoldingActiveId = 1 << 13, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
+ ImGuiButtonFlags_NoNavFocus = 1 << 14, // don't override navigation focus when activated
+ ImGuiButtonFlags_NoHoveredOnFocus = 1 << 15, // don't report as hovered when nav focus is on this item
+ ImGuiButtonFlags_MouseButtonLeft = 1 << 16, // [Default] react on left mouse button
+ ImGuiButtonFlags_MouseButtonRight = 1 << 17, // react on right mouse button
+ ImGuiButtonFlags_MouseButtonMiddle = 1 << 18, // react on center mouse button
+
+ ImGuiButtonFlags_MouseButtonMask_ = ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight | ImGuiButtonFlags_MouseButtonMiddle,
+ ImGuiButtonFlags_MouseButtonShift_ = 16,
+ ImGuiButtonFlags_MouseButtonDefault_ = ImGuiButtonFlags_MouseButtonLeft,
+ ImGuiButtonFlags_PressedOnMask_ = ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_PressedOnDragDropHold,
+ ImGuiButtonFlags_PressedOnDefault_ = ImGuiButtonFlags_PressedOnClickRelease
};
enum ImGuiSliderFlags_
@@ -371,9 +492,9 @@ enum ImGuiSelectableFlagsPrivate_
{
// NB: need to be in sync with last value of ImGuiSelectableFlags_
ImGuiSelectableFlags_NoHoldingActiveID = 1 << 20,
- ImGuiSelectableFlags_PressedOnClick = 1 << 21,
- ImGuiSelectableFlags_PressedOnRelease = 1 << 22,
- ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 23, // FIXME: We may be able to remove this (added in 6251d379 for menus)
+ ImGuiSelectableFlags_SelectOnClick = 1 << 21, // Override button behavior to react on Click (default is Click+Release)
+ ImGuiSelectableFlags_SelectOnRelease = 1 << 22, // Override button behavior to react on Release (default is Click+Release)
+ ImGuiSelectableFlags_SpanAvailWidth = 1 << 23, // Span all avail width even if we declared less for layout purpose. FIXME: We may be able to remove this (added in 6251d379, 2bcafc86 for menus)
ImGuiSelectableFlags_DrawHoveredWhenHeld= 1 << 24, // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow.
ImGuiSelectableFlags_SetNavIdOnHover = 1 << 25
};
@@ -415,8 +536,9 @@ enum ImGuiItemStatusFlags_
ImGuiItemStatusFlags_HasDisplayRect = 1 << 1,
ImGuiItemStatusFlags_Edited = 1 << 2, // Value exposed by item was edited in the current frame (should match the bool return value of most widgets)
ImGuiItemStatusFlags_ToggledSelection = 1 << 3, // Set when Selectable(), TreeNode() reports toggling a selection. We can't report "Selected" because reporting the change allows us to handle clipping with less issues.
- ImGuiItemStatusFlags_HasDeactivated = 1 << 4, // Set if the widget/group is able to provide data for the ImGuiItemStatusFlags_Deactivated flag.
- ImGuiItemStatusFlags_Deactivated = 1 << 5 // Only valid if ImGuiItemStatusFlags_HasDeactivated is set.
+ ImGuiItemStatusFlags_ToggledOpen = 1 << 4, // Set when TreeNode() reports toggling their open state.
+ ImGuiItemStatusFlags_HasDeactivated = 1 << 5, // Set if the widget/group is able to provide data for the ImGuiItemStatusFlags_Deactivated flag.
+ ImGuiItemStatusFlags_Deactivated = 1 << 6 // Only valid if ImGuiItemStatusFlags_HasDeactivated is set.
#ifdef IMGUI_ENABLE_TEST_ENGINE
, // [imgui_tests only]
@@ -433,6 +555,12 @@ enum ImGuiTextFlags_
ImGuiTextFlags_NoWidthForLargeClippedText = 1 << 0
};
+enum ImGuiTooltipFlags_
+{
+ ImGuiTooltipFlags_None = 0,
+ ImGuiTooltipFlags_OverridePreviousTooltip = 1 << 0 // Override will clear/ignore previously submitted tooltip (defaults to append)
+};
+
// FIXME: this is in development, not exposed/functional as a generic feature yet.
// Horizontal/Vertical enums are fixed to 0/1 so they may be used to index ImVec2
enum ImGuiLayoutType_
@@ -558,7 +686,7 @@ struct IMGUI_API ImRect
ImVec2 Min; // Upper-left
ImVec2 Max; // Lower-right
- ImRect() : Min(FLT_MAX,FLT_MAX), Max(-FLT_MAX,-FLT_MAX) {}
+ ImRect() : Min(0.0f, 0.0f), Max(0.0f, 0.0f) {}
ImRect(const ImVec2& min, const ImVec2& max) : Min(min), Max(max) {}
ImRect(const ImVec4& v) : Min(v.x, v.y), Max(v.z, v.w) {}
ImRect(float x1, float y1, float x2, float y2) : Min(x1, y1), Max(x2, y2) {}
@@ -636,14 +764,15 @@ struct IMGUI_API ImGuiMenuColumns
ImGuiMenuColumns();
void Update(int count, float spacing, bool clear);
float DeclColumns(float w0, float w1, float w2);
- float CalcExtraSpace(float avail_w);
+ float CalcExtraSpace(float avail_w) const;
};
// Internal state of the currently focused/edited text input box
+// For a given item ID, access with ImGui::GetInputTextState()
struct IMGUI_API ImGuiInputTextState
{
ImGuiID ID; // widget id owning the text state
- int CurLenW, CurLenA; // we need to maintain our buffer length in both UTF-8 and wchar format. UTF-8 len is valid even if TextA is not.
+ int CurLenW, CurLenA; // we need to maintain our buffer length in both UTF-8 and wchar format. UTF-8 length is valid even if TextA is not.
ImVector TextW; // edit buffer, we need to persist but can't guarantee the persistence of the user-provided buffer. so we copy into own buffer.
ImVector TextA; // temporary UTF8 buffer for callbacks and other operations. this is not updated in every code-path! size=capacity.
ImVector InitialTextA; // backup of end-user buffer at the time of focus (in UTF-8, unaltered)
@@ -674,20 +803,17 @@ struct IMGUI_API ImGuiInputTextState
};
// Windows data saved in imgui.ini file
+// Because we never destroy or rename ImGuiWindowSettings, we can store the names in a separate buffer easily.
+// (this is designed to be stored in a ImChunkStream buffer, with the variable-length Name following our structure)
struct ImGuiWindowSettings
{
- char* Name;
ImGuiID ID;
- ImVec2ih Pos; // NB: Settings position are stored RELATIVE to the viewport! Whereas runtime ones are absolute positions.
+ ImVec2ih Pos;
ImVec2ih Size;
- ImVec2ih ViewportPos;
- ImGuiID ViewportId;
- ImGuiID DockId; // ID of last known DockNode (even if the DockNode is invisible because it has only 1 active window), or 0 if none.
- ImGuiID ClassId; // ID of window class if specified
- short DockOrder; // Order of the last time the window was visible within its DockNode. This is used to reorder windows that are reappearing on the same frame. Same value between windows that were active and windows that were none are possible.
bool Collapsed;
- ImGuiWindowSettings() { Name = NULL; ID = 0; Pos = Size = ViewportPos = ImVec2ih(0, 0); ViewportId = DockId = ClassId = 0; DockOrder = -1; Collapsed = false; }
+ ImGuiWindowSettings() { ID = 0; Pos = Size = ImVec2ih(0, 0); Collapsed = false; }
+ char* GetName() { return (char*)(this + 1); }
};
struct ImGuiSettingsHandler
@@ -741,6 +867,7 @@ struct ImGuiColumns
ImRect HostClipRect; // Backup of ClipRect at the time of BeginColumns()
ImRect HostWorkRect; // Backup of WorkRect at the time of BeginColumns()
ImVector Columns;
+ ImDrawListSplitter Splitter;
ImGuiColumns() { Clear(); }
void Clear()
@@ -759,21 +886,34 @@ struct ImGuiColumns
}
};
+// ImDrawList: Helper function to calculate a circle's segment count given its radius and a "maximum error" value.
+#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN 12
+#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX 512
+#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(_RAD,_MAXERROR) ImClamp((int)((IM_PI * 2.0f) / ImAcos(((_RAD) - (_MAXERROR)) / (_RAD))), IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX)
+
+// ImDrawList: You may set this to higher values (e.g. 2 or 3) to increase tessellation of fast rounded corners path.
+#ifndef IM_DRAWLIST_ARCFAST_TESSELLATION_MULTIPLIER
+#define IM_DRAWLIST_ARCFAST_TESSELLATION_MULTIPLIER 1
+#endif
+
// Data shared between all ImDrawList instances
+// You may want to create your own instance of this if you want to use ImDrawList completely without ImGui. In that case, watch out for future changes to this structure.
struct IMGUI_API ImDrawListSharedData
{
ImVec2 TexUvWhitePixel; // UV of white pixel in the atlas
ImFont* Font; // Current/default font (optional, for simplified AddText overload)
float FontSize; // Current/default font size (optional, for simplified AddText overload)
- float CurveTessellationTol;
+ float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo()
+ float CircleSegmentMaxError; // Number of circle segments to use per pixel of radius for AddCircle() etc
ImVec4 ClipRectFullscreen; // Value for PushClipRectFullscreen()
ImDrawListFlags InitialFlags; // Initial flags at the beginning of the frame (it is possible to alter flags on a per-drawlist basis afterwards)
- // Const data
- // FIXME: Bake rounded corners fill/borders in atlas
- ImVec2 CircleVtx12[12];
+ // [Internal] Lookup tables
+ ImVec2 ArcFastVtx[12 * IM_DRAWLIST_ARCFAST_TESSELLATION_MULTIPLIER]; // FIXME: Bake rounded corners fill/borders in atlas
+ ImU8 CircleSegmentCounts[64]; // Precomputed segment count for given radius (array index + 1) before we calculate it dynamically (to avoid calculation overhead)
ImDrawListSharedData();
+ void SetCircleSegmentMaxError(float max_error);
};
struct ImDrawDataBuilder
@@ -785,47 +925,18 @@ struct ImDrawDataBuilder
IMGUI_API void FlattenIntoSingleLayer();
};
-// ImGuiViewport Private/Internals fields (cardinal sin: we are using inheritance!)
-// Note that every instance of ImGuiViewport is in fact a ImGuiViewportP.
-struct ImGuiViewportP : public ImGuiViewport
-{
- int Idx;
- int LastFrameActive; // Last frame number this viewport was activated by a window
- int LastFrameDrawLists[2]; // Last frame number the background (0) and foreground (1) draw lists were used
- int LastFrontMostStampCount; // Last stamp number from when a window hosted by this viewport was made front-most (by comparing this value between two viewport we have an implicit viewport z-order
- ImGuiID LastNameHash;
- ImVec2 LastPos;
- float Alpha; // Window opacity (when dragging dockable windows/viewports we make them transparent)
- float LastAlpha;
- short PlatformMonitor;
- bool PlatformWindowCreated;
- ImGuiWindow* Window; // Set when the viewport is owned by a window (and ImGuiViewportFlags_CanHostOtherWindows is NOT set)
- ImDrawList* DrawLists[2]; // Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays.
- ImDrawData DrawDataP;
- ImDrawDataBuilder DrawDataBuilder;
- ImVec2 LastPlatformPos;
- ImVec2 LastPlatformSize;
- ImVec2 LastRendererSize;
-
- ImGuiViewportP() { Idx = -1; LastFrameActive = LastFrameDrawLists[0] = LastFrameDrawLists[1] = LastFrontMostStampCount = -1; LastNameHash = 0; Alpha = LastAlpha = 1.0f; PlatformMonitor = -1; PlatformWindowCreated = false; Window = NULL; DrawLists[0] = DrawLists[1] = NULL; LastPlatformPos = LastPlatformSize = LastRendererSize = ImVec2(FLT_MAX, FLT_MAX); }
- ~ImGuiViewportP() { if (DrawLists[0]) IM_DELETE(DrawLists[0]); if (DrawLists[1]) IM_DELETE(DrawLists[1]); }
- ImRect GetRect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
- ImVec2 GetCenter() const { return ImVec2(Pos.x + Size.x * 0.5f, Pos.y + Size.y * 0.5f); }
- void ClearRequestFlags() { PlatformRequestClose = PlatformRequestMove = PlatformRequestResize = false; }
-};
-
struct ImGuiNavMoveResult
{
- ImGuiID ID; // Best candidate
- ImGuiID SelectScopeId;// Best candidate window current selectable group ID
- ImGuiWindow* Window; // Best candidate window
- float DistBox; // Best candidate box distance to current NavId
- float DistCenter; // Best candidate center distance to current NavId
- float DistAxial;
- ImRect RectRel; // Best candidate bounding box in window relative space
+ ImGuiWindow* Window; // Best candidate window
+ ImGuiID ID; // Best candidate ID
+ ImGuiID FocusScopeId; // Best candidate focus scope ID
+ float DistBox; // Best candidate box distance to current NavId
+ float DistCenter; // Best candidate center distance to current NavId
+ float DistAxial;
+ ImRect RectRel; // Best candidate bounding box in window relative space
ImGuiNavMoveResult() { Clear(); }
- void Clear() { ID = SelectScopeId = 0; Window = NULL; DistBox = DistCenter = DistAxial = FLT_MAX; RectRel = ImRect(); }
+ void Clear() { Window = NULL; ID = FocusScopeId = 0; DistBox = DistCenter = DistAxial = FLT_MAX; RectRel = ImRect(); }
};
enum ImGuiNextWindowDataFlags_
@@ -837,10 +948,7 @@ enum ImGuiNextWindowDataFlags_
ImGuiNextWindowDataFlags_HasCollapsed = 1 << 3,
ImGuiNextWindowDataFlags_HasSizeConstraint = 1 << 4,
ImGuiNextWindowDataFlags_HasFocus = 1 << 5,
- ImGuiNextWindowDataFlags_HasBgAlpha = 1 << 6,
- ImGuiNextWindowDataFlags_HasViewport = 1 << 7,
- ImGuiNextWindowDataFlags_HasDock = 1 << 8,
- ImGuiNextWindowDataFlags_HasWindowClass = 1 << 9
+ ImGuiNextWindowDataFlags_HasBgAlpha = 1 << 6
};
// Storage for SetNexWindow** functions
@@ -850,20 +958,15 @@ struct ImGuiNextWindowData
ImGuiCond PosCond;
ImGuiCond SizeCond;
ImGuiCond CollapsedCond;
- ImGuiCond DockCond;
ImVec2 PosVal;
ImVec2 PosPivotVal;
ImVec2 SizeVal;
ImVec2 ContentSizeVal;
- bool PosUndock;
bool CollapsedVal;
ImRect SizeConstraintRect;
ImGuiSizeCallback SizeCallback;
void* SizeCallbackUserData;
- float BgAlphaVal;
- ImGuiID ViewportId;
- ImGuiID DockId;
- ImGuiWindowClass WindowClass;
+ float BgAlphaVal; // Override background alpha
ImVec2 MenuBarOffsetMinVal; // *Always on* This is not exposed publicly, so we don't clear it.
ImGuiNextWindowData() { memset(this, 0, sizeof(*this)); }
@@ -880,16 +983,17 @@ enum ImGuiNextItemDataFlags_
struct ImGuiNextItemData
{
ImGuiNextItemDataFlags Flags;
- float Width; // Set by SetNextItemWidth().
- bool OpenVal; // Set by SetNextItemOpen() function.
+ float Width; // Set by SetNextItemWidth()
+ ImGuiID FocusScopeId; // Set by SetNextItemMultiSelectData() (!= 0 signify value has been set, so it's an alternate version of HasSelectionData, we don't use Flags for this because they are cleared too early. This is mostly used for debugging)
ImGuiCond OpenCond;
+ bool OpenVal; // Set by SetNextItemOpen()
ImGuiNextItemData() { memset(this, 0, sizeof(*this)); }
- inline void ClearFlags() { Flags = ImGuiNextItemDataFlags_None; }
+ inline void ClearFlags() { Flags = ImGuiNextItemDataFlags_None; } // Also cleared manually by ItemAdd()!
};
//-----------------------------------------------------------------------------
-// Docking, Tabs
+// Tabs
//-----------------------------------------------------------------------------
struct ImGuiShrinkWidthItem
@@ -907,111 +1011,16 @@ struct ImGuiPtrOrIndex
ImGuiPtrOrIndex(int index) { Ptr = NULL; Index = index; }
};
-// Extend ImGuiDockNodeFlags_
-enum ImGuiDockNodeFlagsPrivate_
-{
- // [Internal]
- ImGuiDockNodeFlags_DockSpace = 1 << 10, // Local, Saved // A dockspace is a node that occupy space within an existing user window. Otherwise the node is floating and create its own window.
- ImGuiDockNodeFlags_CentralNode = 1 << 11, // Local, Saved //
- ImGuiDockNodeFlags_NoTabBar = 1 << 12, // Local, Saved // Tab bar is completely unavailable. No triangle in the corner to enable it back.
- ImGuiDockNodeFlags_HiddenTabBar = 1 << 13, // Local, Saved // Tab bar is hidden, with a triangle in the corner to show it again (NB: actual tab-bar instance may be destroyed as this is only used for single-window tab bar)
- ImGuiDockNodeFlags_NoWindowMenuButton = 1 << 14, // Local, Saved // Disable window/docking menu (that one that appears instead of the collapse button)
- ImGuiDockNodeFlags_NoCloseButton = 1 << 15, // Local, Saved //
- ImGuiDockNodeFlags_NoDocking = 1 << 16, // Local, Saved // Disable any form of docking in this dockspace or individual node. (On a whole dockspace, this pretty much defeat the purpose of using a dockspace at all). Note: when turned on, existing docked nodes will be preserved.
- ImGuiDockNodeFlags_SharedFlagsInheritMask_ = ~0,
- ImGuiDockNodeFlags_LocalFlagsMask_ = ImGuiDockNodeFlags_NoSplit | ImGuiDockNodeFlags_NoResize | ImGuiDockNodeFlags_AutoHideTabBar | ImGuiDockNodeFlags_DockSpace | ImGuiDockNodeFlags_CentralNode | ImGuiDockNodeFlags_NoTabBar | ImGuiDockNodeFlags_HiddenTabBar | ImGuiDockNodeFlags_NoWindowMenuButton | ImGuiDockNodeFlags_NoCloseButton | ImGuiDockNodeFlags_NoDocking,
- ImGuiDockNodeFlags_LocalFlagsTransferMask_ = ImGuiDockNodeFlags_LocalFlagsMask_ & ~ImGuiDockNodeFlags_DockSpace, // When splitting those flags are moved to the inheriting child, never duplicated
- ImGuiDockNodeFlags_SavedFlagsMask_ = ImGuiDockNodeFlags_NoResize | ImGuiDockNodeFlags_DockSpace | ImGuiDockNodeFlags_CentralNode | ImGuiDockNodeFlags_NoTabBar | ImGuiDockNodeFlags_HiddenTabBar | ImGuiDockNodeFlags_NoWindowMenuButton | ImGuiDockNodeFlags_NoCloseButton | ImGuiDockNodeFlags_NoDocking
-};
-
-// Store the source authority (dock node vs window) of a field
-enum ImGuiDataAuthority_
-{
- ImGuiDataAuthority_Auto,
- ImGuiDataAuthority_DockNode,
- ImGuiDataAuthority_Window
-};
-
-enum ImGuiDockNodeState
-{
- ImGuiDockNodeState_Unknown,
- ImGuiDockNodeState_HostWindowHiddenBecauseSingleWindow,
- ImGuiDockNodeState_HostWindowHiddenBecauseWindowsAreResizing,
- ImGuiDockNodeState_HostWindowVisible
-};
-
-// sizeof() 116~160
-struct ImGuiDockNode
-{
- ImGuiID ID;
- ImGuiDockNodeFlags SharedFlags; // Flags shared by all nodes of a same dockspace hierarchy (inherited from the root node)
- ImGuiDockNodeFlags LocalFlags; // Flags specific to this node
- ImGuiDockNode* ParentNode;
- ImGuiDockNode* ChildNodes[2]; // [Split node only] Child nodes (left/right or top/bottom). Consider switching to an array.
- ImVector Windows; // Note: unordered list! Iterate TabBar->Tabs for user-order.
- ImGuiTabBar* TabBar;
- ImVec2 Pos; // Current position
- ImVec2 Size; // Current size
- ImVec2 SizeRef; // [Split node only] Last explicitly written-to size (overridden when using a splitter affecting the node), used to calculate Size.
- int SplitAxis; // [Split node only] Split axis (X or Y)
- ImGuiWindowClass WindowClass;
-
- ImGuiDockNodeState State;
- ImGuiWindow* HostWindow;
- ImGuiWindow* VisibleWindow; // Generally point to window which is ID is == SelectedTabID, but when CTRL+Tabbing this can be a different window.
- ImGuiDockNode* CentralNode; // [Root node only] Pointer to central node.
- ImGuiDockNode* OnlyNodeWithWindows; // [Root node only] Set when there is a single visible node within the hierarchy.
- int LastFrameAlive; // Last frame number the node was updated or kept alive explicitly with DockSpace() + ImGuiDockNodeFlags_KeepAliveOnly
- int LastFrameActive; // Last frame number the node was updated.
- int LastFrameFocused; // Last frame number the node was focused.
- ImGuiID LastFocusedNodeID; // [Root node only] Which of our child docking node (any ancestor in the hierarchy) was last focused.
- ImGuiID SelectedTabID; // [Leaf node only] Which of our tab/window is selected.
- ImGuiID WantCloseTabID; // [Leaf node only] Set when closing a specific tab/window.
- ImGuiDataAuthority AuthorityForPos :3;
- ImGuiDataAuthority AuthorityForSize :3;
- ImGuiDataAuthority AuthorityForViewport :3;
- bool IsVisible :1; // Set to false when the node is hidden (usually disabled as it has no active window)
- bool IsFocused :1;
- bool HasCloseButton :1;
- bool HasWindowMenuButton :1;
- bool EnableCloseButton :1;
- bool WantCloseAll :1; // Set when closing all tabs at once.
- bool WantLockSizeOnce :1;
- bool WantMouseMove :1; // After a node extraction we need to transition toward moving the newly created host window
- bool WantHiddenTabBarUpdate :1;
- bool WantHiddenTabBarToggle :1;
- bool MarkedForPosSizeWrite :1; // Update by DockNodeTreeUpdatePosSize() write-filtering
-
- ImGuiDockNode(ImGuiID id);
- ~ImGuiDockNode();
- bool IsRootNode() const { return ParentNode == NULL; }
- bool IsDockSpace() const { return (LocalFlags & ImGuiDockNodeFlags_DockSpace) != 0; }
- bool IsFloatingNode() const { return ParentNode == NULL && (LocalFlags & ImGuiDockNodeFlags_DockSpace) == 0; }
- bool IsCentralNode() const { return (LocalFlags & ImGuiDockNodeFlags_CentralNode) != 0; }
- bool IsHiddenTabBar() const { return (LocalFlags & ImGuiDockNodeFlags_HiddenTabBar) != 0; } // Hidden tab bar can be shown back by clicking the small triangle
- bool IsNoTabBar() const { return (LocalFlags & ImGuiDockNodeFlags_NoTabBar) != 0; } // Never show a tab bar
- bool IsSplitNode() const { return ChildNodes[0] != NULL; }
- bool IsLeafNode() const { return ChildNodes[0] == NULL; }
- bool IsEmpty() const { return ChildNodes[0] == NULL && Windows.Size == 0; }
- ImGuiDockNodeFlags GetMergedFlags() const { return SharedFlags | LocalFlags; }
- ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
-};
-
//-----------------------------------------------------------------------------
-// Main imgui context
+// Main Dear ImGui context
//-----------------------------------------------------------------------------
struct ImGuiContext
{
bool Initialized;
- bool FrameScopeActive; // Set by NewFrame(), cleared by EndFrame()
- bool FrameScopePushedFallbackWindow; // Set by NewFrame(), cleared by EndFrame()
- bool FontAtlasOwnedByContext; // Io.Fonts-> is owned by the ImGuiContext and will be destructed along with it.
+ bool FontAtlasOwnedByContext; // IO.Fonts-> is owned by the ImGuiContext and will be destructed along with it.
ImGuiIO IO;
- ImGuiPlatformIO PlatformIO;
ImGuiStyle Style;
- ImGuiConfigFlags ConfigFlagsCurrFrame; // = g.IO.ConfigFlags at the time of NewFrame()
- ImGuiConfigFlags ConfigFlagsLastFrame;
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
@@ -1019,22 +1028,23 @@ struct ImGuiContext
double Time;
int FrameCount;
int FrameCountEnded;
- int FrameCountPlatformEnded;
int FrameCountRendered;
+ bool WithinFrameScope; // Set by NewFrame(), cleared by EndFrame()
+ bool WithinFrameScopeWithImplicitWindow; // Set by NewFrame(), cleared by EndFrame() when the implicit debug window has been pushed
+ bool WithinEndChild; // Set within EndChild()
// Windows state
ImVector Windows; // Windows, sorted in display order, back to front
- ImVector WindowsFocusOrder; // Windows, sorted in focus order, back to front
- ImVector WindowsSortBuffer;
+ ImVector WindowsFocusOrder; // Windows, sorted in focus order, back to front. (FIXME: We could only store root windows here! Need to sort out the Docking equivalent which is RootWindowDockStop and is unfortunately a little more dynamic)
+ ImVector WindowsTempSortBuffer; // Temporary buffer used in EndFrame() to reorder windows so parents are kept before their child
ImVector CurrentWindowStack;
- ImGuiStorage WindowsById;
- int WindowsActiveCount;
- ImGuiWindow* CurrentWindow; // Being drawn into
+ ImGuiStorage WindowsById; // Map window's ImGuiID to ImGuiWindow*
+ int WindowsActiveCount; // Number of unique windows submitted by frame
+ ImGuiWindow* CurrentWindow; // Window being drawn into
ImGuiWindow* HoveredWindow; // Will catch mouse inputs
ImGuiWindow* HoveredRootWindow; // Will catch mouse inputs (for focus/move only)
- ImGuiWindow* HoveredWindowUnderMovingWindow; // Hovered window ignoring MovingWindow. Only set if MovingWindow is set.
ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actually window that is moved is generally MovingWindow->RootWindow.
- ImGuiWindow* WheelingWindow;
+ ImGuiWindow* WheelingWindow; // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window.
ImVec2 WheelingWindowRefMousePos;
float WheelingWindowTimer;
@@ -1052,17 +1062,17 @@ struct ImGuiContext
bool ActiveIdHasBeenPressedBefore; // Track whether the active id led to a press (this is to allow changing between PressOnClick and PressOnRelease without pressing twice). Used by range_select branch.
bool ActiveIdHasBeenEditedBefore; // Was the value associated to the widget Edited over the course of the Active state.
bool ActiveIdHasBeenEditedThisFrame;
- ImU32 ActiveIdUsingNavDirMask; // Active widget will want to read those directional navigation requests (e.g. can activate a button and move away from it)
+ ImU32 ActiveIdUsingNavDirMask; // Active widget will want to read those nav move requests (e.g. can activate a button and move away from it)
ImU32 ActiveIdUsingNavInputMask; // Active widget will want to read those nav inputs.
ImU64 ActiveIdUsingKeyInputMask; // Active widget will want to read those key inputs. When we grow the ImGuiKey enum we'll need to either to order the enum to make useful keys come first, either redesign this into e.g. a small array.
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
ImGuiWindow* ActiveIdWindow;
ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
+ int ActiveIdMouseButton;
ImGuiID ActiveIdPreviousFrame;
bool ActiveIdPreviousFrameIsAlive;
bool ActiveIdPreviousFrameHasBeenEditedBefore;
ImGuiWindow* ActiveIdPreviousFrameWindow;
-
ImGuiID LastActiveId; // Store the last non-zero ActiveId, useful for animation.
float LastActiveIdTimer; // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation.
@@ -1077,34 +1087,22 @@ struct ImGuiContext
ImVectorOpenPopupStack; // Which popups are open (persistent)
ImVectorBeginPopupStack; // Which level of BeginPopup() we are in (reset every frame)
- // Viewports
- ImVector Viewports; // Active viewports (always 1+, and generally 1 unless multi-viewports are enabled). Each viewports hold their copy of ImDrawData.
- ImGuiViewportP* CurrentViewport; // We track changes of viewport (happening in Begin) so we can call Platform_OnChangedViewport()
- ImGuiViewportP* MouseViewport;
- ImGuiViewportP* MouseLastHoveredViewport; // Last known viewport that was hovered by mouse (even if we are not hovering any viewport any more) + honoring the _NoInputs flag.
- ImGuiID PlatformLastFocusedViewport; // Record of last focused platform window/viewport, when this changes we stamp the viewport as front-most
- int ViewportFrontMostStampCount; // Every time the front-most window changes, we stamp its viewport with an incrementing counter
-
- // Navigation data (for gamepad/keyboard)
+ // Gamepad/keyboard Navigation
ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusWindow'
ImGuiID NavId; // Focused item for navigation
+ ImGuiID NavFocusScopeId;
ImGuiID NavActivateId; // ~~ (g.ActiveId == 0) && IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0, also set when calling ActivateItem()
ImGuiID NavActivateDownId; // ~~ IsNavInputDown(ImGuiNavInput_Activate) ? NavId : 0
ImGuiID NavActivatePressedId; // ~~ IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0
ImGuiID NavInputId; // ~~ IsNavInputPressed(ImGuiNavInput_Input) ? NavId : 0
ImGuiID NavJustTabbedId; // Just tabbed to this id.
ImGuiID NavJustMovedToId; // Just navigated to this id (result of a successfully MoveRequest).
- ImGuiID NavJustMovedToMultiSelectScopeId; // Just navigated to this select scope id (result of a successfully MoveRequest).
+ ImGuiID NavJustMovedToFocusScopeId; // Just navigated to this focus scope id (result of a successfully MoveRequest).
+ ImGuiKeyModFlags NavJustMovedToKeyMods;
ImGuiID NavNextActivateId; // Set by ActivateItem(), queued until next frame.
ImGuiInputSource NavInputSource; // Keyboard or Gamepad mode? THIS WILL ONLY BE None or NavGamepad or NavKeyboard.
- ImRect NavScoringRectScreen; // Rectangle used for scoring, in screen space. Based of window->DC.NavRefRectRel[], modified for directional navigation scoring.
+ ImRect NavScoringRect; // Rectangle used for scoring, in screen space. Based of window->DC.NavRefRectRel[], modified for directional navigation scoring.
int NavScoringCount; // Metrics for debugging
- ImGuiWindow* NavWindowingTarget; // When selecting a window (holding Menu+FocusPrev/Next, or equivalent of CTRL-TAB) this window is temporarily displayed top-most.
- ImGuiWindow* NavWindowingTargetAnim; // Record of last valid NavWindowingTarget until DimBgRatio and NavWindowingHighlightAlpha becomes 0.0f
- ImGuiWindow* NavWindowingList;
- float NavWindowingTimer;
- float NavWindowingHighlightAlpha;
- bool NavWindowingToggleLayer;
ImGuiNavLayer NavLayer; // Layer we are navigating on. For now the system is hard-coded for 0=main contents and 1=menu/title bar, may expose layers later.
int NavIdTabCounter; // == NavWindow->DC.FocusIdxTabCounter at time of NavId processing
bool NavIdIsAlive; // Nav widget has been seen this frame ~~ NavRefRectRel is valid
@@ -1120,41 +1118,55 @@ struct ImGuiContext
bool NavMoveRequest; // Move request for this frame
ImGuiNavMoveFlags NavMoveRequestFlags;
ImGuiNavForward NavMoveRequestForward; // None / ForwardQueued / ForwardActive (this is used to navigate sibling parent menus from a child menu)
+ ImGuiKeyModFlags NavMoveRequestKeyMods;
ImGuiDir NavMoveDir, NavMoveDirLast; // Direction of the move request (left/right/up/down), direction of the previous move request
ImGuiDir NavMoveClipDir; // FIXME-NAV: Describe the purpose of this better. Might want to rename?
ImGuiNavMoveResult NavMoveResultLocal; // Best move request candidate within NavWindow
ImGuiNavMoveResult NavMoveResultLocalVisibleSet; // Best move request candidate within NavWindow that are mostly visible (when using ImGuiNavMoveFlags_AlsoScoreVisibleSet flag)
ImGuiNavMoveResult NavMoveResultOther; // Best move request candidate within NavWindow's flattened hierarchy (when using ImGuiWindowFlags_NavFlattened flag)
- // Tabbing system (older than Nav, active even if Nav is disabled. FIXME-NAV: This needs a redesign!)
+ // Navigation: Windowing (CTRL+TAB, holding Menu button + directional pads to move/resize)
+ ImGuiWindow* NavWindowingTarget; // When selecting a window (holding Menu+FocusPrev/Next, or equivalent of CTRL-TAB) this window is temporarily displayed top-most.
+ ImGuiWindow* NavWindowingTargetAnim; // Record of last valid NavWindowingTarget until DimBgRatio and NavWindowingHighlightAlpha becomes 0.0f
+ ImGuiWindow* NavWindowingList;
+ float NavWindowingTimer;
+ float NavWindowingHighlightAlpha;
+ bool NavWindowingToggleLayer;
+
+ // Legacy Focus/Tabbing system (older than Nav, active even if Nav is disabled, misnamed. FIXME-NAV: This needs a redesign!)
ImGuiWindow* FocusRequestCurrWindow; //
ImGuiWindow* FocusRequestNextWindow; //
- int FocusRequestCurrCounterAll; // Any item being requested for focus, stored as an index (we on layout to be stable between the frame pressing TAB and the next frame, semi-ouch)
- int FocusRequestCurrCounterTab; // Tab item being requested for focus, stored as an index
- int FocusRequestNextCounterAll; // Stored for next frame
- int FocusRequestNextCounterTab; // "
+ int FocusRequestCurrCounterRegular; // Any item being requested for focus, stored as an index (we on layout to be stable between the frame pressing TAB and the next frame, semi-ouch)
+ int FocusRequestCurrCounterTabStop; // Tab item being requested for focus, stored as an index
+ int FocusRequestNextCounterRegular; // Stored for next frame
+ int FocusRequestNextCounterTabStop; // "
bool FocusTabPressed; //
// Render
+ ImDrawData DrawData; // Main ImDrawData instance to pass render information to the user
+ ImDrawDataBuilder DrawDataBuilder;
float DimBgRatio; // 0.0..1.0 animation when fading in a dimming background (for modal window and CTRL+TAB list)
+ ImDrawList BackgroundDrawList; // First draw list to be rendered.
+ ImDrawList ForegroundDrawList; // Last draw list to be rendered. This is where we the render software mouse cursor (if io.MouseDrawCursor is set) and most debug overlays.
ImGuiMouseCursor MouseCursor;
// Drag and Drop
bool DragDropActive;
- bool DragDropWithinSourceOrTarget;
+ bool DragDropWithinSource; // Set when within a BeginDragDropXXX/EndDragDropXXX block for a drag source.
+ bool DragDropWithinTarget; // Set when within a BeginDragDropXXX/EndDragDropXXX block for a drag target.
ImGuiDragDropFlags DragDropSourceFlags;
int DragDropSourceFrameCount;
int DragDropMouseButton;
ImGuiPayload DragDropPayload;
- ImRect DragDropTargetRect;
+ ImRect DragDropTargetRect; // Store rectangle of current target candidate (we favor small targets when overlapping)
ImGuiID DragDropTargetId;
ImGuiDragDropFlags DragDropAcceptFlags;
float DragDropAcceptIdCurrRectSurface; // Target item surface (we resolve overlapping targets by prioritizing the smaller surface)
ImGuiID DragDropAcceptIdCurr; // Target item id (set at the time of accepting the payload)
ImGuiID DragDropAcceptIdPrev; // Target item id from previous frame (we need to store this to allow for overlapping drag and drop targets)
int DragDropAcceptFrameCount; // Last time a target expressed a desire to accept the source
- ImVector DragDropPayloadBufHeap; // We don't expose the ImVector<> directly
- unsigned char DragDropPayloadBufLocal[8]; // Local buffer for small payloads
+ ImVector DragDropPayloadBufHeap; // We don't expose the ImVector<> directly, ImGuiPayload only holds pointer+size
+ unsigned char DragDropPayloadBufLocal[16]; // Local buffer for small payloads
// Tab bars
ImGuiTabBar* CurrentTabBar;
@@ -1166,42 +1178,35 @@ struct ImGuiContext
ImVec2 LastValidMousePos;
ImGuiInputTextState InputTextState;
ImFont InputTextPasswordFont;
- ImGuiID TempInputTextId; // Temporary text input when CTRL+clicking on a slider, etc.
+ ImGuiID TempInputId; // Temporary text input when CTRL+clicking on a slider, etc.
ImGuiColorEditFlags ColorEditOptions; // Store user options for color edit widgets
- float ColorEditLastHue;
+ float ColorEditLastHue; // Backup of last Hue associated to LastColor[3], so we can restore Hue in lossy RGB<>HSV round trips
+ float ColorEditLastSat; // Backup of last Saturation associated to LastColor[3], so we can restore Saturation in lossy RGB<>HSV round trips
float ColorEditLastColor[3];
- ImVec4 ColorPickerRef;
+ ImVec4 ColorPickerRef; // Initial/reference color at the time of opening the color picker.
bool DragCurrentAccumDirty;
float DragCurrentAccum; // Accumulator for dragging modification. Always high-precision, not rounded by end-user precision settings
float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
float ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage?
int TooltipOverrideCount;
- ImVector PrivateClipboard; // If no custom clipboard handler is defined
-
- // Range-Select/Multi-Select
- // [This is unused in this branch, but left here to facilitate merging/syncing multiple branches]
- ImGuiID MultiSelectScopeId;
+ ImVector ClipboardHandlerData; // If no custom clipboard handler is defined
+ ImVector MenusIdSubmittedThisFrame; // A list of menu IDs that were rendered at least once
// Platform support
ImVec2 PlatformImePos; // Cursor position request & last passed to the OS Input Method Editor
ImVec2 PlatformImeLastPos;
- ImGuiViewportP* PlatformImePosViewport;
-
- // Extensions
- // FIXME: We could provide an API to register one slot in an array held in ImGuiContext?
- ImGuiDockContext* DockContext;
// Settings
- bool SettingsLoaded;
- float SettingsDirtyTimer; // Save .ini Settings to memory when time reaches zero
- ImGuiTextBuffer SettingsIniData; // In memory .ini settings
- ImVector SettingsHandlers; // List of .ini settings handlers
- ImVector SettingsWindows; // ImGuiWindow .ini settings entries (parsed from the last loaded .ini file and maintained on saving)
+ bool SettingsLoaded;
+ float SettingsDirtyTimer; // Save .ini Settings to memory when time reaches zero
+ ImGuiTextBuffer SettingsIniData; // In memory .ini settings
+ ImVector SettingsHandlers; // List of .ini settings handlers
+ ImChunkStream SettingsWindows; // ImGuiWindow .ini settings entries
- // Logging
+ // Capture/Logging
bool LogEnabled;
ImGuiLogType LogType;
- FILE* LogFile; // If != NULL log to stdout/ file
+ ImFileHandle LogFile; // If != NULL log to stdout/ file
ImGuiTextBuffer LogBuffer; // Accumulation buffer when log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators.
float LogLinePosY;
bool LogLineFirstItem;
@@ -1211,7 +1216,7 @@ struct ImGuiContext
// Debug Tools
bool DebugItemPickerActive;
- ImGuiID DebugItemPickerBreakID; // Will call IM_DEBUG_BREAK() when encountering this id
+ ImGuiID DebugItemPickerBreakId; // Will call IM_DEBUG_BREAK() when encountering this id
// Misc
float FramerateSecPerFrame[120]; // Calculate estimate of framerate for user over the last 2 seconds.
@@ -1222,24 +1227,22 @@ struct ImGuiContext
int WantTextInputNextFrame;
char TempBuffer[1024*3+1]; // Temporary text buffer
- ImGuiContext(ImFontAtlas* shared_font_atlas)
+ ImGuiContext(ImFontAtlas* shared_font_atlas) : BackgroundDrawList(&DrawListSharedData), ForegroundDrawList(&DrawListSharedData)
{
Initialized = false;
- FrameScopeActive = FrameScopePushedFallbackWindow = false;
- ConfigFlagsCurrFrame = ConfigFlagsLastFrame = ImGuiConfigFlags_None;
Font = NULL;
FontSize = FontBaseSize = 0.0f;
FontAtlasOwnedByContext = shared_font_atlas ? false : true;
IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
Time = 0.0f;
FrameCount = 0;
- FrameCountEnded = FrameCountPlatformEnded = FrameCountRendered = -1;
+ FrameCountEnded = FrameCountRendered = -1;
+ WithinFrameScope = WithinFrameScopeWithImplicitWindow = WithinEndChild = false;
WindowsActiveCount = 0;
CurrentWindow = NULL;
HoveredWindow = NULL;
HoveredRootWindow = NULL;
- HoveredWindowUnderMovingWindow = NULL;
MovingWindow = NULL;
WheelingWindow = NULL;
WheelingWindowTimer = 0.0f;
@@ -1262,29 +1265,21 @@ struct ImGuiContext
ActiveIdClickOffset = ImVec2(-1,-1);
ActiveIdWindow = NULL;
ActiveIdSource = ImGuiInputSource_None;
-
+ ActiveIdMouseButton = 0;
ActiveIdPreviousFrame = 0;
ActiveIdPreviousFrameIsAlive = false;
ActiveIdPreviousFrameHasBeenEditedBefore = false;
ActiveIdPreviousFrameWindow = NULL;
-
LastActiveId = 0;
LastActiveIdTimer = 0.0f;
- CurrentViewport = NULL;
- MouseViewport = MouseLastHoveredViewport = NULL;
- PlatformLastFocusedViewport = 0;
- ViewportFrontMostStampCount = 0;
-
NavWindow = NULL;
- NavId = NavActivateId = NavActivateDownId = NavActivatePressedId = NavInputId = 0;
- NavJustTabbedId = NavJustMovedToId = NavJustMovedToMultiSelectScopeId = NavNextActivateId = 0;
+ NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = NavInputId = 0;
+ NavJustTabbedId = NavJustMovedToId = NavJustMovedToFocusScopeId = NavNextActivateId = 0;
+ NavJustMovedToKeyMods = ImGuiKeyModFlags_None;
NavInputSource = ImGuiInputSource_None;
- NavScoringRectScreen = ImRect();
+ NavScoringRect = ImRect();
NavScoringCount = 0;
- NavWindowingTarget = NavWindowingTargetAnim = NavWindowingList = NULL;
- NavWindowingTimer = NavWindowingHighlightAlpha = 0.0f;
- NavWindowingToggleLayer = false;
NavLayer = ImGuiNavLayer_Main;
NavIdTabCounter = INT_MAX;
NavIdIsAlive = false;
@@ -1297,24 +1292,31 @@ struct ImGuiContext
NavInitResultId = 0;
NavMoveFromClampedRefRect = false;
NavMoveRequest = false;
- NavMoveRequestFlags = 0;
+ NavMoveRequestFlags = ImGuiNavMoveFlags_None;
NavMoveRequestForward = ImGuiNavForward_None;
+ NavMoveRequestKeyMods = ImGuiKeyModFlags_None;
NavMoveDir = NavMoveDirLast = NavMoveClipDir = ImGuiDir_None;
+ NavWindowingTarget = NavWindowingTargetAnim = NavWindowingList = NULL;
+ NavWindowingTimer = NavWindowingHighlightAlpha = 0.0f;
+ NavWindowingToggleLayer = false;
+
FocusRequestCurrWindow = FocusRequestNextWindow = NULL;
- FocusRequestCurrCounterAll = FocusRequestCurrCounterTab = INT_MAX;
- FocusRequestNextCounterAll = FocusRequestNextCounterTab = INT_MAX;
+ FocusRequestCurrCounterRegular = FocusRequestCurrCounterTabStop = INT_MAX;
+ FocusRequestNextCounterRegular = FocusRequestNextCounterTabStop = INT_MAX;
FocusTabPressed = false;
DimBgRatio = 0.0f;
+ BackgroundDrawList._OwnerName = "##Background"; // Give it a name for debugging
+ ForegroundDrawList._OwnerName = "##Foreground"; // Give it a name for debugging
MouseCursor = ImGuiMouseCursor_Arrow;
- DragDropActive = DragDropWithinSourceOrTarget = false;
- DragDropSourceFlags = 0;
+ DragDropActive = DragDropWithinSource = DragDropWithinTarget = false;
+ DragDropSourceFlags = ImGuiDragDropFlags_None;
DragDropSourceFrameCount = -1;
DragDropMouseButton = -1;
DragDropTargetId = 0;
- DragDropAcceptFlags = 0;
+ DragDropAcceptFlags = ImGuiDragDropFlags_None;
DragDropAcceptIdCurrRectSurface = 0.0f;
DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0;
DragDropAcceptFrameCount = -1;
@@ -1323,9 +1325,9 @@ struct ImGuiContext
CurrentTabBar = NULL;
LastValidMousePos = ImVec2(0.0f, 0.0f);
- TempInputTextId = 0;
+ TempInputId = 0;
ColorEditOptions = ImGuiColorEditFlags__OptionsDefault;
- ColorEditLastHue = 0.0f;
+ ColorEditLastHue = ColorEditLastSat = 0.0f;
ColorEditLastColor[0] = ColorEditLastColor[1] = ColorEditLastColor[2] = FLT_MAX;
DragCurrentAccumDirty = false;
DragCurrentAccum = 0.0f;
@@ -1333,12 +1335,7 @@ struct ImGuiContext
ScrollbarClickDeltaToGrabCenter = 0.0f;
TooltipOverrideCount = 0;
- MultiSelectScopeId = 0;
-
PlatformImePos = PlatformImeLastPos = ImVec2(FLT_MAX, FLT_MAX);
- PlatformImePosViewport = 0;
-
- DockContext = NULL;
SettingsLoaded = false;
SettingsDirtyTimer = 0.0f;
@@ -1352,7 +1349,7 @@ struct ImGuiContext
LogDepthToExpand = LogDepthToExpandDefault = 2;
DebugItemPickerActive = false;
- DebugItemPickerBreakID = 0;
+ DebugItemPickerBreakId = 0;
memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
FramerateSecPerFrameIdx = 0;
@@ -1370,6 +1367,7 @@ struct ImGuiContext
// FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiWindowTempData is quite tenuous and could be reconsidered.
struct IMGUI_API ImGuiWindowTempData
{
+ // Layout
ImVec2 CursorPos; // Current emitting position, in absolute coordinates.
ImVec2 CursorPosPrevLine;
ImVec2 CursorStartPos; // Initial position after Begin(), generally ~ window position + WindowPadding.
@@ -1378,27 +1376,40 @@ struct IMGUI_API ImGuiWindowTempData
ImVec2 PrevLineSize;
float CurrLineTextBaseOffset; // Baseline offset (0.0f by default on a new line, generally == style.FramePadding.y when a framed item has been added).
float PrevLineTextBaseOffset;
- int TreeDepth; // Current tree depth.
- ImU32 TreeMayJumpToParentOnPopMask; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31.. Could be turned into a ImU64 if necessary.
+ ImVec1 Indent; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
+ ImVec1 ColumnsOffset; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
+ ImVec1 GroupOffset;
+
+ // Last item status
ImGuiID LastItemId; // ID for last item
ImGuiItemStatusFlags LastItemStatusFlags; // Status flags for last item (see ImGuiItemStatusFlags_)
ImRect LastItemRect; // Interaction rect for last item
ImRect LastItemDisplayRect; // End-user display rect for last item (only valid if LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect)
+
+ // Keyboard/Gamepad navigation
ImGuiNavLayer NavLayerCurrent; // Current layer, 0..31 (we currently only use 0..1)
int NavLayerCurrentMask; // = (1 << NavLayerCurrent) used by ItemAdd prior to clipping.
int NavLayerActiveMask; // Which layer have been written to (result from previous frame)
int NavLayerActiveMaskNext; // Which layer have been written to (buffer for current frame)
+ ImGuiID NavFocusScopeIdCurrent; // Current focus scope ID while appending
bool NavHideHighlightOneFrame;
bool NavHasScroll; // Set when scrolling can be used (ScrollMax > 0.0f)
+
+ // Miscellaneous
bool MenuBarAppending; // FIXME: Remove this
ImVec2 MenuBarOffset; // MenuBarOffset.x is sort of equivalent of a per-layer CursorPos.x, saved/restored as we switch to the menu bar. The only situation when MenuBarOffset.y is > 0 if when (SafeAreaPadding.y > FramePadding.y), often used on TVs.
+ ImGuiMenuColumns MenuColumns; // Simplified columns storage for menu items measurement
+ int TreeDepth; // Current tree depth.
+ ImU32 TreeJumpToParentOnPopMask; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31.. Could be turned into a ImU64 if necessary.
ImVector ChildWindows;
ImGuiStorage* StateStorage; // Current persistent per-window storage (store e.g. tree node open/close state)
+ ImGuiColumns* CurrentColumns; // Current columns set
ImGuiLayoutType LayoutType;
ImGuiLayoutType ParentLayoutType; // Layout type of parent window at the time of Begin()
- int FocusCounterAll; // Counter for focus/tabbing system. Start at -1 and increase as assigned via FocusableItemRegister() (FIXME-NAV: Needs redesign)
- int FocusCounterTab; // (same, but only count widgets which you can Tab through)
+ int FocusCounterRegular; // (Legacy Focus/Tabbing system) Sequential counter, start at -1 and increase as assigned via FocusableItemRegister() (FIXME-NAV: Needs redesign)
+ int FocusCounterTabStop; // (Legacy Focus/Tabbing system) Same, but only count widgets which you can Tab through.
+ // Local parameters stacks
// 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]
float ItemWidth; // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
@@ -1409,55 +1420,48 @@ struct IMGUI_API ImGuiWindowTempData
ImVectorGroupStack;
short StackSizesBackup[6]; // Store size of various stacks for asserting
- ImVec1 Indent; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
- ImVec1 GroupOffset;
- ImVec1 ColumnsOffset; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
- ImGuiColumns* CurrentColumns; // Current columns set
-
ImGuiWindowTempData()
{
CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos = ImVec2(0.0f, 0.0f);
CurrLineSize = PrevLineSize = ImVec2(0.0f, 0.0f);
CurrLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f;
- TreeDepth = 0;
- TreeMayJumpToParentOnPopMask = 0x00;
+ Indent = ImVec1(0.0f);
+ ColumnsOffset = ImVec1(0.0f);
+ GroupOffset = ImVec1(0.0f);
+
LastItemId = 0;
- LastItemStatusFlags = 0;
+ LastItemStatusFlags = ImGuiItemStatusFlags_None;
LastItemRect = LastItemDisplayRect = ImRect();
+
NavLayerActiveMask = NavLayerActiveMaskNext = 0x00;
NavLayerCurrent = ImGuiNavLayer_Main;
NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
+ NavFocusScopeIdCurrent = 0;
NavHideHighlightOneFrame = false;
NavHasScroll = false;
+
MenuBarAppending = false;
MenuBarOffset = ImVec2(0.0f, 0.0f);
+ TreeDepth = 0;
+ TreeJumpToParentOnPopMask = 0x00;
StateStorage = NULL;
+ CurrentColumns = NULL;
LayoutType = ParentLayoutType = ImGuiLayoutType_Vertical;
- FocusCounterAll = FocusCounterTab = -1;
+ FocusCounterRegular = FocusCounterTabStop = -1;
ItemFlags = ImGuiItemFlags_Default_;
ItemWidth = 0.0f;
TextWrapPos = -1.0f;
memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
-
- Indent = ImVec1(0.0f);
- GroupOffset = ImVec1(0.0f);
- ColumnsOffset = ImVec1(0.0f);
- CurrentColumns = NULL;
}
};
// Storage for one window
struct IMGUI_API ImGuiWindow
{
- char* Name;
+ char* Name; // Window name, owned by the window.
ImGuiID ID; // == ImHashStr(Name)
- ImGuiWindowFlags Flags, FlagsPreviousFrame; // See enum ImGuiWindowFlags_
- ImGuiWindowClass WindowClass; // Advanced users only. Set with SetNextWindowClass()
- ImGuiViewportP* Viewport; // Always set in Begin(), only inactive windows may have a NULL value here
- ImGuiID ViewportId; // We backup the viewport id (since the viewport may disappear or never be created if the window is inactive)
- ImVec2 ViewportPos; // We backup the viewport position (since the viewport may disappear or never be created if the window is inactive)
- int ViewportAllowPlatformMonitorExtend; // Reset to -1 every frame (index is guaranteed to be valid between NewFrame..EndFrame), only used in the Appearing frame of a tooltip/popup to enforce clamping to a given monitor
+ ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_
ImVec2 Pos; // Position (always rounded-up to nearest pixel)
ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
ImVec2 SizeFull; // Size when non collapsed
@@ -1473,9 +1477,8 @@ struct IMGUI_API ImGuiWindow
ImVec2 ScrollMax;
ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change)
ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
- ImVec2 ScrollbarSizes; // Size taken by scrollbars on each axis
+ ImVec2 ScrollbarSizes; // Size taken by each scrollbars on their smaller axis. Pay attention! ScrollbarSizes.x == width of the vertical scrollbar, ScrollbarSizes.y = height of the horizontal scrollbar.
bool ScrollbarX, ScrollbarY; // Are scrollbars visible?
- bool ViewportOwned;
bool Active; // Set to true on Begin(), unless Collapsed
bool WasActive;
bool WriteAccessed; // Set to true when any widget access the current window
@@ -1484,7 +1487,7 @@ struct IMGUI_API ImGuiWindow
bool SkipItems; // Set when items can safely be all clipped (e.g. window not visible or collapsed)
bool Appearing; // Set during the frame where the window is appearing (or re-appearing)
bool Hidden; // Do not display (== (HiddenFrames*** > 0))
- bool IsFallbackWindow;
+ bool IsFallbackWindow; // Set on the "Debug##Default" window.
bool HasCloseButton; // Set when the window has a close button (p_open != NULL)
signed char ResizeBorderHeld; // Current border being held for resize (-1: none, otherwise 0-3)
short BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
@@ -1500,7 +1503,6 @@ struct IMGUI_API ImGuiWindow
ImGuiCond SetWindowPosAllowFlags; // store acceptable condition flags for SetNextWindowPos() use.
ImGuiCond SetWindowSizeAllowFlags; // store acceptable condition flags for SetNextWindowSize() use.
ImGuiCond SetWindowCollapsedAllowFlags; // store acceptable condition flags for SetNextWindowCollapsed() use.
- ImGuiCond SetWindowDockAllowFlags; // store acceptable condition flags for SetNextWindowDock() use.
ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0,0) when positioning from top-left corner; ImVec2(0.5f,0.5f) for centering; ImVec2(1,1) for bottom right.
@@ -1512,27 +1514,22 @@ struct IMGUI_API ImGuiWindow
ImRect OuterRectClipped; // == Window->Rect() just after setup in Begin(). == window->Rect() for root window.
ImRect InnerRect; // Inner rectangle (omit title bar, menu bar, scroll bar)
ImRect InnerClipRect; // == InnerRect shrunk by WindowPadding*0.5f on each side, clipped within viewport or parent clip rect.
- ImRect WorkRect; // Cover the whole scrolling region, shrunk by WindowPadding*1.0f on each side. This is meant to replace ContentsRegionRect over time (from 1.71+ onward).
+ ImRect WorkRect; // Cover the whole scrolling region, shrunk by WindowPadding*1.0f on each side. This is meant to replace ContentRegionRect over time (from 1.71+ onward).
ImRect ClipRect; // Current clipping/scissoring rectangle, evolve as we are using PushClipRect(), etc. == DrawList->clip_rect_stack.back().
- ImRect ContentsRegionRect; // FIXME: This is currently confusing/misleading. It is essentially WorkRect but not handling of scrolling. We currently rely on it as right/bottom aligned sizing operation need some size to rely on.
- ImVec2ih HitTestHoleSize, HitTestHoleOffset;
+ ImRect ContentRegionRect; // FIXME: This is currently confusing/misleading. It is essentially WorkRect but not handling of scrolling. We currently rely on it as right/bottom aligned sizing operation need some size to rely on.
int LastFrameActive; // Last frame number the window was Active.
- int LastFrameJustFocused; // Last frame number the window was made Focused.
float LastTimeActive; // Last timestamp the window was Active (using float as we don't need high precision there)
float ItemWidthDefault;
- ImGuiMenuColumns MenuColumns; // Simplified columns storage for menu items
ImGuiStorage StateStorage;
ImVector ColumnsStorage;
float FontWindowScale; // User scale multiplier per-window, via SetWindowFontScale()
- float FontDpiScale;
- int SettingsIdx; // Index into SettingsWindow[] (indices are always valid as we only grow the array from the back)
+ int SettingsOffset; // Offset into SettingsWindows[] (offsets are always valid as we only grow the array from the back)
ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer)
ImDrawList DrawListInst;
ImGuiWindow* ParentWindow; // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL.
ImGuiWindow* RootWindow; // Point to ourself or first ancestor that is not a child window.
- ImGuiWindow* RootWindowDockStop; // Point to ourself or first ancestor that is not a child window. Doesn't cross through dock nodes. We use this so IsWindowFocused() can behave consistently regardless of docking state.
ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.
ImGuiWindow* RootWindowForNav; // Point to ourself or first ancestor which doesn't have the NavFlattened flag.
@@ -1544,17 +1541,6 @@ struct IMGUI_API ImGuiWindow
int MemoryDrawListIdxCapacity;
int MemoryDrawListVtxCapacity;
- // Docking
- ImGuiDockNode* DockNode; // Which node are we docked into
- ImGuiDockNode* DockNodeAsHost; // Which node are we owning (for parent windows)
- ImGuiID DockId; // Backup of last valid DockNode->Id, so single value remember their dock node id
- ImGuiItemStatusFlags DockTabItemStatusFlags;
- ImRect DockTabItemRect;
- short DockOrder; // Order of the last time the window was visible within its DockNode. This is used to reorder windows that are reappearing on the same frame. Same value between windows that were active and windows that were none are possible.
- bool DockIsActive :1; // =~ (DockNode != NULL) && (DockNode->Windows.Size > 1)
- bool DockTabIsVisible :1; // Is the window visible this frame? =~ is the corresponding tab selected?
- bool DockTabWantClose :1;
-
public:
ImGuiWindow(ImGuiContext* context, const char* name);
~ImGuiWindow();
@@ -1569,7 +1555,7 @@ struct IMGUI_API ImGuiWindow
// We don't use g.FontSize because the window may be != g.CurrentWidow.
ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x+Size.x, Pos.y+Size.y); }
- float CalcFontSize() const { ImGuiContext& g = *GImGui; float scale = g.FontBaseSize * FontWindowScale * FontDpiScale; if (ParentWindow) scale *= ParentWindow->FontWindowScale; return scale; }
+ float CalcFontSize() const { ImGuiContext& g = *GImGui; float scale = g.FontBaseSize * FontWindowScale; if (ParentWindow) scale *= ParentWindow->FontWindowScale; return scale; }
float TitleBarHeight() const { ImGuiContext& g = *GImGui; return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + g.Style.FramePadding.y * 2.0f; }
ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); }
float MenuBarHeight() const { ImGuiContext& g = *GImGui; return (Flags & ImGuiWindowFlags_MenuBar) ? DC.MenuBarOffset.y + CalcFontSize() + g.Style.FramePadding.y * 2.0f : 0.0f; }
@@ -1604,25 +1590,22 @@ enum ImGuiTabBarFlagsPrivate_
// Extend ImGuiTabItemFlags_
enum ImGuiTabItemFlagsPrivate_
{
- ImGuiTabItemFlags_NoCloseButton = 1 << 20, // Store whether p_open is set or not, which we need to recompute WidthContents during layout.
- ImGuiTabItemFlags_Unsorted = 1 << 21, // [Docking] Trailing tabs with the _Unsorted flag will be sorted based on the DockOrder of their Window.
- ImGuiTabItemFlags_Preview = 1 << 22 // [Docking] Display tab shape for docking preview (height is adjusted slightly to compensate for the yet missing tab bar)
+ ImGuiTabItemFlags_NoCloseButton = 1 << 20 // Track whether p_open was set or not (we'll need this info on the next frame to recompute ContentWidth during layout)
};
-// Storage for one active tab item (sizeof() 32~40 bytes)
+// Storage for one active tab item (sizeof() 26~32 bytes)
struct ImGuiTabItem
{
ImGuiID ID;
ImGuiTabItemFlags Flags;
- ImGuiWindow* Window; // When TabItem is part of a DockNode's TabBar, we hold on to a window.
int LastFrameVisible;
int LastFrameSelected; // This allows us to infer an ordered list of the last activated tabs with little maintenance
int NameOffset; // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames
float Offset; // Position relative to beginning of tab
float Width; // Width currently displayed
- float WidthContents; // Width of actual contents, stored during BeginTabItem() call
+ float ContentWidth; // Width of actual contents, stored during BeginTabItem() call
- ImGuiTabItem() { ID = Flags = 0; Window = NULL; LastFrameVisible = LastFrameSelected = -1; NameOffset = -1; Offset = Width = WidthContents = 0.0f; }
+ ImGuiTabItem() { ID = 0; Flags = ImGuiTabItemFlags_None; LastFrameVisible = LastFrameSelected = -1; NameOffset = -1; Offset = Width = ContentWidth = 0.0f; }
};
// Storage for a tab bar (sizeof() 92~96 bytes)
@@ -1657,8 +1640,6 @@ struct ImGuiTabBar
int GetTabOrder(const ImGuiTabItem* tab) const { return Tabs.index_from_ptr(tab); }
const char* GetTabName(const ImGuiTabItem* tab) const
{
- if (tab->Window)
- return tab->Window->Name;
IM_ASSERT(tab->NameOffset != -1 && tab->NameOffset < TabsNames.Buf.Size);
return TabsNames.Buf.Data + tab->NameOffset;
}
@@ -1671,6 +1652,7 @@ struct ImGuiTabBar
namespace ImGui
{
+ // Windows
// We should always have a CurrentWindow in the stack (there is an implicit "Debug" window)
// If this ever crash because g.CurrentWindow is NULL it means that either
// - ImGui::NewFrame() has never been called, which is illegal.
@@ -1679,11 +1661,6 @@ namespace ImGui
inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; }
IMGUI_API ImGuiWindow* FindWindowByID(ImGuiID id);
IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
- IMGUI_API void FocusWindow(ImGuiWindow* window);
- IMGUI_API void FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window);
- IMGUI_API void BringWindowToFocusFront(ImGuiWindow* window);
- IMGUI_API void BringWindowToDisplayFront(ImGuiWindow* window);
- IMGUI_API void BringWindowToDisplayBack(ImGuiWindow* window);
IMGUI_API void UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window);
IMGUI_API ImVec2 CalcWindowExpectedSize(ImGuiWindow* window);
IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
@@ -1692,12 +1669,18 @@ namespace ImGui
IMGUI_API void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond = 0);
IMGUI_API void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond = 0);
IMGUI_API void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond = 0);
- IMGUI_API void GcCompactTransientWindowBuffers(ImGuiWindow* window);
- IMGUI_API void GcAwakeTransientWindowBuffers(ImGuiWindow* window);
+ // Windows: Display Order and Focus Order
+ IMGUI_API void FocusWindow(ImGuiWindow* window);
+ IMGUI_API void FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window);
+ IMGUI_API void BringWindowToFocusFront(ImGuiWindow* window);
+ IMGUI_API void BringWindowToDisplayFront(ImGuiWindow* window);
+ IMGUI_API void BringWindowToDisplayBack(ImGuiWindow* window);
+
+ // Fonts, drawing
IMGUI_API void SetCurrentFont(ImFont* font);
inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; }
- inline ImDrawList* GetForegroundDrawList(ImGuiWindow* window) { return GetForegroundDrawList(window->Viewport); }
+ inline ImDrawList* GetForegroundDrawList(ImGuiWindow* window) { IM_UNUSED(window); ImGuiContext& g = *GImGui; return &g.ForegroundDrawList; } // This seemingly unnecessary wrapper simplifies compatibility between the 'master' and 'docking' branches.
// Init
IMGUI_API void Initialize(ImGuiContext* context);
@@ -1706,16 +1689,9 @@ namespace ImGui
// NewFrame
IMGUI_API void UpdateHoveredWindowAndCaptureFlags();
IMGUI_API void StartMouseMovingWindow(ImGuiWindow* window);
- IMGUI_API void StartMouseDragFromTitleBar(ImGuiWindow* window, ImGuiDockNode* node, bool from_collapse_button);
IMGUI_API void UpdateMouseMovingWindowNewFrame();
IMGUI_API void UpdateMouseMovingWindowEndFrame();
- // Viewports
- IMGUI_API void TranslateWindowsInViewport(ImGuiViewportP* viewport, const ImVec2& old_pos, const ImVec2& new_pos);
- IMGUI_API void ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale);
- IMGUI_API void DestroyPlatformWindow(ImGuiViewportP* viewport);
- IMGUI_API void ShowViewportThumbnails();
-
// Settings
IMGUI_API void MarkIniSettingsDirty();
IMGUI_API void MarkIniSettingsDirty(ImGuiWindow* window);
@@ -1733,6 +1709,7 @@ namespace ImGui
// Basic Accessors
inline ImGuiID GetItemID() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.LastItemId; }
+ inline ImGuiItemStatusFlags GetItemStatusFlags() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.LastItemStatusFlags; }
inline ImGuiID GetActiveID() { ImGuiContext& g = *GImGui; return g.ActiveId; }
inline ImGuiID GetFocusID() { ImGuiContext& g = *GImGui; return g.NavId; }
IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);
@@ -1741,12 +1718,12 @@ namespace ImGui
IMGUI_API ImGuiID GetHoveredID();
IMGUI_API void SetHoveredID(ImGuiID id);
IMGUI_API void KeepAliveID(ImGuiID id);
- IMGUI_API void MarkItemEdited(ImGuiID id);
- IMGUI_API void PushOverrideID(ImGuiID id);
+ IMGUI_API void MarkItemEdited(ImGuiID id); // Mark data associated to given item as "edited", used by IsItemDeactivatedAfterEdit() function.
+ IMGUI_API void PushOverrideID(ImGuiID id); // Push given value at the top of the ID stack (whereas PushID combines old and new hashes)
// Basic Helpers for widget code
- IMGUI_API void ItemSize(const ImVec2& size, float text_baseline_y = 0.0f);
- IMGUI_API void ItemSize(const ImRect& bb, float text_baseline_y = 0.0f);
+ IMGUI_API void ItemSize(const ImVec2& size, float text_baseline_y = -1.0f);
+ IMGUI_API void ItemSize(const ImRect& bb, float text_baseline_y = -1.0f);
IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL);
IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id);
IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
@@ -1766,12 +1743,13 @@ namespace ImGui
IMGUI_API void LogToBuffer(int auto_open_depth = -1); // Start logging/capturing to internal buffer
// Popups, Modals, Tooltips
+ IMGUI_API bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags);
IMGUI_API void OpenPopupEx(ImGuiID id);
IMGUI_API void ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup);
IMGUI_API void ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup);
IMGUI_API bool IsPopupOpen(ImGuiID id); // Test for id within current popup stack level (currently begin-ed into); this doesn't scan the whole popup stack!
IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
- IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip = true);
+ IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags);
IMGUI_API ImGuiWindow* GetTopMostPopupModal();
IMGUI_API ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window);
IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy = ImGuiPopupPositionPolicy_Default);
@@ -1786,67 +1764,31 @@ namespace ImGui
IMGUI_API ImVec2 GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor = 0.0f, float fast_factor = 0.0f);
IMGUI_API int CalcTypematicRepeatAmount(float t0, float t1, float repeat_delay, float repeat_rate);
IMGUI_API void ActivateItem(ImGuiID id); // Remotely activate a button, checkbox, tree node etc. given its unique ID. activation is queued and processed on the next frame when the item is encountered again.
- IMGUI_API void SetNavID(ImGuiID id, int nav_layer);
- IMGUI_API void SetNavIDWithRectRel(ImGuiID id, int nav_layer, const ImRect& rect_rel);
+ IMGUI_API void SetNavID(ImGuiID id, int nav_layer, ImGuiID focus_scope_id);
+ IMGUI_API void SetNavIDWithRectRel(ImGuiID id, int nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel);
+
+ // Focus scope (WIP)
+ IMGUI_API void PushFocusScope(ImGuiID id); // Note: this is storing in same stack as IDStack, so Push/Pop mismatch will be reported there.
+ IMGUI_API void PopFocusScope();
+ inline ImGuiID GetFocusScopeID() { ImGuiContext& g = *GImGui; return g.NavFocusScopeId; }
// Inputs
// FIXME: Eventually we should aim to move e.g. IsActiveIdUsingKey() into IsKeyXXX functions.
inline bool IsActiveIdUsingNavDir(ImGuiDir dir) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavDirMask & (1 << dir)) != 0; }
inline bool IsActiveIdUsingNavInput(ImGuiNavInput input) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavInputMask & (1 << input)) != 0; }
inline bool IsActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; IM_ASSERT(key < 64); return (g.ActiveIdUsingKeyInputMask & ((ImU64)1 << key)) != 0; }
- IMGUI_API bool IsMouseDragPastThreshold(int button, float lock_threshold = -1.0f);
+ IMGUI_API bool IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold = -1.0f);
inline bool IsKeyPressedMap(ImGuiKey key, bool repeat = true) { ImGuiContext& g = *GImGui; const int key_index = g.IO.KeyMap[key]; return (key_index >= 0) ? IsKeyPressed(key_index, repeat) : false; }
inline bool IsNavInputDown(ImGuiNavInput n) { ImGuiContext& g = *GImGui; return g.IO.NavInputs[n] > 0.0f; }
- inline bool IsNavInputPressed(ImGuiNavInput n, ImGuiInputReadMode mode) { return GetNavInputAmount(n, mode) > 0.0f; }
- inline bool IsNavInputPressedAnyOfTwo(ImGuiNavInput n1, ImGuiNavInput n2, ImGuiInputReadMode mode) { return (GetNavInputAmount(n1, mode) + GetNavInputAmount(n2, mode)) > 0.0f; }
-
- // Docking
- // (some functions are only declared in imgui.cpp, see Docking section)
- IMGUI_API void DockContextInitialize(ImGuiContext* ctx);
- IMGUI_API void DockContextShutdown(ImGuiContext* ctx);
- IMGUI_API void DockContextOnLoadSettings(ImGuiContext* ctx);
- IMGUI_API void DockContextRebuildNodes(ImGuiContext* ctx);
- IMGUI_API void DockContextUpdateUndocking(ImGuiContext* ctx);
- IMGUI_API void DockContextUpdateDocking(ImGuiContext* ctx);
- IMGUI_API ImGuiID DockContextGenNodeID(ImGuiContext* ctx);
- IMGUI_API void DockContextQueueDock(ImGuiContext* ctx, ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload, ImGuiDir split_dir, float split_ratio, bool split_outer);
- IMGUI_API void DockContextQueueUndockWindow(ImGuiContext* ctx, ImGuiWindow* window);
- IMGUI_API void DockContextQueueUndockNode(ImGuiContext* ctx, ImGuiDockNode* node);
- IMGUI_API bool DockContextCalcDropPosForDocking(ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload, ImGuiDir split_dir, bool split_outer, ImVec2* out_pos);
- inline ImGuiDockNode* DockNodeGetRootNode(ImGuiDockNode* node) { while (node->ParentNode) node = node->ParentNode; return node; }
- IMGUI_API bool GetWindowAlwaysWantOwnTabBar(ImGuiWindow* window);
- IMGUI_API void BeginDocked(ImGuiWindow* window, bool* p_open);
- IMGUI_API void BeginAsDockableDragDropSource(ImGuiWindow* window);
- IMGUI_API void BeginAsDockableDragDropTarget(ImGuiWindow* window);
- IMGUI_API void SetWindowDock(ImGuiWindow* window, ImGuiID dock_id, ImGuiCond cond);
-
- // Docking - Builder function needs to be generally called before the DockSpace() node is submitted.
- // - The DockBuilderXXX functions are designed to _eventually_ become a public API, but it is too early to expose it and guarantee stability.
- // - You can create dockspace _or_ floating nodes with this API. To create a dockspace node, make sure to set the ImGuiDockNodeFlags_DockSpace flag.
- // - If you intend to split the node immediately after creation using DockBuilderSplitNode(), make sure to call DockBuilderSetNodeSize() beforehand.
- // - Call DockBuilderFinish() after you are done.
- // - Important: do not hold on ImGuiDockNode* pointers! They may be invalidated by any split/merge/remove operation and every frame.
- IMGUI_API void DockBuilderDockWindow(const char* window_name, ImGuiID node_id);
- IMGUI_API ImGuiDockNode*DockBuilderGetNode(ImGuiID node_id);
- inline ImGuiDockNode* DockBuilderGetCentralNode(ImGuiID node_id) { ImGuiDockNode* node = DockBuilderGetNode(node_id); if (!node) return NULL; return DockNodeGetRootNode(node)->CentralNode; }
- IMGUI_API ImGuiID DockBuilderAddNode(ImGuiID node_id = 0, ImGuiDockNodeFlags flags = 0);
- IMGUI_API void DockBuilderRemoveNode(ImGuiID node_id); // Remove node and all its child, undock all windows
- IMGUI_API void DockBuilderRemoveNodeDockedWindows(ImGuiID node_id, bool clear_persistent_docking_references = true);
- IMGUI_API void DockBuilderRemoveNodeChildNodes(ImGuiID node_id); // Remove all split/hierarchy. All remaining docked windows will be re-docked to the root.
- IMGUI_API void DockBuilderSetNodePos(ImGuiID node_id, ImVec2 pos);
- IMGUI_API void DockBuilderSetNodeSize(ImGuiID node_id, ImVec2 size);
- IMGUI_API ImGuiID DockBuilderSplitNode(ImGuiID node_id, ImGuiDir split_dir, float size_ratio_for_node_at_dir, ImGuiID* out_id_at_dir, ImGuiID* out_id_at_opposite_dir);
- IMGUI_API void DockBuilderCopyDockSpace(ImGuiID src_dockspace_id, ImGuiID dst_dockspace_id, ImVector* in_window_remap_pairs);
- IMGUI_API void DockBuilderCopyNode(ImGuiID src_node_id, ImGuiID dst_node_id, ImVector* out_node_remap_pairs);
- IMGUI_API void DockBuilderCopyWindowSettings(const char* src_name, const char* dst_name);
- IMGUI_API void DockBuilderFinish(ImGuiID node_id);
+ inline bool IsNavInputTest(ImGuiNavInput n, ImGuiInputReadMode rm) { return (GetNavInputAmount(n, rm) > 0.0f); }
+ IMGUI_API ImGuiKeyModFlags GetMergedKeyModFlags();
// Drag and Drop
IMGUI_API bool BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id);
IMGUI_API void ClearDragDrop();
IMGUI_API bool IsDragDropPayloadBeingAccepted();
- // New Columns API (FIXME-WIP)
+ // Internal Columns API (this is not exposed because we will encourage transitioning to the Tables api)
IMGUI_API void BeginColumns(const char* str_id, int count, ImGuiColumnsFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns().
IMGUI_API void EndColumns(); // close columns
IMGUI_API void PushColumnClipRect(int column_index);
@@ -1858,14 +1800,12 @@ namespace ImGui
IMGUI_API float GetColumnNormFromOffset(const ImGuiColumns* columns, float offset);
// Tab Bars
- IMGUI_API bool BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& bb, ImGuiTabBarFlags flags, ImGuiDockNode* dock_node);
+ IMGUI_API bool BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& bb, ImGuiTabBarFlags flags);
IMGUI_API ImGuiTabItem* TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id);
- IMGUI_API ImGuiTabItem* TabBarFindMostRecentlySelectedTabForActiveWindow(ImGuiTabBar* tab_bar);
- IMGUI_API void TabBarAddTab(ImGuiTabBar* tab_bar, ImGuiTabItemFlags tab_flags, ImGuiWindow* window);
IMGUI_API void TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id);
IMGUI_API void TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
IMGUI_API void TabBarQueueChangeTabOrder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int dir);
- IMGUI_API bool TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags, ImGuiWindow* docked_window);
+ IMGUI_API bool TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags);
IMGUI_API ImVec2 TabItemCalcSize(const char* label, bool has_close_button);
IMGUI_API void TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col);
IMGUI_API bool TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id);
@@ -1880,21 +1820,18 @@ namespace ImGui
IMGUI_API void RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, const char* text, const char* text_end, const ImVec2* text_size_if_known);
IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
IMGUI_API void RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f);
- IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, int rounding_corners_flags = ~0);
- IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col, float sz);
+ IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list, ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, int rounding_corners_flags = ~0);
IMGUI_API void RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags = ImGuiNavHighlightFlags_TypeDefault); // Navigation highlight
- IMGUI_API void RenderMouseCursor(ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor = ImGuiMouseCursor_Arrow);
IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
IMGUI_API void LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end = NULL);
// Render helpers (those functions don't access any ImGui state!)
IMGUI_API void RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir dir, float scale = 1.0f);
IMGUI_API void RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col);
+ IMGUI_API void RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz);
IMGUI_API void RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow);
IMGUI_API void RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col);
- IMGUI_API void RenderArrowDockMenu(ImDrawList* draw_list, ImVec2 p_min, float sz, ImU32 col);
IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
- IMGUI_API void RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect inner, ImU32 col, float rounding);
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
// [1.71: 2019/06/07: Updating prototypes of some of the internal functions. Leaving those for reference for a short while]
@@ -1906,11 +1843,13 @@ namespace ImGui
IMGUI_API void TextEx(const char* text, const char* text_end = NULL, ImGuiTextFlags flags = 0);
IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0,0), ImGuiButtonFlags flags = 0);
IMGUI_API bool CloseButton(ImGuiID id, const ImVec2& pos);
- IMGUI_API bool CollapseButton(ImGuiID id, const ImVec2& pos, ImGuiDockNode* dock_node);
- IMGUI_API bool ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags);
+ IMGUI_API bool CollapseButton(ImGuiID id, const ImVec2& pos);
+ IMGUI_API bool ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags = 0);
IMGUI_API void Scrollbar(ImGuiAxis axis);
IMGUI_API bool ScrollbarEx(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* p_scroll_v, float avail_v, float contents_v, ImDrawCornerFlags rounding_corners);
- IMGUI_API ImGuiID GetScrollbarID(ImGuiWindow* window, ImGuiAxis axis);
+ IMGUI_API ImRect GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis);
+ IMGUI_API ImGuiID GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis);
+ IMGUI_API ImGuiID GetWindowResizeID(ImGuiWindow* window, int n); // 0..3: corners, 4..7: borders
IMGUI_API void SeparatorEx(ImGuiSeparatorFlags flags);
// Widgets low-level behaviors
@@ -1938,8 +1877,10 @@ namespace ImGui
// InputText
IMGUI_API bool InputTextEx(const char* label, const char* hint, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
- IMGUI_API bool TempInputTextScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format);
- inline bool TempInputTextIsActive(ImGuiID id) { ImGuiContext& g = *GImGui; return (g.ActiveId == id && g.TempInputTextId == id); }
+ IMGUI_API bool TempInputText(const ImRect& bb, ImGuiID id, const char* label, char* buf, int buf_size, ImGuiInputTextFlags flags);
+ IMGUI_API bool TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format);
+ inline bool TempInputIsActive(ImGuiID id) { ImGuiContext& g = *GImGui; return (g.ActiveId == id && g.TempInputId == id); }
+ inline ImGuiInputTextState* GetInputTextState(ImGuiID id) { ImGuiContext& g = *GImGui; return (g.InputTextState.ID == id) ? &g.InputTextState : NULL; } // Get input text state if active
// Color
IMGUI_API void ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags);
@@ -1947,12 +1888,16 @@ namespace ImGui
IMGUI_API void ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags);
// Plot
- IMGUI_API void PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size);
+ IMGUI_API int PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size);
// Shade functions (write over already created vertices)
IMGUI_API void ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1);
IMGUI_API void ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp);
+ // Garbage collection
+ IMGUI_API void GcCompactTransientWindowBuffers(ImGuiWindow* window);
+ IMGUI_API void GcAwakeTransientWindowBuffers(ImGuiWindow* window);
+
// Debug Tools
inline void DebugDrawItemRect(ImU32 col = IM_COL32(255,0,0,255)) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; GetForegroundDrawList(window)->AddRect(window->DC.LastItemRect.Min, window->DC.LastItemRect.Max, col); }
inline void DebugStartItemPicker() { ImGuiContext& g = *GImGui; g.DebugItemPickerActive = true; }
@@ -1961,7 +1906,7 @@ namespace ImGui
// ImFontAtlas internals
IMGUI_API bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas);
-IMGUI_API void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas);
+IMGUI_API void ImFontAtlasBuildInit(ImFontAtlas* atlas);
IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque);
IMGUI_API void ImFontAtlasBuildFinish(ImFontAtlas* atlas);
@@ -2006,3 +1951,5 @@ extern void ImGuiTestEngineHook_Log(ImGuiContext* ctx, const cha
#ifdef _MSC_VER
#pragma warning (pop)
#endif
+
+#endif // #ifndef IMGUI_DISABLE
diff --git a/Sources/CImGui/imgui/imgui_widgets.cpp b/Sources/CImGui/imgui/imgui_widgets.cpp
index 71e2986..27d9e45 100644
--- a/Sources/CImGui/imgui/imgui_widgets.cpp
+++ b/Sources/CImGui/imgui/imgui_widgets.cpp
@@ -1,4 +1,4 @@
-// dear imgui, v1.74 WIP
+// dear imgui, v1.76
// (widgets code)
/*
@@ -33,6 +33,8 @@ Index of this file:
#endif
#include "imgui.h"
+#ifndef IMGUI_DISABLE
+
#ifndef IMGUI_DEFINE_MATH_OPERATORS
#define IMGUI_DEFINE_MATH_OPERATORS
#endif
@@ -47,8 +49,11 @@ Index of this file:
// Visual Studio warnings
#ifdef _MSC_VER
-#pragma warning (disable: 4127) // condition expression is constant
-#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
+#pragma warning (disable: 4127) // condition expression is constant
+#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
+#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later
+#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types
+#endif
#endif
// Clang/GCC warnings with -Weverything
@@ -63,6 +68,9 @@ Index of this file:
#if __has_warning("-Wdouble-promotion")
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
#endif
+#if __has_warning("-Wdeprecated-enum-enum-conversion")
+#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
+#endif
#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
@@ -213,7 +221,7 @@ void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags)
text_size.y = (pos - text_pos).y;
ImRect bb(text_pos, text_pos + text_size);
- ItemSize(text_size);
+ ItemSize(text_size, 0.0f);
ItemAdd(bb, 0);
}
else
@@ -222,7 +230,7 @@ void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags)
const ImVec2 text_size = CalcTextSize(text_begin, text_end, false, wrap_width);
ImRect bb(text_pos, text_pos + text_size);
- ItemSize(text_size);
+ ItemSize(text_size, 0.0f);
if (!ItemAdd(bb, 0))
return;
@@ -359,17 +367,18 @@ void ImGui::BulletTextV(const char* fmt, va_list args)
const char* text_begin = g.TempBuffer;
const char* text_end = text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
const ImVec2 label_size = CalcTextSize(text_begin, text_end, false);
- const float text_base_offset_y = ImMax(0.0f, window->DC.CurrLineTextBaseOffset); // Latch before ItemSize changes it
- const float line_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + g.Style.FramePadding.y*2), g.FontSize);
- const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize + (label_size.x > 0.0f ? (label_size.x + style.FramePadding.x*2) : 0.0f), ImMax(line_height, label_size.y))); // Empty text doesn't add padding
- ItemSize(bb);
+ const ImVec2 total_size = ImVec2(g.FontSize + (label_size.x > 0.0f ? (label_size.x + style.FramePadding.x * 2) : 0.0f), label_size.y); // Empty text doesn't add padding
+ ImVec2 pos = window->DC.CursorPos;
+ pos.y += window->DC.CurrLineTextBaseOffset;
+ ItemSize(total_size, 0.0f);
+ const ImRect bb(pos, pos + total_size);
if (!ItemAdd(bb, 0))
return;
// Render
ImU32 text_col = GetColorU32(ImGuiCol_Text);
- RenderBullet(window->DrawList, bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, line_height*0.5f), text_col);
- RenderText(bb.Min+ImVec2(g.FontSize + style.FramePadding.x*2, text_base_offset_y), text_begin, text_end, false);
+ RenderBullet(window->DrawList, bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, g.FontSize*0.5f), text_col);
+ RenderText(bb.Min + ImVec2(g.FontSize + style.FramePadding.x * 2, 0.0f), text_begin, text_end, false);
}
//-------------------------------------------------------------------------
@@ -382,8 +391,10 @@ void ImGui::BulletTextV(const char* fmt, va_list args)
// - ArrowButton()
// - CloseButton() [Internal]
// - CollapseButton() [Internal]
-// - ScrollbarEx() [Internal]
+// - GetWindowScrollbarID() [Internal]
+// - GetWindowScrollbarRect() [Internal]
// - Scrollbar() [Internal]
+// - ScrollbarEx() [Internal]
// - Image()
// - ImageButton()
// - Checkbox()
@@ -460,12 +471,16 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
return false;
}
- // Default behavior requires click+release on same spot
- if ((flags & (ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick)) == 0)
- flags |= ImGuiButtonFlags_PressedOnClickRelease;
+ // Default only reacts to left mouse button
+ if ((flags & ImGuiButtonFlags_MouseButtonMask_) == 0)
+ flags |= ImGuiButtonFlags_MouseButtonDefault_;
+
+ // Default behavior requires click + release inside bounding box
+ if ((flags & ImGuiButtonFlags_PressedOnMask_) == 0)
+ flags |= ImGuiButtonFlags_PressedOnDefault_;
ImGuiWindow* backup_hovered_window = g.HoveredWindow;
- const bool flatten_hovered_children = (flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredRootWindow == window->RootWindow;
+ const bool flatten_hovered_children = (flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredRootWindow == window;
if (flatten_hovered_children)
g.HoveredWindow = window;
@@ -501,38 +516,55 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
if (hovered && (flags & ImGuiButtonFlags_AllowItemOverlap) && (g.HoveredIdPreviousFrame != id && g.HoveredIdPreviousFrame != 0))
hovered = false;
- // Mouse
+ // Mouse handling
if (hovered)
{
if (!(flags & ImGuiButtonFlags_NoKeyModifiers) || (!g.IO.KeyCtrl && !g.IO.KeyShift && !g.IO.KeyAlt))
{
- if ((flags & ImGuiButtonFlags_PressedOnClickRelease) && g.IO.MouseClicked[0])
+ // Poll buttons
+ int mouse_button_clicked = -1;
+ int mouse_button_released = -1;
+ if ((flags & ImGuiButtonFlags_MouseButtonLeft) && g.IO.MouseClicked[0]) { mouse_button_clicked = 0; }
+ else if ((flags & ImGuiButtonFlags_MouseButtonRight) && g.IO.MouseClicked[1]) { mouse_button_clicked = 1; }
+ else if ((flags & ImGuiButtonFlags_MouseButtonMiddle) && g.IO.MouseClicked[2]) { mouse_button_clicked = 2; }
+ if ((flags & ImGuiButtonFlags_MouseButtonLeft) && g.IO.MouseReleased[0]) { mouse_button_released = 0; }
+ else if ((flags & ImGuiButtonFlags_MouseButtonRight) && g.IO.MouseReleased[1]) { mouse_button_released = 1; }
+ else if ((flags & ImGuiButtonFlags_MouseButtonMiddle) && g.IO.MouseReleased[2]) { mouse_button_released = 2; }
+
+ if (mouse_button_clicked != -1 && g.ActiveId != id)
{
- SetActiveID(id, window);
- if (!(flags & ImGuiButtonFlags_NoNavFocus))
- SetFocusID(id, window);
- FocusWindow(window);
- }
- if (((flags & ImGuiButtonFlags_PressedOnClick) && g.IO.MouseClicked[0]) || ((flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDoubleClicked[0]))
- {
- pressed = true;
- if (flags & ImGuiButtonFlags_NoHoldingActiveID)
- ClearActiveID();
- else
- SetActiveID(id, window); // Hold on ID
- FocusWindow(window);
+ if (flags & (ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere))
+ {
+ SetActiveID(id, window);
+ g.ActiveIdMouseButton = mouse_button_clicked;
+ if (!(flags & ImGuiButtonFlags_NoNavFocus))
+ SetFocusID(id, window);
+ FocusWindow(window);
+ }
+ if ((flags & ImGuiButtonFlags_PressedOnClick) || ((flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDoubleClicked[mouse_button_clicked]))
+ {
+ pressed = true;
+ if (flags & ImGuiButtonFlags_NoHoldingActiveId)
+ ClearActiveID();
+ else
+ SetActiveID(id, window); // Hold on ID
+ g.ActiveIdMouseButton = mouse_button_clicked;
+ FocusWindow(window);
+ }
}
- if ((flags & ImGuiButtonFlags_PressedOnRelease) && g.IO.MouseReleased[0])
+ if ((flags & ImGuiButtonFlags_PressedOnRelease) && mouse_button_released != -1)
{
- if (!((flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[0] >= g.IO.KeyRepeatDelay)) // Repeat mode trumps
+ // Repeat mode trumps on release behavior
+ if (!((flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[mouse_button_released] >= g.IO.KeyRepeatDelay))
pressed = true;
ClearActiveID();
}
// 'Repeat' mode acts when held regardless of _PressedOn flags (see table above).
// Relies on repeat logic of IsMouseClicked() but we may as well do it ourselves if we end up exposing finer RepeatDelay/RepeatRate settings.
- if ((flags & ImGuiButtonFlags_Repeat) && g.ActiveId == id && g.IO.MouseDownDuration[0] > 0.0f && IsMouseClicked(0, true))
- pressed = true;
+ if (g.ActiveId == id && (flags & ImGuiButtonFlags_Repeat))
+ if (g.IO.MouseDownDuration[g.ActiveIdMouseButton] > 0.0f && IsMouseClicked(g.ActiveIdMouseButton, true))
+ pressed = true;
}
if (pressed)
@@ -542,13 +574,12 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
// Gamepad/Keyboard navigation
// We report navigated item as hovered but we don't set g.HoveredId to not interfere with mouse.
if (g.NavId == id && !g.NavDisableHighlight && g.NavDisableMouseHover && (g.ActiveId == 0 || g.ActiveId == id || g.ActiveId == window->MoveId))
- if (!(flags & ImGuiButtonFlags_NoHoveredOnNav))
+ if (!(flags & ImGuiButtonFlags_NoHoveredOnFocus))
hovered = true;
-
if (g.NavActivateDownId == id)
{
bool nav_activated_by_code = (g.NavActivateId == id);
- bool nav_activated_by_inputs = IsNavInputPressed(ImGuiNavInput_Activate, (flags & ImGuiButtonFlags_Repeat) ? ImGuiInputReadMode_Repeat : ImGuiInputReadMode_Pressed);
+ bool nav_activated_by_inputs = IsNavInputTest(ImGuiNavInput_Activate, (flags & ImGuiButtonFlags_Repeat) ? ImGuiInputReadMode_Repeat : ImGuiInputReadMode_Pressed);
if (nav_activated_by_code || nav_activated_by_inputs)
pressed = true;
if (nav_activated_by_code || nav_activated_by_inputs || g.ActiveId == id)
@@ -564,22 +595,25 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
bool held = false;
if (g.ActiveId == id)
{
- if (pressed)
- g.ActiveIdHasBeenPressedBefore = true;
if (g.ActiveIdSource == ImGuiInputSource_Mouse)
{
if (g.ActiveIdIsJustActivated)
g.ActiveIdClickOffset = g.IO.MousePos - bb.Min;
- if (g.IO.MouseDown[0])
+
+ const int mouse_button = g.ActiveIdMouseButton;
+ IM_ASSERT(mouse_button >= 0 && mouse_button < ImGuiMouseButton_COUNT);
+ if (g.IO.MouseDown[mouse_button])
{
held = true;
}
else
{
- if (hovered && (flags & ImGuiButtonFlags_PressedOnClickRelease) && !g.DragDropActive)
+ bool release_in = hovered && (flags & ImGuiButtonFlags_PressedOnClickRelease) != 0;
+ bool release_anywhere = (flags & ImGuiButtonFlags_PressedOnClickReleaseAnywhere) != 0;
+ if ((release_in || release_anywhere) && !g.DragDropActive)
{
- bool is_double_click_release = (flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDownWasDoubleClick[0];
- bool is_repeating_already = (flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[0] >= g.IO.KeyRepeatDelay; // Repeat mode trumps
+ bool is_double_click_release = (flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDownWasDoubleClick[mouse_button];
+ bool is_repeating_already = (flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[mouse_button] >= g.IO.KeyRepeatDelay; // Repeat mode trumps
if (!is_double_click_release && !is_repeating_already)
pressed = true;
}
@@ -593,6 +627,8 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
if (g.NavActivateDownId != id)
ClearActiveID();
}
+ if (pressed)
+ g.ActiveIdHasBeenPressedBefore = true;
}
if (out_hovered) *out_hovered = hovered;
@@ -691,7 +727,7 @@ bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiBu
const ImGuiID id = window->GetID(str_id);
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
const float default_size = GetFrameHeight();
- ItemSize(size, (size.y >= default_size) ? g.Style.FramePadding.y : 0.0f);
+ ItemSize(size, (size.y >= default_size) ? g.Style.FramePadding.y : -1.0f);
if (!ItemAdd(bb, id))
return false;
@@ -714,7 +750,7 @@ bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiBu
bool ImGui::ArrowButton(const char* str_id, ImGuiDir dir)
{
float sz = GetFrameHeight();
- return ArrowButtonEx(str_id, dir, ImVec2(sz, sz), 0);
+ return ArrowButtonEx(str_id, dir, ImVec2(sz, sz), ImGuiButtonFlags_None);
}
// Button to close a window
@@ -748,8 +784,7 @@ bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos)//, float size)
return pressed;
}
-// The Collapse button also functions as a Dock Menu button.
-bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos, ImGuiDockNode* dock_node)
+bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
@@ -760,31 +795,68 @@ bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos, ImGuiDockNode* dock_no
bool pressed = ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_None);
// Render
- //bool is_dock_menu = (window->DockNodeAsHost && !window->Collapsed);
- ImVec2 off = dock_node ? ImVec2(IM_FLOOR(-g.Style.ItemInnerSpacing.x * 0.5f) + 0.5f, 0.0f) : ImVec2(0.0f, 0.0f);
ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
ImU32 text_col = GetColorU32(ImGuiCol_Text);
ImVec2 center = bb.GetCenter();
if (hovered || held)
- window->DrawList->AddCircleFilled(center + off + ImVec2(0,-0.5f), g.FontSize * 0.5f + 1.0f, bg_col, 12);
-
- if (dock_node)
- RenderArrowDockMenu(window->DrawList, bb.Min + g.Style.FramePadding, g.FontSize, text_col);
- else
- RenderArrow(window->DrawList, bb.Min + g.Style.FramePadding, text_col, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f);
+ window->DrawList->AddCircleFilled(center/*+ ImVec2(0.0f, -0.5f)*/, g.FontSize * 0.5f + 1.0f, bg_col, 12);
+ RenderArrow(window->DrawList, bb.Min + g.Style.FramePadding, text_col, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f);
// Switch to moving the window after mouse is moved beyond the initial drag threshold
if (IsItemActive() && IsMouseDragging(0))
- StartMouseDragFromTitleBar(window, dock_node, true);
+ StartMouseMovingWindow(window);
return pressed;
}
-ImGuiID ImGui::GetScrollbarID(ImGuiWindow* window, ImGuiAxis axis)
+ImGuiID ImGui::GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis)
{
return window->GetIDNoKeepAlive(axis == ImGuiAxis_X ? "#SCROLLX" : "#SCROLLY");
}
+// Return scrollbar rectangle, must only be called for corresponding axis if window->ScrollbarX/Y is set.
+ImRect ImGui::GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis)
+{
+ const ImRect outer_rect = window->Rect();
+ const ImRect inner_rect = window->InnerRect;
+ const float border_size = window->WindowBorderSize;
+ const float scrollbar_size = window->ScrollbarSizes[axis ^ 1]; // (ScrollbarSizes.x = width of Y scrollbar; ScrollbarSizes.y = height of X scrollbar)
+ IM_ASSERT(scrollbar_size > 0.0f);
+ if (axis == ImGuiAxis_X)
+ return ImRect(inner_rect.Min.x, ImMax(outer_rect.Min.y, outer_rect.Max.y - border_size - scrollbar_size), inner_rect.Max.x, outer_rect.Max.y);
+ else
+ return ImRect(ImMax(outer_rect.Min.x, outer_rect.Max.x - border_size - scrollbar_size), inner_rect.Min.y, outer_rect.Max.x, inner_rect.Max.y);
+}
+
+void ImGui::Scrollbar(ImGuiAxis axis)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ const ImGuiID id = GetWindowScrollbarID(window, axis);
+ KeepAliveID(id);
+
+ // Calculate scrollbar bounding box
+ ImRect bb = GetWindowScrollbarRect(window, axis);
+ ImDrawCornerFlags rounding_corners = 0;
+ if (axis == ImGuiAxis_X)
+ {
+ rounding_corners |= ImDrawCornerFlags_BotLeft;
+ if (!window->ScrollbarY)
+ rounding_corners |= ImDrawCornerFlags_BotRight;
+ }
+ else
+ {
+ if ((window->Flags & ImGuiWindowFlags_NoTitleBar) && !(window->Flags & ImGuiWindowFlags_MenuBar))
+ rounding_corners |= ImDrawCornerFlags_TopRight;
+ if (!window->ScrollbarX)
+ rounding_corners |= ImDrawCornerFlags_BotRight;
+ }
+ float size_avail = window->InnerRect.Max[axis] - window->InnerRect.Min[axis];
+ float size_contents = window->ContentSize[axis] + window->WindowPadding[axis] * 2.0f;
+ ScrollbarEx(bb, id, axis, &window->Scroll[axis], size_avail, size_contents, rounding_corners);
+}
+
// Vertical/Horizontal scrollbar
// The entire piece of code below is rather confusing because:
// - We handle absolute seeking (when first clicking outside the grab) and relative manipulation (afterward or when clicking inside the grab)
@@ -803,7 +875,7 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, floa
if (bb_frame_width <= 0.0f || bb_frame_height <= 0.0f)
return false;
- // 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 window resize grab)
float alpha = 1.0f;
if ((axis == ImGuiAxis_Y) && bb_frame_height < g.FontSize + g.Style.FramePadding.y * 2.0f)
alpha = ImSaturate((bb_frame_height - g.FontSize) / (g.Style.FramePadding.y * 2.0f));
@@ -812,13 +884,12 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, floa
const ImGuiStyle& style = g.Style;
const bool allow_interaction = (alpha >= 1.0f);
- const bool horizontal = (axis == ImGuiAxis_X);
ImRect bb = bb_frame;
bb.Expand(ImVec2(-ImClamp(IM_FLOOR((bb_frame_width - 2.0f) * 0.5f), 0.0f, 3.0f), -ImClamp(IM_FLOOR((bb_frame_height - 2.0f) * 0.5f), 0.0f, 3.0f)));
// V denote the main, longer axis of the scrollbar (= height for a vertical scrollbar)
- const float scrollbar_size_v = horizontal ? bb.GetWidth() : bb.GetHeight();
+ const float scrollbar_size_v = (axis == ImGuiAxis_X) ? bb.GetWidth() : bb.GetHeight();
// Calculate the height of our grabbable box. It generally represent the amount visible (vs the total scrollable amount)
// But we maintain a minimum size in pixel to allow for the user to still aim inside.
@@ -834,11 +905,11 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, floa
float scroll_max = ImMax(1.0f, size_contents_v - size_avail_v);
float scroll_ratio = ImSaturate(*p_scroll_v / scroll_max);
- float grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v;
+ float grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v; // Grab position in normalized space
if (held && allow_interaction && grab_h_norm < 1.0f)
{
- float scrollbar_pos_v = horizontal ? bb.Min.x : bb.Min.y;
- float mouse_pos_v = horizontal ? g.IO.MousePos.x : g.IO.MousePos.y;
+ float scrollbar_pos_v = bb.Min[axis];
+ float mouse_pos_v = g.IO.MousePos[axis];
// Click position in scrollbar normalized space (0.0f->1.0f)
const float clicked_v_norm = ImSaturate((mouse_pos_v - scrollbar_pos_v) / scrollbar_size_v);
@@ -855,10 +926,10 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, floa
g.ScrollbarClickDeltaToGrabCenter = clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f;
}
- // Apply scroll
+ // Apply scroll (p_scroll_v will generally point on one member of window->Scroll)
// It is ok to modify Scroll here because we are being called in Begin() after the calculation of ContentSize and before setting up our starting position
const float scroll_v_norm = ImSaturate((clicked_v_norm - g.ScrollbarClickDeltaToGrabCenter - grab_h_norm * 0.5f) / (1.0f - grab_h_norm));
- *p_scroll_v = IM_FLOOR(0.5f + scroll_v_norm * scroll_max);//(win_size_contents_v - win_size_v));
+ *p_scroll_v = IM_ROUND(scroll_v_norm * scroll_max);//(win_size_contents_v - win_size_v));
// Update values for rendering
scroll_ratio = ImSaturate(*p_scroll_v / scroll_max);
@@ -870,10 +941,11 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, floa
}
// Render
- window->DrawList->AddRectFilled(bb_frame.Min, bb_frame.Max, GetColorU32(ImGuiCol_ScrollbarBg), window->WindowRounding, rounding_corners);
+ const ImU32 bg_col = GetColorU32(ImGuiCol_ScrollbarBg);
const ImU32 grab_col = GetColorU32(held ? ImGuiCol_ScrollbarGrabActive : hovered ? ImGuiCol_ScrollbarGrabHovered : ImGuiCol_ScrollbarGrab, alpha);
+ window->DrawList->AddRectFilled(bb_frame.Min, bb_frame.Max, bg_col, window->WindowRounding, rounding_corners);
ImRect grab_rect;
- if (horizontal)
+ if (axis == ImGuiAxis_X)
grab_rect = ImRect(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm), bb.Min.y, ImLerp(bb.Min.x, bb.Max.x, grab_v_norm) + grab_h_pixels, bb.Max.y);
else
grab_rect = ImRect(bb.Min.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm), bb.Max.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm) + grab_h_pixels);
@@ -882,38 +954,6 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, floa
return held;
}
-void ImGui::Scrollbar(ImGuiAxis axis)
-{
- ImGuiContext& g = *GImGui;
- ImGuiWindow* window = g.CurrentWindow;
-
- const ImGuiID id = GetScrollbarID(window, axis);
- KeepAliveID(id);
-
- // Calculate scrollbar bounding box
- const ImRect outer_rect = window->Rect();
- const ImRect inner_rect = window->InnerRect;
- const float border_size = window->WindowBorderSize;
- const float scrollbar_size = window->ScrollbarSizes[axis ^ 1];
- IM_ASSERT(scrollbar_size > 0.0f);
- const float other_scrollbar_size = window->ScrollbarSizes[axis];
- ImDrawCornerFlags rounding_corners = (other_scrollbar_size <= 0.0f) ? ImDrawCornerFlags_BotRight : 0;
- ImRect bb;
- if (axis == ImGuiAxis_X)
- {
- bb.Min = ImVec2(inner_rect.Min.x, ImMax(outer_rect.Min.y, outer_rect.Max.y - border_size - scrollbar_size));
- bb.Max = ImVec2(inner_rect.Max.x, outer_rect.Max.y);
- rounding_corners |= ImDrawCornerFlags_BotLeft;
- }
- else
- {
- bb.Min = ImVec2(ImMax(outer_rect.Min.x, outer_rect.Max.x - border_size - scrollbar_size), inner_rect.Min.y);
- bb.Max = ImVec2(outer_rect.Max.x, window->InnerRect.Max.y);
- rounding_corners |= ((window->Flags & ImGuiWindowFlags_NoTitleBar) && !(window->Flags & ImGuiWindowFlags_MenuBar)) ? ImDrawCornerFlags_TopRight : 0;
- }
- ScrollbarEx(bb, id, axis, &window->Scroll[axis], inner_rect.Max[axis] - inner_rect.Min[axis], window->ContentSize[axis] + window->WindowPadding[axis] * 2.0f, rounding_corners);
-}
-
void ImGui::Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col)
{
ImGuiWindow* window = GetCurrentWindow();
@@ -1017,7 +1057,7 @@ bool ImGui::Checkbox(const char* label, bool* v)
else if (*v)
{
const float pad = ImMax(1.0f, IM_FLOOR(square_sz / 6.0f));
- RenderCheckMark(check_bb.Min + ImVec2(pad, pad), check_col, square_sz - pad*2.0f);
+ RenderCheckMark(window->DrawList, check_bb.Min + ImVec2(pad, pad), check_col, square_sz - pad*2.0f);
}
if (g.LogEnabled)
@@ -1064,8 +1104,8 @@ bool ImGui::RadioButton(const char* label, bool active)
return false;
ImVec2 center = check_bb.GetCenter();
- center.x = IM_FLOOR(center.x + 0.5f);
- center.y = IM_FLOOR(center.y + 0.5f);
+ center.x = IM_ROUND(center.x);
+ center.y = IM_ROUND(center.y);
const float radius = (square_sz - 1.0f) * 0.5f;
bool hovered, held;
@@ -1265,21 +1305,14 @@ void ImGui::SeparatorEx(ImGuiSeparatorFlags flags)
// We don't provide our width to the layout so that it doesn't get feed back into AutoFit
const ImRect bb(ImVec2(x1, window->DC.CursorPos.y), ImVec2(x2, window->DC.CursorPos.y + thickness_draw));
ItemSize(ImVec2(0.0f, thickness_layout));
- if (!ItemAdd(bb, 0))
+ const bool item_visible = ItemAdd(bb, 0);
+ if (item_visible)
{
- if (columns)
- {
- PopColumnsBackground();
- columns->LineMinY = window->DC.CursorPos.y;
- }
- return;
+ // Draw
+ window->DrawList->AddLine(bb.Min, ImVec2(bb.Max.x, bb.Min.y), GetColorU32(ImGuiCol_Separator));
+ if (g.LogEnabled)
+ LogRenderedText(&bb.Min, "--------------------------------");
}
-
- // Draw
- window->DrawList->AddLine(bb.Min, ImVec2(bb.Max.x, bb.Min.y), GetColorU32(ImGuiCol_Separator));
- if (g.LogEnabled)
- LogRenderedText(&bb.Min, "--------------------------------");
-
if (columns)
{
PopColumnsBackground();
@@ -1354,7 +1387,7 @@ bool ImGui::SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float
// Render
const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : (hovered && g.HoveredIdTimer >= hover_visibility_delay) ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator);
- window->DrawList->AddRectFilled(bb_render.Min, bb_render.Max, col, g.Style.FrameRounding);
+ window->DrawList->AddRectFilled(bb_render.Min, bb_render.Max, col, 0.0f);
return held;
}
@@ -2092,7 +2125,7 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
// Tabbing or CTRL-clicking on Drag turns it into an input box
const bool hovered = ItemHoverable(frame_bb, id);
- bool temp_input_is_active = TempInputTextIsActive(id);
+ bool temp_input_is_active = TempInputIsActive(id);
bool temp_input_start = false;
if (!temp_input_is_active)
{
@@ -2113,7 +2146,7 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
}
}
if (temp_input_is_active || temp_input_start)
- return TempInputTextScalar(frame_bb, id, label, data_type, p_data, format);
+ return TempInputScalar(frame_bb, id, label, data_type, p_data, format);
// Draw frame
const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
@@ -2480,7 +2513,7 @@ bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_typ
return value_changed;
}
-// For 32-bits and larger types, slider bounds are limited to half the natural type range.
+// For 32-bit and larger types, slider bounds are limited to half the natural type range.
// So e.g. an integer Slider between INT_MAX-10 and INT_MAX will fail, but an integer Slider between INT_MAX/2-10 and INT_MAX/2 will be ok.
// It would be possible to lift that limitation with some work but it doesn't seem to be worth it for sliders.
bool ImGui::SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* p_v, const void* p_min, const void* p_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb)
@@ -2544,7 +2577,7 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
// Tabbing or CTRL-clicking on Slider turns it into an input box
const bool hovered = ItemHoverable(frame_bb, id);
- bool temp_input_is_active = TempInputTextIsActive(id);
+ bool temp_input_is_active = TempInputIsActive(id);
bool temp_input_start = false;
if (!temp_input_is_active)
{
@@ -2564,7 +2597,7 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
}
}
if (temp_input_is_active || temp_input_start)
- return TempInputTextScalar(frame_bb, id, label, data_type, p_data, format);
+ return TempInputScalar(frame_bb, id, label, data_type, p_data, format);
// Draw frame
const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
@@ -2843,32 +2876,39 @@ int ImParseFormatPrecision(const char* fmt, int default_precision)
// Create text input in place of another active widget (e.g. used when doing a CTRL+Click on drag/slider widgets)
// FIXME: Facilitate using this in variety of other situations.
-bool ImGui::TempInputTextScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format)
+bool ImGui::TempInputText(const ImRect& bb, ImGuiID id, const char* label, char* buf, int buf_size, ImGuiInputTextFlags flags)
{
- ImGuiContext& g = *GImGui;
-
// On the first frame, g.TempInputTextId == 0, then on subsequent frames it becomes == id.
// We clear ActiveID on the first frame to allow the InputText() taking it back.
- const bool init = (g.TempInputTextId != id);
+ ImGuiContext& g = *GImGui;
+ const bool init = (g.TempInputId != id);
if (init)
ClearActiveID();
+ g.CurrentWindow->DC.CursorPos = bb.Min;
+ bool value_changed = InputTextEx(label, NULL, buf, buf_size, bb.GetSize(), flags);
+ if (init)
+ {
+ // First frame we started displaying the InputText widget, we expect it to take the active id.
+ IM_ASSERT(g.ActiveId == id);
+ g.TempInputId = g.ActiveId;
+ }
+ return value_changed;
+}
+
+bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format)
+{
+ ImGuiContext& g = *GImGui;
+
char fmt_buf[32];
char data_buf[32];
format = ImParseFormatTrimDecorations(format, fmt_buf, IM_ARRAYSIZE(fmt_buf));
DataTypeFormatString(data_buf, IM_ARRAYSIZE(data_buf), data_type, p_data, format);
ImStrTrimBlanks(data_buf);
- g.CurrentWindow->DC.CursorPos = bb.Min;
ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_NoMarkEdited;
flags |= ((data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) ? ImGuiInputTextFlags_CharsScientific : ImGuiInputTextFlags_CharsDecimal);
- bool value_changed = InputTextEx(label, NULL, data_buf, IM_ARRAYSIZE(data_buf), bb.GetSize(), flags);
- if (init)
- {
- // First frame we started displaying the InputText widget, we expect it to take the active id.
- IM_ASSERT(g.ActiveId == id);
- g.TempInputTextId = g.ActiveId;
- }
+ bool value_changed = TempInputText(bb, id, label, data_buf, IM_ARRAYSIZE(data_buf), flags);
if (value_changed)
{
value_changed = DataTypeApplyOpFromText(data_buf, g.InputTextState.InitialTextA.Data, data_type, p_data, NULL);
@@ -3163,7 +3203,7 @@ namespace ImStb
static int STB_TEXTEDIT_STRINGLEN(const STB_TEXTEDIT_STRING* obj) { return obj->CurLenW; }
static ImWchar STB_TEXTEDIT_GETCHAR(const STB_TEXTEDIT_STRING* obj, int idx) { return obj->TextW[idx]; }
static float STB_TEXTEDIT_GETWIDTH(STB_TEXTEDIT_STRING* obj, int line_start_idx, int char_idx) { ImWchar c = obj->TextW[line_start_idx + char_idx]; if (c == '\n') return STB_TEXTEDIT_GETWIDTH_NEWLINE; ImGuiContext& g = *GImGui; return g.Font->GetCharAdvance(c) * (g.FontSize / g.Font->FontSize); }
-static int STB_TEXTEDIT_KEYTOTEXT(int key) { return key >= 0x10000 ? 0 : key; }
+static int STB_TEXTEDIT_KEYTOTEXT(int key) { return key >= 0x200000 ? 0 : key; }
static ImWchar STB_TEXTEDIT_NEWLINE = '\n';
static void STB_TEXTEDIT_LAYOUTROW(StbTexteditRow* r, STB_TEXTEDIT_STRING* obj, int line_start_idx)
{
@@ -3256,8 +3296,25 @@ static bool STB_TEXTEDIT_INSERTCHARS(STB_TEXTEDIT_STRING* obj, int pos, const Im
#define STB_TEXTEDIT_IMPLEMENTATION
#include "imstb_textedit.h"
+// stb_textedit internally allows for a single undo record to do addition and deletion, but somehow, calling
+// the stb_textedit_paste() function creates two separate records, so we perform it manually. (FIXME: Report to nothings/stb?)
+static void stb_textedit_replace(STB_TEXTEDIT_STRING* str, STB_TexteditState* state, const STB_TEXTEDIT_CHARTYPE* text, int text_len)
+{
+ stb_text_makeundo_replace(str, state, 0, str->CurLenW, text_len);
+ ImStb::STB_TEXTEDIT_DELETECHARS(str, 0, str->CurLenW);
+ if (text_len <= 0)
+ return;
+ if (ImStb::STB_TEXTEDIT_INSERTCHARS(str, 0, text, text_len))
+ {
+ state->cursor = text_len;
+ state->has_preferred_x = 0;
+ return;
+ }
+ IM_ASSERT(0); // Failed to insert character, normally shouldn't happen because of how we currently use stb_textedit_replace()
}
+} // namespace ImStb
+
void ImGuiInputTextState::OnKeyPressed(int key)
{
stb_textedit_key(this, &Stb, key);
@@ -3346,6 +3403,10 @@ static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags f
if (c >= 0xE000 && c <= 0xF8FF)
return false;
+ // Filter Unicode ranges we are not handling in this build.
+ if (c > IM_UNICODE_CODEPOINT_MAX)
+ return false;
+
// Generic named filters
if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank | ImGuiInputTextFlags_CharsScientific))
{
@@ -3439,14 +3500,23 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
EndGroup();
return false;
}
- if (!BeginChildFrame(id, frame_bb.GetSize()))
+
+ // We reproduce the contents of BeginChildFrame() in order to provide 'label' so our window internal data are easier to read/debug.
+ PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]);
+ PushStyleVar(ImGuiStyleVar_ChildRounding, style.FrameRounding);
+ PushStyleVar(ImGuiStyleVar_ChildBorderSize, style.FrameBorderSize);
+ PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding);
+ bool child_visible = BeginChildEx(label, id, frame_bb.GetSize(), true, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysUseWindowPadding);
+ PopStyleVar(3);
+ PopStyleColor();
+ if (!child_visible)
{
- EndChildFrame();
+ EndChild();
EndGroup();
return false;
}
draw_window = g.CurrentWindow; // Child window
- draw_window->DC.NavLayerActiveMaskNext |= draw_window->DC.NavLayerCurrentMask; // This is to ensure that EndChild() will display a navigation highlight
+ draw_window->DC.NavLayerActiveMaskNext |= draw_window->DC.NavLayerCurrentMask; // This is to ensure that EndChild() will display a navigation highlight so we can "enter" into it.
inner_size.x -= draw_window->ScrollbarSizes.x;
}
else
@@ -3459,19 +3529,17 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
if (hovered)
g.MouseCursor = ImGuiMouseCursor_TextInput;
- // NB: we are only allowed to access 'edit_state' if we are the active widget.
- ImGuiInputTextState* state = NULL;
- if (g.InputTextState.ID == id)
- state = &g.InputTextState;
+ // We are only allowed to access the state if we are already the active widget.
+ ImGuiInputTextState* state = GetInputTextState(id);
const bool focus_requested = FocusableItemRegister(window, id);
- const bool focus_requested_by_code = focus_requested && (g.FocusRequestCurrWindow == window && g.FocusRequestCurrCounterAll == window->DC.FocusCounterAll);
+ const bool focus_requested_by_code = focus_requested && (g.FocusRequestCurrWindow == window && g.FocusRequestCurrCounterRegular == window->DC.FocusCounterRegular);
const bool focus_requested_by_tab = focus_requested && !focus_requested_by_code;
const bool user_clicked = hovered && io.MouseClicked[0];
const bool user_nav_input_start = (g.ActiveId != id) && ((g.NavInputId == id) || (g.NavActivateId == id && g.NavInputSource == ImGuiInputSource_NavKeyboard));
- const bool user_scroll_finish = is_multiline && state != NULL && g.ActiveId == 0 && g.ActiveIdPreviousFrame == GetScrollbarID(draw_window, ImGuiAxis_Y);
- const bool user_scroll_active = is_multiline && state != NULL && g.ActiveId == GetScrollbarID(draw_window, ImGuiAxis_Y);
+ const bool user_scroll_finish = is_multiline && state != NULL && g.ActiveId == 0 && g.ActiveIdPreviousFrame == GetWindowScrollbarID(draw_window, ImGuiAxis_Y);
+ const bool user_scroll_active = is_multiline && state != NULL && g.ActiveId == GetWindowScrollbarID(draw_window, ImGuiAxis_Y);
bool clear_active_id = false;
bool select_all = (g.ActiveId != id) && ((flags & ImGuiInputTextFlags_AutoSelectAll) != 0 || user_nav_input_start) && (!is_multiline);
@@ -3673,14 +3741,16 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
if (g.ActiveId == id && !g.ActiveIdIsJustActivated && !clear_active_id)
{
IM_ASSERT(state != NULL);
+ IM_ASSERT(io.KeyMods == GetMergedKeyModFlags() && "Mismatching io.KeyCtrl/io.KeyShift/io.KeyAlt/io.KeySuper vs io.KeyMods"); // We rarely do this check, but if anything let's do it here.
+
const int k_mask = (io.KeyShift ? STB_TEXTEDIT_K_SHIFT : 0);
const bool is_osx = io.ConfigMacOSXBehaviors;
- const bool is_shortcut_key = (is_osx ? (io.KeySuper && !io.KeyCtrl) : (io.KeyCtrl && !io.KeySuper)) && !io.KeyAlt && !io.KeyShift; // OS X style: Shortcuts using Cmd/Super instead of Ctrl
- const bool is_osx_shift_shortcut = is_osx && io.KeySuper && io.KeyShift && !io.KeyCtrl && !io.KeyAlt;
+ const bool is_osx_shift_shortcut = is_osx && (io.KeyMods == (ImGuiKeyModFlags_Super | ImGuiKeyModFlags_Shift));
const bool is_wordmove_key_down = is_osx ? io.KeyAlt : io.KeyCtrl; // OS X style: Text editing cursor movement using Alt instead of Ctrl
const bool is_startend_key_down = is_osx && io.KeySuper && !io.KeyCtrl && !io.KeyAlt; // OS X style: Line/Text Start and End using Cmd+Arrows instead of Home/End
- const bool is_ctrl_key_only = io.KeyCtrl && !io.KeyShift && !io.KeyAlt && !io.KeySuper;
- const bool is_shift_key_only = io.KeyShift && !io.KeyCtrl && !io.KeyAlt && !io.KeySuper;
+ const bool is_ctrl_key_only = (io.KeyMods == ImGuiKeyModFlags_Ctrl);
+ const bool is_shift_key_only = (io.KeyMods == ImGuiKeyModFlags_Shift);
+ const bool is_shortcut_key = g.IO.ConfigMacOSXBehaviors ? (io.KeyMods == ImGuiKeyModFlags_Super) : (io.KeyMods == ImGuiKeyModFlags_Ctrl);
const bool is_cut = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_X)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Delete))) && !is_readonly && !is_password && (!is_multiline || state->HasSelection());
const bool is_copy = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_C)) || (is_ctrl_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && !is_password && (!is_multiline || state->HasSelection());
@@ -3769,7 +3839,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
s += ImTextCharFromUtf8(&c, s, NULL);
if (c == 0)
break;
- if (c >= 0x10000 || !InputTextFilterCharacter(&c, flags, callback, callback_user_data))
+ if (!InputTextFilterCharacter(&c, flags, callback, callback_user_data))
continue;
clipboard_filtered[clipboard_filtered_len++] = (ImWchar)c;
}
@@ -3798,13 +3868,22 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
// Restore initial value. Only return true if restoring to the initial value changes the current buffer contents.
if (!is_readonly && strcmp(buf, state->InitialTextA.Data) != 0)
{
+ // Push records into the undo stack so we can CTRL+Z the revert operation itself
apply_new_text = state->InitialTextA.Data;
apply_new_text_length = state->InitialTextA.Size - 1;
+ ImVector w_text;
+ if (apply_new_text_length > 0)
+ {
+ w_text.resize(ImTextCountCharsFromUtf8(apply_new_text, apply_new_text + apply_new_text_length) + 1);
+ ImTextStrFromUtf8(w_text.Data, w_text.Size, apply_new_text, apply_new_text + apply_new_text_length);
+ }
+ stb_textedit_replace(state, &state->Stb, w_text.Data, (apply_new_text_length > 0) ? (w_text.Size - 1) : 0);
}
}
// When using 'ImGuiInputTextFlags_EnterReturnsTrue' as a special case we reapply the live buffer back to the input buffer before clearing ActiveId, even though strictly speaking it wasn't modified on this frame.
- // If we didn't do that, code like InputInt() with ImGuiInputTextFlags_EnterReturnsTrue would fail. Also this allows the user to use InputText() with ImGuiInputTextFlags_EnterReturnsTrue without maintaining any user-side storage.
+ // If we didn't do that, code like InputInt() with ImGuiInputTextFlags_EnterReturnsTrue would fail.
+ // This also allows the user to use InputText() with ImGuiInputTextFlags_EnterReturnsTrue without maintaining any user-side storage (please note that if you use this property along ImGuiInputTextFlags_CallbackResize you can end up with your temporary string object unnecessarily allocating once a frame, either store your string data, either if you don't then don't use ImGuiInputTextFlags_CallbackResize).
bool apply_edit_back_to_user_buffer = !cancel_edit || (enter_pressed && (flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0);
if (apply_edit_back_to_user_buffer)
{
@@ -3898,8 +3977,11 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
// Copy result to user buffer
if (apply_new_text)
{
+ // We cannot test for 'backup_current_text_length != apply_new_text_length' here because we have no guarantee that the size
+ // of our owned buffer matches the size of the string object held by the user, and by design we allow InputText() to be used
+ // without any storage on user's side.
IM_ASSERT(apply_new_text_length >= 0);
- if (backup_current_text_length != apply_new_text_length && is_resizable)
+ if (is_resizable)
{
ImGuiInputTextCallbackData callback_data;
callback_data.EventFlag = ImGuiInputTextFlags_CallbackResize;
@@ -3914,6 +3996,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
apply_new_text_length = ImMin(callback_data.BufTextLen, buf_size - 1);
IM_ASSERT(apply_new_text_length <= buf_size);
}
+ //IMGUI_DEBUG_LOG("InputText(\"%s\"): apply_new_text length %d\n", label, apply_new_text_length);
// If the underlying buffer resize was denied or not carried to the next frame, apply_new_text_length+1 may be >= buf_size.
ImStrncpy(buf, apply_new_text, ImMin(apply_new_text_length + 1, buf_size));
@@ -3993,7 +4076,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
// In multi-line mode, we never exit the loop until all lines are counted, so add one extra to the searches_remaining counter.
searches_remaining += is_multiline ? 1 : 0;
int line_count = 0;
- //for (const ImWchar* s = text_begin; (s = (const ImWchar*)wcschr((const wchar_t*)s, (wchar_t)'\n')) != NULL; s++) // FIXME-OPT: Could use this when wchar_t are 16-bits
+ //for (const ImWchar* s = text_begin; (s = (const ImWchar*)wcschr((const wchar_t*)s, (wchar_t)'\n')) != NULL; s++) // FIXME-OPT: Could use this when wchar_t are 16-bit
for (const ImWchar* s = text_begin; *s != 0; s++)
if (*s == '\n')
{
@@ -4070,7 +4153,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
break;
if (rect_pos.y < clip_rect.y)
{
- //p = (const ImWchar*)wmemchr((const wchar_t*)p, '\n', text_selected_end - p); // FIXME-OPT: Could use this when wchar_t are 16-bits
+ //p = (const ImWchar*)wmemchr((const wchar_t*)p, '\n', text_selected_end - p); // FIXME-OPT: Could use this when wchar_t are 16-bit
//p = p ? p + 1 : text_selected_end;
while (p < text_selected_end)
if (*p++ == '\n')
@@ -4109,10 +4192,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
// Notify OS of text input position for advanced IME (-1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.)
if (!is_readonly)
- {
- g.PlatformImePos = ImVec2(cursor_screen_pos.x - 1, cursor_screen_pos.y - g.FontSize);
- g.PlatformImePosViewport = window->Viewport;
- }
+ g.PlatformImePos = ImVec2(cursor_screen_pos.x - 1.0f, cursor_screen_pos.y - g.FontSize);
}
}
else
@@ -4135,7 +4215,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
if (is_multiline)
{
Dummy(text_size + ImVec2(0.0f, g.FontSize)); // Always add room to scroll an extra line
- EndChildFrame();
+ EndChild();
EndGroup();
}
@@ -4234,8 +4314,13 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
{
// Hue is lost when converting from greyscale rgb (saturation=0). Restore it.
ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]);
- if (f[1] == 0 && memcmp(g.ColorEditLastColor, col, sizeof(float) * 3) == 0)
- f[0] = g.ColorEditLastHue;
+ if (memcmp(g.ColorEditLastColor, col, sizeof(float) * 3) == 0)
+ {
+ if (f[1] == 0)
+ f[0] = g.ColorEditLastHue;
+ if (f[2] == 0)
+ f[1] = g.ColorEditLastSat;
+ }
}
int i[4] = { IM_F32_TO_INT8_UNBOUND(f[0]), IM_F32_TO_INT8_UNBOUND(f[1]), IM_F32_TO_INT8_UNBOUND(f[2]), IM_F32_TO_INT8_UNBOUND(f[3]) };
@@ -4274,16 +4359,15 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
SameLine(0, style.ItemInnerSpacing.x);
SetNextItemWidth((n + 1 < components) ? w_item_one : w_item_last);
- // Disable Hue edit when Saturation is zero
- const bool disable_hue_edit = (n == 0 && (flags & ImGuiColorEditFlags_DisplayHSV) && i[1] == 0);
+ // FIXME: When ImGuiColorEditFlags_HDR flag is passed HS values snap in weird ways when SV values go below 0.
if (flags & ImGuiColorEditFlags_Float)
{
- value_changed |= DragFloat(ids[n], &f[n], 1.0f/255.0f, disable_hue_edit ? +FLT_MAX : 0.0f, disable_hue_edit ? -FLT_MAX : 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]);
value_changed_as_float |= value_changed;
}
else
{
- value_changed |= DragInt(ids[n], &i[n], 1.0f, disable_hue_edit ? INT_MAX : 0, disable_hue_edit ? INT_MIN : hdr ? 0 : 255, fmt_table_int[fmt_idx][n]);
+ value_changed |= DragInt(ids[n], &i[n], 1.0f, 0, hdr ? 0 : 255, fmt_table_int[fmt_idx][n]);
}
if (!(flags & ImGuiColorEditFlags_NoOptions))
OpenPopupOnItemClick("context");
@@ -4352,7 +4436,8 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
if (label != label_display_end && !(flags & ImGuiColorEditFlags_NoLabel))
{
- window->DC.CursorPos = ImVec2(pos.x + w_full + style.ItemInnerSpacing.x, pos.y + style.FramePadding.y);
+ const float text_offset_x = (flags & ImGuiColorEditFlags_NoInputs) ? w_button : w_full + style.ItemInnerSpacing.x;
+ window->DC.CursorPos = ImVec2(pos.x + text_offset_x, pos.y + style.FramePadding.y);
TextEx(label, label_display_end);
}
@@ -4365,6 +4450,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
if ((flags & ImGuiColorEditFlags_DisplayHSV) && (flags & ImGuiColorEditFlags_InputRGB))
{
g.ColorEditLastHue = f[0];
+ g.ColorEditLastSat = f[1];
ColorConvertHSVtoRGB(f[0], f[1], f[2], f[0], f[1], f[2]);
memcpy(g.ColorEditLastColor, f, sizeof(float) * 3);
}
@@ -4422,52 +4508,6 @@ bool ImGui::ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags fl
return true;
}
-static inline ImU32 ImAlphaBlendColor(ImU32 col_a, ImU32 col_b)
-{
- float t = ((col_b >> IM_COL32_A_SHIFT) & 0xFF) / 255.f;
- int r = ImLerp((int)(col_a >> IM_COL32_R_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_R_SHIFT) & 0xFF, t);
- int g = ImLerp((int)(col_a >> IM_COL32_G_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_G_SHIFT) & 0xFF, t);
- int b = ImLerp((int)(col_a >> IM_COL32_B_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_B_SHIFT) & 0xFF, t);
- return IM_COL32(r, g, b, 0xFF);
-}
-
-// Helper for ColorPicker4()
-// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that.
-// I spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding alltogether.
-void ImGui::RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 col, float grid_step, ImVec2 grid_off, float rounding, int rounding_corners_flags)
-{
- ImGuiWindow* window = GetCurrentWindow();
- if (((col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT) < 0xFF)
- {
- ImU32 col_bg1 = GetColorU32(ImAlphaBlendColor(IM_COL32(204,204,204,255), col));
- ImU32 col_bg2 = GetColorU32(ImAlphaBlendColor(IM_COL32(128,128,128,255), col));
- window->DrawList->AddRectFilled(p_min, p_max, col_bg1, rounding, rounding_corners_flags);
-
- int yi = 0;
- for (float y = p_min.y + grid_off.y; y < p_max.y; y += grid_step, yi++)
- {
- float y1 = ImClamp(y, p_min.y, p_max.y), y2 = ImMin(y + grid_step, p_max.y);
- if (y2 <= y1)
- continue;
- for (float x = p_min.x + grid_off.x + (yi & 1) * grid_step; x < p_max.x; x += grid_step * 2.0f)
- {
- float x1 = ImClamp(x, p_min.x, p_max.x), x2 = ImMin(x + grid_step, p_max.x);
- if (x2 <= x1)
- continue;
- int rounding_corners_flags_cell = 0;
- if (y1 <= p_min.y) { if (x1 <= p_min.x) rounding_corners_flags_cell |= ImDrawCornerFlags_TopLeft; if (x2 >= p_max.x) rounding_corners_flags_cell |= ImDrawCornerFlags_TopRight; }
- if (y2 >= p_max.y) { if (x1 <= p_min.x) rounding_corners_flags_cell |= ImDrawCornerFlags_BotLeft; if (x2 >= p_max.x) rounding_corners_flags_cell |= ImDrawCornerFlags_BotRight; }
- rounding_corners_flags_cell &= rounding_corners_flags;
- window->DrawList->AddRectFilled(ImVec2(x1,y1), ImVec2(x2,y2), col_bg2, rounding_corners_flags_cell ? rounding : 0.0f, rounding_corners_flags_cell);
- }
- }
- }
- else
- {
- window->DrawList->AddRectFilled(p_min, p_max, col, rounding, rounding_corners_flags);
- }
-}
-
// Helper for ColorPicker4()
static void RenderArrowsForVerticalBar(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, float bar_w, float alpha)
{
@@ -4547,8 +4587,13 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
{
// Hue is lost when converting from greyscale rgb (saturation=0). Restore it.
ColorConvertRGBtoHSV(R, G, B, H, S, V);
- if (S == 0 && memcmp(g.ColorEditLastColor, col, sizeof(float) * 3) == 0)
- H = g.ColorEditLastHue;
+ if (memcmp(g.ColorEditLastColor, col, sizeof(float) * 3) == 0)
+ {
+ if (S == 0)
+ H = g.ColorEditLastHue;
+ if (V == 0)
+ S = g.ColorEditLastSat;
+ }
}
else if (flags & ImGuiColorEditFlags_InputHSV)
{
@@ -4676,6 +4721,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
{
ColorConvertHSVtoRGB(H >= 1.0f ? H - 10 * 1e-6f : H, S > 0.0f ? S : 10*1e-6f, V > 0.0f ? V : 1e-6f, col[0], col[1], col[2]);
g.ColorEditLastHue = H;
+ g.ColorEditLastSat = S;
memcpy(g.ColorEditLastColor, col, sizeof(float) * 3);
}
else if (flags & ImGuiColorEditFlags_InputHSV)
@@ -4730,8 +4776,13 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
G = col[1];
B = col[2];
ColorConvertRGBtoHSV(R, G, B, H, S, V);
- if (S == 0 && memcmp(g.ColorEditLastColor, col, sizeof(float) * 3) == 0) // Fix local Hue as display below will use it immediately.
- H = g.ColorEditLastHue;
+ if (memcmp(g.ColorEditLastColor, col, sizeof(float) * 3) == 0) // Fix local Hue as display below will use it immediately.
+ {
+ if (S == 0)
+ H = g.ColorEditLastHue;
+ if (V == 0)
+ S = g.ColorEditLastSat;
+ }
}
else if (flags & ImGuiColorEditFlags_InputHSV)
{
@@ -4794,7 +4845,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
draw_list->PrimVtx(trb, uv_white, hue_color32);
draw_list->PrimVtx(trc, uv_white, col_white);
draw_list->PrimVtx(tra, uv_white, 0);
- draw_list->PrimVtx(trb, uv_white, col_white);
+ draw_list->PrimVtx(trb, uv_white, col_black);
draw_list->PrimVtx(trc, uv_white, 0);
draw_list->AddTriangle(tra, trb, trc, col_midgrey, 1.5f);
sv_cursor_pos = ImLerp(ImLerp(trc, tra, ImSaturate(S)), trb, ImSaturate(1 - V));
@@ -4805,13 +4856,13 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size, sv_picker_size), col_white, hue_color32, hue_color32, col_white);
draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size, sv_picker_size), 0, 0, col_black, col_black);
RenderFrameBorder(picker_pos, picker_pos + ImVec2(sv_picker_size, sv_picker_size), 0.0f);
- sv_cursor_pos.x = ImClamp(IM_FLOOR(picker_pos.x + ImSaturate(S) * sv_picker_size + 0.5f), picker_pos.x + 2, picker_pos.x + sv_picker_size - 2); // Sneakily prevent the circle to stick out too much
- sv_cursor_pos.y = ImClamp(IM_FLOOR(picker_pos.y + ImSaturate(1 - V) * sv_picker_size + 0.5f), picker_pos.y + 2, picker_pos.y + sv_picker_size - 2);
+ sv_cursor_pos.x = ImClamp(IM_ROUND(picker_pos.x + ImSaturate(S) * sv_picker_size), picker_pos.x + 2, picker_pos.x + sv_picker_size - 2); // Sneakily prevent the circle to stick out too much
+ sv_cursor_pos.y = ImClamp(IM_ROUND(picker_pos.y + ImSaturate(1 - V) * sv_picker_size), picker_pos.y + 2, picker_pos.y + sv_picker_size - 2);
// Render Hue Bar
for (int i = 0; i < 6; ++i)
draw_list->AddRectFilledMultiColor(ImVec2(bar0_pos_x, picker_pos.y + i * (sv_picker_size / 6)), ImVec2(bar0_pos_x + bars_width, picker_pos.y + (i + 1) * (sv_picker_size / 6)), col_hues[i], col_hues[i], col_hues[i + 1], col_hues[i + 1]);
- float bar0_line_y = IM_FLOOR(picker_pos.y + H * sv_picker_size + 0.5f);
+ float bar0_line_y = IM_ROUND(picker_pos.y + H * sv_picker_size);
RenderFrameBorder(ImVec2(bar0_pos_x, picker_pos.y), ImVec2(bar0_pos_x + bars_width, picker_pos.y + sv_picker_size), 0.0f);
RenderArrowsForVerticalBar(draw_list, ImVec2(bar0_pos_x - 1, bar0_line_y), ImVec2(bars_triangles_half_sz + 1, bars_triangles_half_sz), bars_width + 2.0f, style.Alpha);
}
@@ -4827,9 +4878,9 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
{
float alpha = ImSaturate(col[3]);
ImRect bar1_bb(bar1_pos_x, picker_pos.y, bar1_pos_x + bars_width, picker_pos.y + sv_picker_size);
- RenderColorRectWithAlphaCheckerboard(bar1_bb.Min, bar1_bb.Max, 0, bar1_bb.GetWidth() / 2.0f, ImVec2(0.0f, 0.0f));
+ RenderColorRectWithAlphaCheckerboard(draw_list, bar1_bb.Min, bar1_bb.Max, 0, bar1_bb.GetWidth() / 2.0f, ImVec2(0.0f, 0.0f));
draw_list->AddRectFilledMultiColor(bar1_bb.Min, bar1_bb.Max, user_col32_striped_of_alpha, user_col32_striped_of_alpha, user_col32_striped_of_alpha & ~IM_COL32_A_MASK, user_col32_striped_of_alpha & ~IM_COL32_A_MASK);
- float bar1_line_y = IM_FLOOR(picker_pos.y + (1.0f - alpha) * sv_picker_size + 0.5f);
+ float bar1_line_y = IM_ROUND(picker_pos.y + (1.0f - alpha) * sv_picker_size);
RenderFrameBorder(bar1_bb.Min, bar1_bb.Max, 0.0f);
RenderArrowsForVerticalBar(draw_list, ImVec2(bar1_pos_x - 1, bar1_line_y), ImVec2(bars_triangles_half_sz + 1, bars_triangles_half_sz), bars_width + 2.0f, style.Alpha);
}
@@ -4882,12 +4933,16 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
float grid_step = ImMin(size.x, size.y) / 2.99f;
float rounding = ImMin(g.Style.FrameRounding, grid_step * 0.5f);
ImRect bb_inner = bb;
- float off = -0.75f; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middle ground to reduce those artifacts.
- bb_inner.Expand(off);
+ float off = 0.0f;
+ if ((flags & ImGuiColorEditFlags_NoBorder) == 0)
+ {
+ off = -0.75f; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middle ground to reduce those artifacts.
+ bb_inner.Expand(off);
+ }
if ((flags & ImGuiColorEditFlags_AlphaPreviewHalf) && col_rgb.w < 1.0f)
{
- float mid_x = IM_FLOOR((bb_inner.Min.x + bb_inner.Max.x) * 0.5f + 0.5f);
- RenderColorRectWithAlphaCheckerboard(ImVec2(bb_inner.Min.x + grid_step, bb_inner.Min.y), bb_inner.Max, GetColorU32(col_rgb), grid_step, ImVec2(-grid_step + off, off), rounding, ImDrawCornerFlags_TopRight| ImDrawCornerFlags_BotRight);
+ float mid_x = IM_ROUND((bb_inner.Min.x + bb_inner.Max.x) * 0.5f);
+ RenderColorRectWithAlphaCheckerboard(window->DrawList, ImVec2(bb_inner.Min.x + grid_step, bb_inner.Min.y), bb_inner.Max, GetColorU32(col_rgb), grid_step, ImVec2(-grid_step + off, off), rounding, ImDrawCornerFlags_TopRight| ImDrawCornerFlags_BotRight);
window->DrawList->AddRectFilled(bb_inner.Min, ImVec2(mid_x, bb_inner.Max.y), GetColorU32(col_rgb_without_alpha), rounding, ImDrawCornerFlags_TopLeft|ImDrawCornerFlags_BotLeft);
}
else
@@ -4895,15 +4950,18 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
// Because GetColorU32() multiplies by the global style Alpha and we don't want to display a checkerboard if the source code had no alpha
ImVec4 col_source = (flags & ImGuiColorEditFlags_AlphaPreview) ? col_rgb : col_rgb_without_alpha;
if (col_source.w < 1.0f)
- RenderColorRectWithAlphaCheckerboard(bb_inner.Min, bb_inner.Max, GetColorU32(col_source), grid_step, ImVec2(off, off), rounding);
+ RenderColorRectWithAlphaCheckerboard(window->DrawList, bb_inner.Min, bb_inner.Max, GetColorU32(col_source), grid_step, ImVec2(off, off), rounding);
else
window->DrawList->AddRectFilled(bb_inner.Min, bb_inner.Max, GetColorU32(col_source), rounding, ImDrawCornerFlags_All);
}
RenderNavHighlight(bb, id);
- if (g.Style.FrameBorderSize > 0.0f)
- RenderFrameBorder(bb.Min, bb.Max, rounding);
- else
- window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), rounding); // Color button are often in need of some sort of border
+ if ((flags & ImGuiColorEditFlags_NoBorder) == 0)
+ {
+ if (g.Style.FrameBorderSize > 0.0f)
+ RenderFrameBorder(bb.Min, bb.Max, rounding);
+ else
+ window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), rounding); // Color button are often in need of some sort of border
+ }
// Drag and Drop Source
// NB: The ActiveId test is merely an optional micro-optimization, BeginDragDropSource() does the same test.
@@ -4950,7 +5008,7 @@ void ImGui::ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags
{
ImGuiContext& g = *GImGui;
- BeginTooltipEx(0, true);
+ BeginTooltipEx(0, ImGuiTooltipFlags_OverridePreviousTooltip);
const char* text_end = text ? FindRenderedTextEnd(text, NULL) : text;
if (text_end > text)
{
@@ -5015,12 +5073,15 @@ void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags)
ImFormatString(buf, IM_ARRAYSIZE(buf), "(%d,%d,%d,%d)", cr, cg, cb, ca);
if (Selectable(buf))
SetClipboardText(buf);
- if (flags & ImGuiColorEditFlags_NoAlpha)
- ImFormatString(buf, IM_ARRAYSIZE(buf), "0x%02X%02X%02X", cr, cg, cb);
- else
- ImFormatString(buf, IM_ARRAYSIZE(buf), "0x%02X%02X%02X%02X", cr, cg, cb, ca);
+ ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", cr, cg, cb);
if (Selectable(buf))
SetClipboardText(buf);
+ if (!(flags & ImGuiColorEditFlags_NoAlpha))
+ {
+ ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X%02X", cr, cg, cb, ca);
+ if (Selectable(buf))
+ SetClipboardText(buf);
+ }
EndPopup();
}
@@ -5221,7 +5282,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const bool display_frame = (flags & ImGuiTreeNodeFlags_Framed) != 0;
- const ImVec2 padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding)) ? style.FramePadding : ImVec2(style.FramePadding.x, 0.0f);
+ const ImVec2 padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding)) ? style.FramePadding : ImVec2(style.FramePadding.x, ImMin(window->DC.CurrLineTextBaseOffset, style.FramePadding.y));
if (!label_end)
label_end = FindRenderedTextEnd(label);
@@ -5246,7 +5307,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
const float text_offset_y = ImMax(padding.y, window->DC.CurrLineTextBaseOffset); // Latch before ItemSize changes it
const float text_width = g.FontSize + (label_size.x > 0.0f ? label_size.x + padding.x*2 : 0.0f); // Include collapser
ImVec2 text_pos(window->DC.CursorPos.x + text_offset_x, window->DC.CursorPos.y + text_offset_y);
- ItemSize(ImVec2(text_width, frame_height), text_offset_y);
+ ItemSize(ImVec2(text_width, frame_height), padding.y);
// For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing
ImRect interact_bb = frame_bb;
@@ -5259,7 +5320,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
const bool is_leaf = (flags & ImGuiTreeNodeFlags_Leaf) != 0;
bool is_open = TreeNodeBehaviorIsOpen(id, flags);
if (is_open && !g.NavIdIsAlive && (flags & ImGuiTreeNodeFlags_NavLeftJumpsBackHere) && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
- window->DC.TreeMayJumpToParentOnPopMask |= (1 << window->DC.TreeDepth);
+ window->DC.TreeJumpToParentOnPopMask |= (1 << window->DC.TreeDepth);
bool item_add = ItemAdd(interact_bb, id);
window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HasDisplayRect;
@@ -5273,19 +5334,39 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
return is_open;
}
- // Flags that affects opening behavior:
- // - 0 (default) .................... single-click anywhere to open
- // - OpenOnDoubleClick .............. double-click anywhere to open
- // - OpenOnArrow .................... single-click on arrow to open
- // - OpenOnDoubleClick|OpenOnArrow .. single-click on arrow or double-click anywhere to open
- ImGuiButtonFlags button_flags = ImGuiButtonFlags_NoKeyModifiers;
+ ImGuiButtonFlags button_flags = ImGuiTreeNodeFlags_None;
if (flags & ImGuiTreeNodeFlags_AllowItemOverlap)
button_flags |= ImGuiButtonFlags_AllowItemOverlap;
- if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick)
- button_flags |= ImGuiButtonFlags_PressedOnDoubleClick | ((flags & ImGuiTreeNodeFlags_OpenOnArrow) ? ImGuiButtonFlags_PressedOnClickRelease : 0);
if (!is_leaf)
button_flags |= ImGuiButtonFlags_PressedOnDragDropHold;
+ // We allow clicking on the arrow section with keyboard modifiers held, in order to easily
+ // allow browsing a tree while preserving selection with code implementing multi-selection patterns.
+ // When clicking on the rest of the tree node we always disallow keyboard modifiers.
+ const float arrow_hit_x1 = (text_pos.x - text_offset_x) - style.TouchExtraPadding.x;
+ const float arrow_hit_x2 = (text_pos.x - text_offset_x) + (g.FontSize + padding.x * 2.0f) + style.TouchExtraPadding.x;
+ const bool is_mouse_x_over_arrow = (g.IO.MousePos.x >= arrow_hit_x1 && g.IO.MousePos.x < arrow_hit_x2);
+ if (window != g.HoveredWindow || !is_mouse_x_over_arrow)
+ button_flags |= ImGuiButtonFlags_NoKeyModifiers;
+
+ // Open behaviors can be altered with the _OpenOnArrow and _OnOnDoubleClick flags.
+ // Some alteration have subtle effects (e.g. toggle on MouseUp vs MouseDown events) due to requirements for multi-selection and drag and drop support.
+ // - Single-click on label = Toggle on MouseUp (default)
+ // - Single-click on arrow = Toggle on MouseUp (when _OpenOnArrow=0)
+ // - Single-click on arrow = Toggle on MouseDown (when _OpenOnArrow=1)
+ // - Double-click on label = Toggle on MouseDoubleClick (when _OpenOnDoubleClick=1)
+ // - Double-click on arrow = Toggle on MouseDoubleClick (when _OpenOnDoubleClick=1 and _OpenOnArrow=0)
+ // This makes _OpenOnArrow have a subtle effect on _OpenOnDoubleClick: arrow click reacts on Down rather than Up.
+ // It is rather standard that arrow click react on Down rather than Up and we'd be tempted to make it the default
+ // (by removing the _OpenOnArrow test below), however this would have a perhaps surprising effect on CollapsingHeader()?
+ // So right now we are making this optional. May evolve later.
+ if (is_mouse_x_over_arrow && (flags & ImGuiTreeNodeFlags_OpenOnArrow))
+ button_flags |= ImGuiButtonFlags_PressedOnClick;
+ else if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick)
+ button_flags |= ImGuiButtonFlags_PressedOnDoubleClick;
+ else
+ button_flags |= ImGuiButtonFlags_PressedOnClickRelease;
+
bool selected = (flags & ImGuiTreeNodeFlags_Selected) != 0;
const bool was_selected = selected;
@@ -5296,13 +5377,12 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
{
if (pressed)
{
- const float arrow_x1 = text_pos.x - text_offset_x;
- const float arrow_x2 = arrow_x1 + g.FontSize + padding.x * 2.0f;
- toggled = !(flags & (ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) || (g.NavActivateId == id);
+ if ((flags & (ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) == 0 || (g.NavActivateId == id))
+ toggled = true;
if (flags & ImGuiTreeNodeFlags_OpenOnArrow)
- toggled |= IsMouseHoveringRect(ImVec2(arrow_x1, interact_bb.Min.y), ImVec2(arrow_x2, interact_bb.Max.y)) && (!g.NavDisableMouseHover);
- if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick)
- toggled |= g.IO.MouseDoubleClicked[0];
+ toggled |= is_mouse_x_over_arrow && !g.NavDisableMouseHover; // Lightweight equivalent of IsMouseHoveringRect() since ButtonBehavior() already did the job
+ if ((flags & ImGuiTreeNodeFlags_OpenOnDoubleClick) && g.IO.MouseDoubleClicked[0])
+ toggled = true;
if (g.DragDropActive && is_open) // When using Drag and Drop "hold to open" we keep the node highlighted after opening, but never close it again.
toggled = false;
}
@@ -5322,6 +5402,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
{
is_open = !is_open;
window->DC.StateStorage->SetInt(id, is_open);
+ window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_ToggledOpen;
}
}
if (flags & ImGuiTreeNodeFlags_AllowItemOverlap)
@@ -5421,12 +5502,12 @@ void ImGui::TreePop()
// Handle Left arrow to move to parent tree node (when ImGuiTreeNodeFlags_NavLeftJumpsBackHere is enabled)
if (g.NavMoveDir == ImGuiDir_Left && g.NavWindow == window && NavMoveRequestButNoResultYet())
- if (g.NavIdIsAlive && (window->DC.TreeMayJumpToParentOnPopMask & tree_depth_mask))
+ if (g.NavIdIsAlive && (window->DC.TreeJumpToParentOnPopMask & tree_depth_mask))
{
- SetNavID(window->IDStack.back(), g.NavLayer);
+ SetNavID(window->IDStack.back(), g.NavLayer, 0);
NavMoveRequestCancel();
}
- window->DC.TreeMayJumpToParentOnPopMask &= tree_depth_mask - 1;
+ window->DC.TreeJumpToParentOnPopMask &= tree_depth_mask - 1;
IM_ASSERT(window->IDStack.Size > 1); // There should always be 1 element in the IDStack (pushed during window creation). If this triggers you called TreePop/PopID too much.
PopID();
@@ -5471,7 +5552,9 @@ bool ImGui::CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags
return false;
ImGuiID id = window->GetID(label);
- flags |= ImGuiTreeNodeFlags_CollapsingHeader | (p_open ? ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_ClipLabelForTrailingButton : 0);
+ flags |= ImGuiTreeNodeFlags_CollapsingHeader;
+ if (p_open)
+ flags |= ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_ClipLabelForTrailingButton;
bool is_open = TreeNodeBehavior(id, flags, label);
if (p_open)
{
@@ -5499,6 +5582,8 @@ bool ImGui::CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags
// Tip: pass a non-visible label (e.g. "##dummy") then you can use the space to draw other text or image.
// But you need to make sure the ID is unique, e.g. enclose calls in PushID/PopID or use ##unique_id.
+// With this scheme, ImGuiSelectableFlags_SpanAllColumns and ImGuiSelectableFlags_AllowItemOverlap are also frequently used flags.
+// FIXME: Selectable() with (size.x == 0.0f) and (SelectableTextAlign.x > 0.0f) followed by SameLine() is currently not supported.
bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags flags, const ImVec2& size_arg)
{
ImGuiWindow* window = GetCurrentWindow();
@@ -5511,44 +5596,48 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.CurrentColumns) // FIXME-OPT: Avoid if vertically clipped.
PushColumnsBackground();
+ // Submit label or explicit size to ItemSize(), whereas ItemAdd() will submit a larger/spanning rectangle.
ImGuiID id = window->GetID(label);
ImVec2 label_size = CalcTextSize(label, NULL, true);
ImVec2 size(size_arg.x != 0.0f ? size_arg.x : label_size.x, size_arg.y != 0.0f ? size_arg.y : label_size.y);
ImVec2 pos = window->DC.CursorPos;
pos.y += window->DC.CurrLineTextBaseOffset;
- ImRect bb_inner(pos, pos + size);
- ItemSize(size);
+ ItemSize(size, 0.0f);
- // Fill horizontal space.
- ImVec2 window_padding = window->WindowPadding;
- float max_x = (flags & ImGuiSelectableFlags_SpanAllColumns) ? GetWindowContentRegionMax().x : GetContentRegionMax().x;
- float w_draw = ImMax(label_size.x, window->Pos.x + max_x - window_padding.x - pos.x);
- ImVec2 size_draw((size_arg.x != 0 && !(flags & ImGuiSelectableFlags_DrawFillAvailWidth)) ? size_arg.x : w_draw, size_arg.y != 0.0f ? size_arg.y : size.y);
- ImRect bb(pos, pos + size_draw);
- if (size_arg.x == 0.0f || (flags & ImGuiSelectableFlags_DrawFillAvailWidth))
- bb.Max.x += window_padding.x;
+ // Fill horizontal space
+ const float min_x = (flags & ImGuiSelectableFlags_SpanAllColumns) ? window->ContentRegionRect.Min.x : pos.x;
+ const float max_x = (flags & ImGuiSelectableFlags_SpanAllColumns) ? window->ContentRegionRect.Max.x : GetContentRegionMaxAbs().x;
+ if (size_arg.x == 0.0f || (flags & ImGuiSelectableFlags_SpanAvailWidth))
+ size.x = ImMax(label_size.x, max_x - min_x);
- // Selectables are tightly packed together so we extend the box to cover spacing between selectable.
+ // Text stays at the submission position, but bounding box may be extended on both sides
+ const ImVec2 text_min = pos;
+ const ImVec2 text_max(min_x + size.x, pos.y + size.y);
+
+ // Selectables are meant to be tightly packed together with no click-gap, so we extend their box to cover spacing between selectable.
+ ImRect bb_enlarged(min_x, pos.y, text_max.x, text_max.y);
const float spacing_x = style.ItemSpacing.x;
const float spacing_y = style.ItemSpacing.y;
const float spacing_L = IM_FLOOR(spacing_x * 0.50f);
const float spacing_U = IM_FLOOR(spacing_y * 0.50f);
- bb.Min.x -= spacing_L;
- bb.Min.y -= spacing_U;
- bb.Max.x += (spacing_x - spacing_L);
- bb.Max.y += (spacing_y - spacing_U);
+ bb_enlarged.Min.x -= spacing_L;
+ bb_enlarged.Min.y -= spacing_U;
+ bb_enlarged.Max.x += (spacing_x - spacing_L);
+ bb_enlarged.Max.y += (spacing_y - spacing_U);
+ //if (g.IO.KeyCtrl) { GetForegroundDrawList()->AddRect(bb_align.Min, bb_align.Max, IM_COL32(255, 0, 0, 255)); }
+ //if (g.IO.KeyCtrl) { GetForegroundDrawList()->AddRect(bb_enlarged.Min, bb_enlarged.Max, IM_COL32(0, 255, 0, 255)); }
bool item_add;
if (flags & ImGuiSelectableFlags_Disabled)
{
ImGuiItemFlags backup_item_flags = window->DC.ItemFlags;
window->DC.ItemFlags |= ImGuiItemFlags_Disabled | ImGuiItemFlags_NoNavDefaultFocus;
- item_add = ItemAdd(bb, id);
+ item_add = ItemAdd(bb_enlarged, id);
window->DC.ItemFlags = backup_item_flags;
}
else
{
- item_add = ItemAdd(bb, id);
+ item_add = ItemAdd(bb_enlarged, id);
}
if (!item_add)
{
@@ -5559,19 +5648,19 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
// We use NoHoldingActiveID on menus so user can click and _hold_ on a menu then drag to browse child entries
ImGuiButtonFlags button_flags = 0;
- if (flags & ImGuiSelectableFlags_NoHoldingActiveID) button_flags |= ImGuiButtonFlags_NoHoldingActiveID;
- if (flags & ImGuiSelectableFlags_PressedOnClick) button_flags |= ImGuiButtonFlags_PressedOnClick;
- if (flags & ImGuiSelectableFlags_PressedOnRelease) button_flags |= ImGuiButtonFlags_PressedOnRelease;
- if (flags & ImGuiSelectableFlags_Disabled) button_flags |= ImGuiButtonFlags_Disabled;
- if (flags & ImGuiSelectableFlags_AllowDoubleClick) button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick;
- if (flags & ImGuiSelectableFlags_AllowItemOverlap) button_flags |= ImGuiButtonFlags_AllowItemOverlap;
+ if (flags & ImGuiSelectableFlags_NoHoldingActiveID) { button_flags |= ImGuiButtonFlags_NoHoldingActiveId; }
+ if (flags & ImGuiSelectableFlags_SelectOnClick) { button_flags |= ImGuiButtonFlags_PressedOnClick; }
+ if (flags & ImGuiSelectableFlags_SelectOnRelease) { button_flags |= ImGuiButtonFlags_PressedOnRelease; }
+ if (flags & ImGuiSelectableFlags_Disabled) { button_flags |= ImGuiButtonFlags_Disabled; }
+ if (flags & ImGuiSelectableFlags_AllowDoubleClick) { button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick; }
+ if (flags & ImGuiSelectableFlags_AllowItemOverlap) { button_flags |= ImGuiButtonFlags_AllowItemOverlap; }
if (flags & ImGuiSelectableFlags_Disabled)
selected = false;
const bool was_selected = selected;
bool hovered, held;
- bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags);
+ bool pressed = ButtonBehavior(bb_enlarged, id, &hovered, &held, button_flags);
// Update NavId when clicking or when Hovering (this doesn't happen on most widgets), so navigation can be resumed with gamepad/keyboard
if (pressed || (hovered && (flags & ImGuiSelectableFlags_SetNavIdOnHover)))
@@ -5579,7 +5668,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
if (!g.NavDisableMouseHover && g.NavWindow == window && g.NavLayer == window->DC.NavLayerCurrent)
{
g.NavDisableHighlight = true;
- SetNavID(id, window->DC.NavLayerCurrent);
+ SetNavID(id, window->DC.NavLayerCurrent, window->DC.NavFocusScopeIdCurrent);
}
}
if (pressed)
@@ -5598,18 +5687,15 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
if (hovered || selected)
{
const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header);
- RenderFrame(bb.Min, bb.Max, col, false, 0.0f);
- RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding);
+ RenderFrame(bb_enlarged.Min, bb_enlarged.Max, col, false, 0.0f);
+ RenderNavHighlight(bb_enlarged, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding);
}
if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.CurrentColumns)
- {
PopColumnsBackground();
- bb.Max.x -= (GetContentRegionMax().x - max_x);
- }
if (flags & ImGuiSelectableFlags_Disabled) PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]);
- RenderTextClipped(bb_inner.Min, bb_inner.Max, label, NULL, &label_size, style.SelectableTextAlign, &bb);
+ RenderTextClipped(text_min, text_max, label, NULL, &label_size, style.SelectableTextAlign, &bb_enlarged);
if (flags & ImGuiSelectableFlags_Disabled) PopStyleColor();
// Automatically close popups
@@ -5762,13 +5848,13 @@ bool ImGui::ListBox(const char* label, int* current_item, bool (*items_getter)(v
// - PlotHistogram()
//-------------------------------------------------------------------------
-void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size)
+int ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size)
{
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
- return;
+ return -1;
- ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label);
@@ -5783,7 +5869,7 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
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));
ItemSize(total_bb, style.FramePadding.y);
if (!ItemAdd(total_bb, 0, &frame_bb))
- return;
+ return -1;
const bool hovered = ItemHoverable(frame_bb, id);
// Determine scale from values if not specified
@@ -5808,13 +5894,13 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
const int values_count_min = (plot_type == ImGuiPlotType_Lines) ? 2 : 1;
+ int idx_hovered = -1;
if (values_count >= values_count_min)
{
int res_w = ImMin((int)frame_size.x, values_count) + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0);
int item_count = values_count + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0);
// Tooltip on hover
- int v_hovered = -1;
if (hovered && inner_bb.Contains(g.IO.MousePos))
{
const float t = ImClamp((g.IO.MousePos.x - inner_bb.Min.x) / (inner_bb.Max.x - inner_bb.Min.x), 0.0f, 0.9999f);
@@ -5827,7 +5913,7 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
SetTooltip("%d: %8.4g\n%d: %8.4g", v_idx, v0, v_idx+1, v1);
else if (plot_type == ImGuiPlotType_Histogram)
SetTooltip("%d: %8.4g", v_idx, v0);
- v_hovered = v_idx;
+ idx_hovered = v_idx;
}
const float t_step = 1.0f / (float)res_w;
@@ -5854,13 +5940,13 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
ImVec2 pos1 = ImLerp(inner_bb.Min, inner_bb.Max, (plot_type == ImGuiPlotType_Lines) ? tp1 : ImVec2(tp1.x, histogram_zero_line_t));
if (plot_type == ImGuiPlotType_Lines)
{
- window->DrawList->AddLine(pos0, pos1, v_hovered == v1_idx ? col_hovered : col_base);
+ window->DrawList->AddLine(pos0, pos1, idx_hovered == v1_idx ? col_hovered : col_base);
}
else if (plot_type == ImGuiPlotType_Histogram)
{
if (pos1.x >= pos0.x + 2.0f)
pos1.x -= 1.0f;
- window->DrawList->AddRectFilled(pos0, pos1, v_hovered == v1_idx ? col_hovered : col_base);
+ window->DrawList->AddRectFilled(pos0, pos1, idx_hovered == v1_idx ? col_hovered : col_base);
}
t0 = t1;
@@ -5874,6 +5960,10 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
if (label_size.x > 0.0f)
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, inner_bb.Min.y), label);
+
+ // Return hovered index or -1 if none are hovered.
+ // This is currently not exposed in the public API because we need a larger redesign of the whole thing, but in the short-term we are making it available in PlotEx().
+ return idx_hovered;
}
struct ImGuiPlotArrayGetterData
@@ -5953,10 +6043,10 @@ void ImGui::Value(const char* prefix, float v, const char* float_format)
// [SECTION] MenuItem, BeginMenu, EndMenu, etc.
//-------------------------------------------------------------------------
// - ImGuiMenuColumns [Internal]
-// - BeginMainMenuBar()
-// - EndMainMenuBar()
// - BeginMenuBar()
// - EndMenuBar()
+// - BeginMainMenuBar()
+// - EndMainMenuBar()
// - BeginMenu()
// - EndMenu()
// - MenuItem()
@@ -5999,47 +6089,11 @@ float ImGuiMenuColumns::DeclColumns(float w0, float w1, float w2) // not using v
return ImMax(Width, NextWidth);
}
-float ImGuiMenuColumns::CalcExtraSpace(float avail_w)
+float ImGuiMenuColumns::CalcExtraSpace(float avail_w) const
{
return ImMax(0.0f, avail_w - Width);
}
-// For the main menu bar, which cannot be moved, we honor g.Style.DisplaySafeAreaPadding to ensure text can be visible on a TV set.
-bool ImGui::BeginMainMenuBar()
-{
- ImGuiContext& g = *GImGui;
- ImGuiViewport* viewport = g.Viewports[0];
- g.NextWindowData.MenuBarOffsetMinVal = ImVec2(g.Style.DisplaySafeAreaPadding.x, ImMax(g.Style.DisplaySafeAreaPadding.y - g.Style.FramePadding.y, 0.0f));
- SetNextWindowPos(viewport->Pos);
- SetNextWindowSize(ImVec2(viewport->Size.x, g.NextWindowData.MenuBarOffsetMinVal.y + g.FontBaseSize + g.Style.FramePadding.y));
- SetNextWindowViewport(viewport->ID); // Enforce viewport so we don't create our onw viewport when ImGuiConfigFlags_ViewportsNoMerge is set.
- PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
- PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0,0));
- ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_MenuBar;
- bool is_open = Begin("##MainMenuBar", NULL, window_flags) && BeginMenuBar();
- PopStyleVar(2);
- g.NextWindowData.MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f);
- if (!is_open)
- {
- End();
- return false;
- }
- return true; //-V1020
-}
-
-void ImGui::EndMainMenuBar()
-{
- EndMenuBar();
-
- // When the user has left the menu layer (typically: closed menus through activation of an item), we restore focus to the previous window
- // FIXME: With this strategy we won't be able to restore a NULL focus.
- ImGuiContext& g = *GImGui;
- if (g.CurrentWindow == g.NavWindow && g.NavLayer == 0 && !g.NavAnyRequest)
- FocusTopMostWindowUnderOne(g.NavWindow, NULL);
-
- End();
-}
-
// FIXME: Provided a rectangle perhaps e.g. a BeginMenuBarEx() could be used anywhere..
// Currently the main responsibility of this function being to setup clip-rect + horizontal layout + menu navigation layer.
// Ideally we also want this to be responsible for claiming space out of the main window scrolling rectangle, in which case ImGuiWindowFlags_MenuBar will become unnecessary.
@@ -6059,7 +6113,7 @@ bool ImGui::BeginMenuBar()
// We don't clip with current window clipping rectangle as it is already set to the area below. However we clip with window full rect.
// We remove 1 worth of rounding to Max.x to that text in long menus and small windows don't tend to display over the lower-right rounded area, which looks particularly glitchy.
ImRect bar_rect = window->MenuBarRect();
- ImRect clip_rect(ImFloor(bar_rect.Min.x + window->WindowBorderSize + 0.5f), ImFloor(bar_rect.Min.y + window->WindowBorderSize + 0.5f), ImFloor(ImMax(bar_rect.Min.x, bar_rect.Max.x - ImMax(window->WindowRounding, window->WindowBorderSize)) + 0.5f), ImFloor(bar_rect.Max.y + 0.5f));
+ ImRect clip_rect(IM_ROUND(bar_rect.Min.x + window->WindowBorderSize), IM_ROUND(bar_rect.Min.y + window->WindowBorderSize), IM_ROUND(ImMax(bar_rect.Min.x, bar_rect.Max.x - ImMax(window->WindowRounding, window->WindowBorderSize))), IM_ROUND(bar_rect.Max.y));
clip_rect.ClipWith(window->OuterRectClipped);
PushClipRect(clip_rect.Min, clip_rect.Max, false);
@@ -6092,7 +6146,7 @@ void ImGui::EndMenuBar()
const ImGuiNavLayer layer = ImGuiNavLayer_Menu;
IM_ASSERT(window->DC.NavLayerActiveMaskNext & (1 << layer)); // Sanity check
FocusWindow(window);
- SetNavIDWithRectRel(window->NavLastIds[layer], layer, window->NavRectRel[layer]);
+ SetNavIDWithRectRel(window->NavLastIds[layer], layer, 0, window->NavRectRel[layer]);
g.NavLayer = layer;
g.NavDisableHighlight = true; // Hide highlight for the current frame so we don't see the intermediary selection.
g.NavMoveRequestForward = ImGuiNavForward_ForwardQueued;
@@ -6113,6 +6167,40 @@ void ImGui::EndMenuBar()
window->DC.MenuBarAppending = false;
}
+// For the main menu bar, which cannot be moved, we honor g.Style.DisplaySafeAreaPadding to ensure text can be visible on a TV set.
+bool ImGui::BeginMainMenuBar()
+{
+ ImGuiContext& g = *GImGui;
+ g.NextWindowData.MenuBarOffsetMinVal = ImVec2(g.Style.DisplaySafeAreaPadding.x, ImMax(g.Style.DisplaySafeAreaPadding.y - g.Style.FramePadding.y, 0.0f));
+ SetNextWindowPos(ImVec2(0.0f, 0.0f));
+ SetNextWindowSize(ImVec2(g.IO.DisplaySize.x, g.NextWindowData.MenuBarOffsetMinVal.y + g.FontBaseSize + g.Style.FramePadding.y));
+ PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
+ PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0, 0));
+ ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_MenuBar;
+ bool is_open = Begin("##MainMenuBar", NULL, window_flags) && BeginMenuBar();
+ PopStyleVar(2);
+ g.NextWindowData.MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f);
+ if (!is_open)
+ {
+ End();
+ return false;
+ }
+ return true; //-V1020
+}
+
+void ImGui::EndMainMenuBar()
+{
+ EndMenuBar();
+
+ // When the user has left the menu layer (typically: closed menus through activation of an item), we restore focus to the previous window
+ // FIXME: With this strategy we won't be able to restore a NULL focus.
+ ImGuiContext& g = *GImGui;
+ if (g.CurrentWindow == g.NavWindow && g.NavLayer == ImGuiNavLayer_Main && !g.NavAnyRequest)
+ FocusTopMostWindowUnderOne(g.NavWindow, NULL);
+
+ End();
+}
+
bool ImGui::BeginMenu(const char* label, bool enabled)
{
ImGuiWindow* window = GetCurrentWindow();
@@ -6122,11 +6210,30 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label);
+ bool menu_is_open = IsPopupOpen(id);
- ImVec2 label_size = CalcTextSize(label, NULL, true);
+ // Sub-menus are ChildWindow so that mouse can be hovering across them (otherwise top-most popup menu would steal focus and not allow hovering on parent menu)
+ ImGuiWindowFlags flags = ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNavFocus;
+ if (window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu))
+ flags |= ImGuiWindowFlags_ChildWindow;
+
+ // If a menu with same the ID was already submitted, we will append to it, matching the behavior of Begin().
+ // We are relying on a O(N) search - so O(N log N) over the frame - which seems like the most efficient for the expected small amount of BeginMenu() calls per frame.
+ // If somehow this is ever becoming a problem we can switch to use e.g. a ImGuiStorager mapping key to last frame used.
+ if (g.MenusIdSubmittedThisFrame.contains(id))
+ {
+ if (menu_is_open)
+ menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
+ else
+ g.NextWindowData.ClearFlags(); // we behave like Begin() and need to consume those values
+ return menu_is_open;
+ }
+ // Tag menu as used. Next time BeginMenu() with same ID is called it will append to existing menu
+ g.MenusIdSubmittedThisFrame.push_back(id);
+
+ ImVec2 label_size = CalcTextSize(label, NULL, true);
bool pressed;
- bool menu_is_open = IsPopupOpen(id);
bool menuset_is_open = !(window->Flags & ImGuiWindowFlags_Popup) && (g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].OpenParentId == window->IDStack.back());
ImGuiWindow* backed_nav_window = g.NavWindow;
if (menuset_is_open)
@@ -6145,19 +6252,21 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * 0.5f);
PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y));
float w = label_size.x;
- pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_PressedOnClick | ImGuiSelectableFlags_DontClosePopups | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f));
+ pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f));
PopStyleVar();
window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar().
}
else
{
// Menu inside a menu
+ // (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f.
+ // Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.
popup_pos = ImVec2(pos.x, pos.y - style.WindowPadding.y);
- float w = window->MenuColumns.DeclColumns(label_size.x, 0.0f, IM_FLOOR(g.FontSize * 1.20f)); // Feedback to next frame
- float extra_w = ImMax(0.0f, GetContentRegionAvail().x - w);
- pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_PressedOnClick | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_DrawFillAvailWidth | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f));
+ float min_w = window->DC.MenuColumns.DeclColumns(label_size.x, 0.0f, IM_FLOOR(g.FontSize * 1.20f)); // Feedback to next frame
+ float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
+ pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_SpanAvailWidth | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(min_w, 0.0f));
ImU32 text_col = GetColorU32(enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled);
- RenderArrow(window->DrawList, pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * 0.30f, 0.0f), text_col, ImGuiDir_Right);
+ RenderArrow(window->DrawList, pos + ImVec2(window->DC.MenuColumns.Pos[2] + extra_w + g.FontSize * 0.30f, 0.0f), text_col, ImGuiDir_Right);
}
const bool hovered = enabled && ItemHoverable(window->DC.LastItemRect, id);
@@ -6245,13 +6354,13 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
if (menu_is_open)
{
- // Sub-menus are ChildWindow so that mouse can be hovering across them (otherwise top-most popup menu would steal focus and not allow hovering on parent menu)
SetNextWindowPos(popup_pos, ImGuiCond_Always);
- ImGuiWindowFlags flags = ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNavFocus;
- if (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu))
- flags |= ImGuiWindowFlags_ChildWindow;
menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
}
+ else
+ {
+ g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
+ }
return menu_is_open;
}
@@ -6285,7 +6394,7 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool selected, boo
// We've been using the equivalent of ImGuiSelectableFlags_SetNavIdOnHover on all Selectable() since early Nav system days (commit 43ee5d73),
// but I am unsure whether this should be kept at all. For now moved it to be an opt-in feature used by menus only.
- ImGuiSelectableFlags flags = ImGuiSelectableFlags_PressedOnRelease | ImGuiSelectableFlags_SetNavIdOnHover | (enabled ? 0 : ImGuiSelectableFlags_Disabled);
+ ImGuiSelectableFlags flags = ImGuiSelectableFlags_SelectOnRelease | ImGuiSelectableFlags_SetNavIdOnHover | (enabled ? 0 : ImGuiSelectableFlags_Disabled);
bool pressed;
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
{
@@ -6300,18 +6409,21 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool selected, boo
}
else
{
- ImVec2 shortcut_size = shortcut ? CalcTextSize(shortcut, NULL) : ImVec2(0.0f, 0.0f);
- float w = window->MenuColumns.DeclColumns(label_size.x, shortcut_size.x, IM_FLOOR(g.FontSize * 1.20f)); // Feedback for next frame
- float extra_w = ImMax(0.0f, GetContentRegionAvail().x - w);
- pressed = Selectable(label, false, flags | ImGuiSelectableFlags_DrawFillAvailWidth, ImVec2(w, 0.0f));
- if (shortcut_size.x > 0.0f)
+ // Menu item inside a vertical menu
+ // (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f.
+ // Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.
+ float shortcut_w = shortcut ? CalcTextSize(shortcut, NULL).x : 0.0f;
+ float min_w = window->DC.MenuColumns.DeclColumns(label_size.x, shortcut_w, IM_FLOOR(g.FontSize * 1.20f)); // Feedback for next frame
+ float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
+ pressed = Selectable(label, false, flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, 0.0f));
+ if (shortcut_w > 0.0f)
{
PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]);
- RenderText(pos + ImVec2(window->MenuColumns.Pos[1] + extra_w, 0.0f), shortcut, NULL, false);
+ RenderText(pos + ImVec2(window->DC.MenuColumns.Pos[1] + extra_w, 0.0f), shortcut, NULL, false);
PopStyleColor();
}
if (selected)
- RenderCheckMark(pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * 0.40f, g.FontSize * 0.134f * 0.5f), GetColorU32(enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled), g.FontSize * 0.866f);
+ RenderCheckMark(window->DrawList, pos + ImVec2(window->DC.MenuColumns.Pos[2] + extra_w + g.FontSize * 0.40f, g.FontSize * 0.134f * 0.5f), GetColorU32(enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled), g.FontSize * 0.866f);
}
IMGUI_TEST_ENGINE_ITEM_INFO(window->DC.LastItemId, label, window->DC.ItemFlags | ImGuiItemStatusFlags_Checkable | (selected ? ImGuiItemStatusFlags_Checked : 0));
@@ -6332,8 +6444,6 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool* p_selected,
//-------------------------------------------------------------------------
// [SECTION] Widgets: BeginTabBar, EndTabBar, etc.
//-------------------------------------------------------------------------
-// [BETA API] API may evolve!
-//-------------------------------------------------------------------------
// - BeginTabBar()
// - BeginTabBarEx() [Internal]
// - EndTabBar()
@@ -6341,7 +6451,6 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool* p_selected,
// - TabBarCalcTabID() [Internal]
// - TabBarCalcMaxTabWidth() [Internal]
// - TabBarFindTabById() [Internal]
-// - TabBarAddTab() [Internal]
// - TabBarRemoveTab() [Internal]
// - TabBarCloseTab() [Internal]
// - TabBarScrollClamp()v
@@ -6409,10 +6518,10 @@ bool ImGui::BeginTabBar(const char* str_id, ImGuiTabBarFlags flags)
ImGuiTabBar* tab_bar = g.TabBars.GetOrAddByKey(id);
ImRect tab_bar_bb = ImRect(window->DC.CursorPos.x, window->DC.CursorPos.y, window->WorkRect.Max.x, window->DC.CursorPos.y + g.FontSize + g.Style.FramePadding.y * 2);
tab_bar->ID = id;
- return BeginTabBarEx(tab_bar, tab_bar_bb, flags | ImGuiTabBarFlags_IsFocused, NULL);
+ return BeginTabBarEx(tab_bar, tab_bar_bb, flags | ImGuiTabBarFlags_IsFocused);
}
-bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImGuiTabBarFlags flags, ImGuiDockNode* dock_node)
+bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImGuiTabBarFlags flags)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
@@ -6429,7 +6538,7 @@ bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImG
if (tab_bar->CurrFrameVisible == g.FrameCount)
{
//IMGUI_DEBUG_LOG("BeginTabBarEx already called this frame\n", g.FrameCount);
- //IM_ASSERT(0);
+ IM_ASSERT(0);
return true;
}
@@ -6450,22 +6559,15 @@ bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImG
tab_bar->FramePadding = g.Style.FramePadding;
// Layout
- ItemSize(ImVec2(tab_bar->OffsetMaxIdeal, tab_bar->BarRect.GetHeight()));
+ ItemSize(ImVec2(tab_bar->OffsetMaxIdeal, tab_bar->BarRect.GetHeight()), tab_bar->FramePadding.y);
window->DC.CursorPos.x = tab_bar->BarRect.Min.x;
// Draw separator
const ImU32 col = GetColorU32((flags & ImGuiTabBarFlags_IsFocused) ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive);
const float y = tab_bar->BarRect.Max.y - 1.0f;
- if (dock_node != NULL)
- {
- const float separator_min_x = dock_node->Pos.x + window->WindowBorderSize;
- const float separator_max_x = dock_node->Pos.x + dock_node->Size.x - window->WindowBorderSize;
- window->DrawList->AddLine(ImVec2(separator_min_x, y), ImVec2(separator_max_x, y), col, 1.0f);
- }
- else
{
- const float separator_min_x = tab_bar->BarRect.Min.x - ImFloor(window->WindowPadding.x * 0.5f);
- const float separator_max_x = tab_bar->BarRect.Max.x + ImFloor(window->WindowPadding.x * 0.5f);
+ const float separator_min_x = tab_bar->BarRect.Min.x - IM_FLOOR(window->WindowPadding.x * 0.5f);
+ const float separator_max_x = tab_bar->BarRect.Max.x + IM_FLOOR(window->WindowPadding.x * 0.5f);
window->DrawList->AddLine(ImVec2(separator_min_x, y), ImVec2(separator_max_x, y), col, 1.0f);
}
return true;
@@ -6481,8 +6583,8 @@ void ImGui::EndTabBar()
ImGuiTabBar* tab_bar = g.CurrentTabBar;
if (tab_bar == NULL)
{
- IM_ASSERT(tab_bar != NULL && "Mismatched BeginTabBar()/EndTabBar()!");
- return; // FIXME-ERRORHANDLING
+ IM_ASSERT_USER_ERROR(tab_bar != NULL, "Mismatched BeginTabBar()/EndTabBar()!");
+ return;
}
if (tab_bar->WantLayout)
TabBarLayout(tab_bar);
@@ -6583,14 +6685,14 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
// Additionally, when using TabBarAddTab() to manipulate tab bar order we occasionally insert new tabs that don't have a width yet,
// and we cannot wait for the next BeginTabItem() call. We cannot compute this width within TabBarAddTab() because font size depends on the active window.
const char* tab_name = tab_bar->GetTabName(tab);
- const bool has_close_button = tab->Window ? tab->Window->HasCloseButton : ((tab->Flags & ImGuiTabItemFlags_NoCloseButton) == 0);
- tab->WidthContents = TabItemCalcSize(tab_name, has_close_button).x;
+ const bool has_close_button = (tab->Flags & ImGuiTabItemFlags_NoCloseButton) ? false : true;
+ tab->ContentWidth = TabItemCalcSize(tab_name, has_close_button).x;
- width_total_contents += (tab_n > 0 ? g.Style.ItemInnerSpacing.x : 0.0f) + tab->WidthContents;
+ width_total_contents += (tab_n > 0 ? g.Style.ItemInnerSpacing.x : 0.0f) + tab->ContentWidth;
// Store data so we can build an array sorted by width if we need to shrink tabs down
g.ShrinkWidthBuffer[tab_n].Index = tab_n;
- g.ShrinkWidthBuffer[tab_n].Width = tab->WidthContents;
+ g.ShrinkWidthBuffer[tab_n].Width = tab->ContentWidth;
}
// Compute width
@@ -6610,7 +6712,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
{
ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
- tab->Width = ImMin(tab->WidthContents, tab_max_width);
+ tab->Width = ImMin(tab->ContentWidth, tab_max_width);
IM_ASSERT(tab->Width > 0.0f);
}
}
@@ -6626,7 +6728,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
if (scroll_track_selected_tab_id == 0 && g.NavJustMovedToId == tab->ID)
scroll_track_selected_tab_id = tab->ID;
offset_x += tab->Width + g.Style.ItemInnerSpacing.x;
- offset_x_ideal += tab->WidthContents + g.Style.ItemInnerSpacing.x;
+ offset_x_ideal += tab->ContentWidth + g.Style.ItemInnerSpacing.x;
}
tab_bar->OffsetMax = ImMax(offset_x - g.Style.ItemInnerSpacing.x, 0.0f);
tab_bar->OffsetMaxIdeal = ImMax(offset_x_ideal - g.Style.ItemInnerSpacing.x, 0.0f);
@@ -6647,10 +6749,6 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
tab_bar->VisibleTabId = tab_bar->SelectedTabId;
tab_bar->VisibleTabWasSubmitted = false;
- // CTRL+TAB can override visible tab temporarily
- if (g.NavWindowingTarget != NULL && g.NavWindowingTarget->DockNode && g.NavWindowingTarget->DockNode->TabBar == tab_bar)
- tab_bar->VisibleTabId = scroll_track_selected_tab_id = g.NavWindowingTarget->ID;
-
// Update scrolling
if (scroll_track_selected_tab_id)
if (ImGuiTabItem* scroll_track_selected_tab = TabBarFindTabByID(tab_bar, scroll_track_selected_tab_id))
@@ -6707,38 +6805,6 @@ ImGuiTabItem* ImGui::TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id)
return NULL;
}
-// FIXME: See references to #2304 in TODO.txt
-ImGuiTabItem* ImGui::TabBarFindMostRecentlySelectedTabForActiveWindow(ImGuiTabBar* tab_bar)
-{
- ImGuiTabItem* most_recently_selected_tab = NULL;
- for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
- {
- ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
- if (most_recently_selected_tab == NULL || most_recently_selected_tab->LastFrameSelected < tab->LastFrameSelected)
- if (tab->Window && tab->Window->WasActive)
- most_recently_selected_tab = tab;
- }
- return most_recently_selected_tab;
-}
-
-// The purpose of this call is to register tab in advance so we can control their order at the time they appear.
-// Otherwise calling this is unnecessary as tabs are appending as needed by the BeginTabItem() function.
-void ImGui::TabBarAddTab(ImGuiTabBar* tab_bar, ImGuiTabItemFlags tab_flags, ImGuiWindow* window)
-{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(TabBarFindTabByID(tab_bar, window->ID) == NULL);
- IM_ASSERT(g.CurrentTabBar == NULL); // Can't work while the tab bar is active as our tab doesn't have an X offset yet
-
- ImGuiTabItem new_tab;
- new_tab.ID = window->ID;
- new_tab.Flags = tab_flags;
- new_tab.LastFrameVisible = tab_bar->CurrFrameVisible; // Required so BeginTabBar() doesn't ditch the tab
- if (new_tab.LastFrameVisible == -1)
- new_tab.LastFrameVisible = g.FrameCount - 1;
- new_tab.Window = window; // Required so tab bar layout can compute the tab width before tab submission
- tab_bar->Tabs.push_back(new_tab);
-}
-
// The *TabId fields be already set by the docking system _before_ the actual TabItem was created, so we clear them regardless.
void ImGui::TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id)
{
@@ -6892,8 +6958,6 @@ static ImGuiTabItem* ImGui::TabBarTabListPopupButton(ImGuiTabBar* tab_bar)
//-------------------------------------------------------------------------
// [SECTION] Widgets: BeginTabItem, EndTabItem, etc.
//-------------------------------------------------------------------------
-// [BETA API] API may evolve!
-//-------------------------------------------------------------------------
// - BeginTabItem()
// - EndTabItem()
// - TabItemEx() [Internal]
@@ -6913,10 +6977,10 @@ bool ImGui::BeginTabItem(const char* label, bool* p_open, ImGuiTabItemFlags f
ImGuiTabBar* tab_bar = g.CurrentTabBar;
if (tab_bar == NULL)
{
- IM_ASSERT(tab_bar && "Needs to be called between BeginTabBar() and EndTabBar()!");
- return false; // FIXME-ERRORHANDLING
+ IM_ASSERT_USER_ERROR(tab_bar, "BeginTabItem() Needs to be called between BeginTabBar() and EndTabBar()!");
+ return false;
}
- bool ret = TabItemEx(tab_bar, label, p_open, flags, NULL);
+ bool ret = TabItemEx(tab_bar, label, p_open, flags);
if (ret && !(flags & ImGuiTabItemFlags_NoPushId))
{
ImGuiTabItem* tab = &tab_bar->Tabs[tab_bar->LastTabItemIdx];
@@ -6944,7 +7008,7 @@ void ImGui::EndTabItem()
window->IDStack.pop_back();
}
-bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags, ImGuiWindow* docked_window)
+bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags)
{
// Layout whole tab bar if not already done
if (tab_bar->WantLayout)
@@ -6967,6 +7031,12 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
return false;
}
+ // Store into ImGuiTabItemFlags_NoCloseButton, also honor ImGuiTabItemFlags_NoCloseButton passed by user (although not documented)
+ if (flags & ImGuiTabItemFlags_NoCloseButton)
+ p_open = NULL;
+ else if (p_open == NULL)
+ flags |= ImGuiTabItemFlags_NoCloseButton;
+
// Calculate tab contents size
ImVec2 size = TabItemCalcSize(label, p_open != NULL);
@@ -6982,30 +7052,17 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
tab_is_new = true;
}
tab_bar->LastTabItemIdx = (short)tab_bar->Tabs.index_from_ptr(tab);
- tab->WidthContents = size.x;
-
- if (p_open == NULL)
- flags |= ImGuiTabItemFlags_NoCloseButton;
+ tab->ContentWidth = size.x;
const bool tab_bar_appearing = (tab_bar->PrevFrameVisible + 1 < g.FrameCount);
const bool tab_bar_focused = (tab_bar->Flags & ImGuiTabBarFlags_IsFocused) != 0;
const bool tab_appearing = (tab->LastFrameVisible + 1 < g.FrameCount);
tab->LastFrameVisible = g.FrameCount;
tab->Flags = flags;
- tab->Window = docked_window;
// Append name with zero-terminator
- if (tab_bar->Flags & ImGuiTabBarFlags_DockNode)
- {
- IM_ASSERT(tab->Window != NULL);
- tab->NameOffset = -1;
- }
- else
- {
- IM_ASSERT(tab->Window == NULL);
- tab->NameOffset = tab_bar->TabsNames.size();
- tab_bar->TabsNames.append(label, label + strlen(label) + 1); // Append name _with_ the zero-terminator.
- }
+ tab->NameOffset = tab_bar->TabsNames.size();
+ tab_bar->TabsNames.append(label, label + strlen(label) + 1);
// If we are not reorderable, always reset offset based on submission order.
// (We already handled layout and sizing using the previous known order, but sizing is not affected by order!)
@@ -7028,7 +7085,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
tab_bar->VisibleTabWasSubmitted = true;
// On the very first frame of a tab bar we let first tab contents be visible to minimize appearing glitches
- if (!tab_contents_visible && tab_bar->SelectedTabId == 0 && tab_bar_appearing && docked_window == NULL)
+ if (!tab_contents_visible && tab_bar->SelectedTabId == 0 && tab_bar_appearing)
if (tab_bar->Tabs.Size == 1 && !(tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs))
tab_contents_visible = true;
@@ -7071,7 +7128,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
// Click to Select a tab
ImGuiButtonFlags button_flags = (ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_AllowItemOverlap);
- if (g.DragDropActive && !g.DragDropPayload.IsDataType(IMGUI_PAYLOAD_TYPE_WINDOW))
+ if (g.DragDropActive)
button_flags |= ImGuiButtonFlags_PressedOnDragDropHold;
bool hovered, held;
bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags);
@@ -7083,73 +7140,30 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
if (!held)
SetItemAllowOverlap();
- // Drag and drop a single floating window node moves it
- ImGuiDockNode* node = docked_window ? docked_window->DockNode : NULL;
- const bool single_floating_window_node = node && node->IsFloatingNode() && (node->Windows.Size == 1);
- if (held && single_floating_window_node && IsMouseDragging(0, 0.0f))
+ // Drag and drop: re-order tabs
+ if (held && !tab_appearing && IsMouseDragging(0))
{
- // Move
- StartMouseMovingWindow(docked_window);
- }
- else if (held && !tab_appearing && IsMouseDragging(0))
- {
- // Drag and drop: re-order tabs
- float drag_distance_from_edge_x = 0.0f;
- if (!g.DragDropActive && ((tab_bar->Flags & ImGuiTabBarFlags_Reorderable) || (docked_window != NULL)))
+ if (!g.DragDropActive && (tab_bar->Flags & ImGuiTabBarFlags_Reorderable))
{
// While moving a tab it will jump on the other side of the mouse, so we also test for MouseDelta.x
if (g.IO.MouseDelta.x < 0.0f && g.IO.MousePos.x < bb.Min.x)
{
- drag_distance_from_edge_x = bb.Min.x - g.IO.MousePos.x;
if (tab_bar->Flags & ImGuiTabBarFlags_Reorderable)
TabBarQueueChangeTabOrder(tab_bar, tab, -1);
}
else if (g.IO.MouseDelta.x > 0.0f && g.IO.MousePos.x > bb.Max.x)
{
- drag_distance_from_edge_x = g.IO.MousePos.x - bb.Max.x;
if (tab_bar->Flags & ImGuiTabBarFlags_Reorderable)
TabBarQueueChangeTabOrder(tab_bar, tab, +1);
}
}
-
- // Extract a Dockable window out of it's tab bar
- if (docked_window != NULL && !(docked_window->Flags & ImGuiWindowFlags_NoMove))
- {
- // We use a variable threshold to distinguish dragging tabs within a tab bar and extracting them out of the tab bar
- bool undocking_tab = (g.DragDropActive && g.DragDropPayload.SourceId == id);
-
- if (!undocking_tab) //&& (!g.IO.ConfigDockingWithShift || g.IO.KeyShift)
- {
- float threshold_base = g.FontSize;
- //float threshold_base = g.IO.ConfigDockingWithShift ? g.FontSize * 0.5f : g.FontSize;
- float threshold_x = (threshold_base * 2.2f);
- float threshold_y = (threshold_base * 1.5f) + ImClamp((ImFabs(g.IO.MouseDragMaxDistanceAbs[0].x) - threshold_base * 2.0f) * 0.20f, 0.0f, threshold_base * 4.0f);
- //GetForegroundDrawList()->AddRect(ImVec2(bb.Min.x - threshold_x, bb.Min.y - threshold_y), ImVec2(bb.Max.x + threshold_x, bb.Max.y + threshold_y), IM_COL32_WHITE); // [DEBUG]
-
- float distance_from_edge_y = ImMax(bb.Min.y - g.IO.MousePos.y, g.IO.MousePos.y - bb.Max.y);
- if (distance_from_edge_y >= threshold_y)
- undocking_tab = true;
- else if (drag_distance_from_edge_x > threshold_x)
- if ((tab_bar->ReorderRequestDir < 0 && tab_bar->GetTabOrder(tab) == 0) || (tab_bar->ReorderRequestDir > 0 && tab_bar->GetTabOrder(tab) == tab_bar->Tabs.Size - 1))
- undocking_tab = true;
- }
-
- if (undocking_tab)
- {
- // Undock
- DockContextQueueUndockWindow(&g, docked_window);
- g.MovingWindow = docked_window;
- g.ActiveId = g.MovingWindow->MoveId;
- g.ActiveIdClickOffset -= g.MovingWindow->Pos - bb.Min;
- }
- }
}
#if 0
- if (hovered && g.HoveredIdNotActiveTimer > 0.50f && bb.GetWidth() < tab->WidthContents)
+ if (hovered && g.HoveredIdNotActiveTimer > 0.50f && bb.GetWidth() < tab->ContentWidth)
{
// Enlarge tab display when hovering
- bb.Max.x = bb.Min.x + IM_FLOOR(ImLerp(bb.GetWidth(), tab->WidthContents, ImSaturate((g.HoveredIdNotActiveTimer - 0.40f) * 6.0f)));
+ bb.Max.x = bb.Min.x + IM_FLOOR(ImLerp(bb.GetWidth(), tab->ContentWidth, ImSaturate((g.HoveredIdNotActiveTimer - 0.40f) * 6.0f)));
display_draw_list = GetForegroundDrawList(window);
TabItemBackground(display_draw_list, bb, flags, GetColorU32(ImGuiCol_TitleBgActive));
}
@@ -7205,16 +7219,6 @@ void ImGui::SetTabItemClosed(const char* label)
ImGuiID tab_id = TabBarCalcTabID(tab_bar, label);
TabBarRemoveTab(tab_bar, tab_id);
}
- else if (ImGuiWindow* window = FindWindowByName(label))
- {
- if (window->DockIsActive)
- if (ImGuiDockNode* node = window->DockNode)
- {
- ImGuiID tab_id = TabBarCalcTabID(node->TabBar, label);
- TabBarRemoveTab(node->TabBar, tab_id);
- window->DockTabWantClose = true;
- }
- }
}
ImVec2 ImGui::TabItemCalcSize(const char* label, bool has_close_button)
@@ -7238,7 +7242,7 @@ void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabI
IM_ASSERT(width > 0.0f);
const float rounding = ImMax(0.0f, ImMin(g.Style.TabRounding, width * 0.5f - 1.0f));
const float y1 = bb.Min.y + 1.0f;
- const float y2 = bb.Max.y + ((flags & ImGuiTabItemFlags_Preview) ? 0.0f : -1.0f);
+ const float y2 = bb.Max.y - 1.0f;
draw_list->PathLineTo(ImVec2(bb.Min.x, y2));
draw_list->PathArcToFast(ImVec2(bb.Min.x + rounding, y1 + rounding), rounding, 6, 9);
draw_list->PathArcToFast(ImVec2(bb.Max.x - rounding, y1 + rounding), rounding, 9, 12);
@@ -7463,7 +7467,7 @@ void ImGui::PushColumnsBackground()
ImGuiColumns* columns = window->DC.CurrentColumns;
if (columns->Count == 1)
return;
- window->DrawList->ChannelsSetCurrent(0);
+ columns->Splitter.SetCurrentChannel(window->DrawList, 0);
int cmd_size = window->DrawList->CmdBuffer.Size;
PushClipRect(columns->HostClipRect.Min, columns->HostClipRect.Max, false);
IM_UNUSED(cmd_size);
@@ -7476,7 +7480,7 @@ void ImGui::PopColumnsBackground()
ImGuiColumns* columns = window->DC.CurrentColumns;
if (columns->Count == 1)
return;
- window->DrawList->ChannelsSetCurrent(columns->Current + 1);
+ columns->Splitter.SetCurrentChannel(window->DrawList, columns->Current + 1);
PopClipRect();
}
@@ -7512,7 +7516,7 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
ImGuiWindow* window = GetCurrentWindow();
IM_ASSERT(columns_count >= 1);
- IM_ASSERT(window->DC.CurrentColumns == NULL); // Nested columns are currently not supported
+ IM_ASSERT(window->DC.CurrentColumns == NULL); // Nested columns are currently not supported
// Acquire storage for the columns set
ImGuiID id = GetColumnsID(str_id, columns_count);
@@ -7559,16 +7563,16 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
{
// Compute clipping rectangle
ImGuiColumnData* column = &columns->Columns[n];
- 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_x1 = IM_ROUND(window->Pos.x + GetColumnOffset(n));
+ float clip_x2 = IM_ROUND(window->Pos.x + GetColumnOffset(n + 1) - 1.0f);
column->ClipRect = ImRect(clip_x1, -FLT_MAX, clip_x2, +FLT_MAX);
column->ClipRect.ClipWith(window->ClipRect);
}
if (columns->Count > 1)
{
- window->DrawList->ChannelsSplit(1 + columns->Count);
- window->DrawList->ChannelsSetCurrent(1);
+ columns->Splitter.Split(window->DrawList, 1 + columns->Count);
+ columns->Splitter.SetCurrentChannel(window->DrawList, 1);
PushColumnClipRect(0);
}
@@ -7607,14 +7611,14 @@ void ImGui::NextColumn()
// Columns 1+ ignore IndentX (by canceling it out)
// FIXME-COLUMNS: Unnecessary, could be locked?
window->DC.ColumnsOffset.x = GetColumnOffset(columns->Current) - window->DC.Indent.x + column_padding;
- window->DrawList->ChannelsSetCurrent(columns->Current + 1);
+ columns->Splitter.SetCurrentChannel(window->DrawList, columns->Current + 1);
}
else
{
// New row/line
// Column 0 honor IndentX
window->DC.ColumnsOffset.x = ImMax(column_padding - window->WindowPadding.x, 0.0f);
- window->DrawList->ChannelsSetCurrent(1);
+ columns->Splitter.SetCurrentChannel(window->DrawList, 1);
columns->Current = 0;
columns->LineMinY = columns->LineMaxY;
}
@@ -7644,7 +7648,7 @@ void ImGui::EndColumns()
if (columns->Count > 1)
{
PopClipRect();
- window->DrawList->ChannelsMerge();
+ columns->Splitter.Merge(window->DrawList);
}
const ImGuiColumnsFlags flags = columns->Flags;
@@ -7728,3 +7732,5 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
}
//-------------------------------------------------------------------------
+
+#endif // #ifndef IMGUI_DISABLE
diff --git a/Sources/CImGui/imgui/imstb_textedit.h b/Sources/CImGui/imgui/imstb_textedit.h
index d7fcbd6..2077d02 100644
--- a/Sources/CImGui/imgui/imstb_textedit.h
+++ b/Sources/CImGui/imgui/imstb_textedit.h
@@ -1,4 +1,4 @@
-// [DEAR IMGUI]
+// [DEAR IMGUI]
// This is a slightly modified version of stb_textedit.h 1.13.
// Those changes would need to be pushed into nothings/stb:
// - Fix in stb_textedit_discard_redo (see https://github.com/nothings/stb/issues/321)
diff --git a/Sources/CImGui/imgui/imstb_truetype.h b/Sources/CImGui/imgui/imstb_truetype.h
index c1cdb18..b4bdbd8 100644
--- a/Sources/CImGui/imgui/imstb_truetype.h
+++ b/Sources/CImGui/imgui/imstb_truetype.h
@@ -1,4 +1,4 @@
-// [DEAR IMGUI]
+// [DEAR IMGUI]
// This is a slightly modified version of stb_truetype.h 1.20.
// Mostly fixing for compiler and static analyzer warnings.
// Grep for [DEAR IMGUI] to find the changes.
@@ -2538,11 +2538,11 @@ static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, i
// There are no other cases.
STBTT_assert(0);
break;
- };
+ } // [DEAR IMGUI] removed ;
}
}
break;
- };
+ } // [DEAR IMGUI] removed ;
default:
// TODO: Implement other stuff.
@@ -4132,7 +4132,7 @@ STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect
STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges)
{
stbtt_fontinfo info;
- int i,j,n, return_value = 1;
+ int i,j,n, return_value; // [DEAR IMGUI] removed = 1
//stbrp_context *context = (stbrp_context *) spc->pack_info;
stbrp_rect *rects;
diff --git a/Sources/CImGui/include/cimgui.h b/Sources/CImGui/include/cimgui.h
index 7e24825..60267ef 100644
--- a/Sources/CImGui/include/cimgui.h
+++ b/Sources/CImGui/include/cimgui.h
@@ -1,5 +1,6 @@
//This file is automatically generated by generator.lua from https://github.com/cimgui/cimgui
-//based on imgui.h file version "1.74 WIP" from Dear ImGui https://github.com/ocornut/imgui
+//based on imgui.h file version "1.76" from Dear ImGui https://github.com/ocornut/imgui
+//with imgui_internal.h api
#ifndef CIMGUI_INCLUDED
#define CIMGUI_INCLUDED
#include
@@ -14,7 +15,11 @@
#define snprintf sprintf_s
#endif
#else
- #define API
+ #ifdef __GNUC__
+ #define API __attribute__((__visibility__("default")))
+ #else
+ #define API
+ #endif
#endif
#if defined __cplusplus
@@ -35,27 +40,44 @@ typedef unsigned __int64 ImU64;
//typedef unsigned long long ImU64;
#endif
-//UDT stuff
-typedef struct ImVec2_Simple { float x; float y; } ImVec2_Simple;
-typedef struct ImVec4_Simple { float x; float y; float z; float w;} ImVec4_Simple;
-typedef struct ImColor_Simple { ImVec4_Simple Value;} ImColor_Simple;
-
#ifndef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
typedef struct ImGuiStoragePair ImGuiStoragePair;
typedef struct ImGuiTextRange ImGuiTextRange;
+typedef struct ImGuiPtrOrIndex ImGuiPtrOrIndex;
+typedef struct ImGuiShrinkWidthItem ImGuiShrinkWidthItem;
+typedef struct ImVec2ih ImVec2ih;
+typedef struct ImVec1 ImVec1;
typedef struct ImFontAtlasCustomRect ImFontAtlasCustomRect;
typedef struct ImVec4 ImVec4;
typedef struct ImVec2 ImVec2;
-typedef struct ImGuiWindowClass ImGuiWindowClass;
-typedef struct ImGuiViewport ImGuiViewport;
+typedef struct ImGuiWindowSettings ImGuiWindowSettings;
+typedef struct ImGuiWindowTempData ImGuiWindowTempData;
+typedef struct ImGuiWindow ImGuiWindow;
+typedef struct ImGuiTabItem ImGuiTabItem;
+typedef struct ImGuiTabBar ImGuiTabBar;
+typedef struct ImGuiStyleMod ImGuiStyleMod;
+typedef struct ImGuiSettingsHandler ImGuiSettingsHandler;
+typedef struct ImGuiPopupData ImGuiPopupData;
+typedef struct ImGuiNextItemData ImGuiNextItemData;
+typedef struct ImGuiNextWindowData ImGuiNextWindowData;
+typedef struct ImGuiNavMoveResult ImGuiNavMoveResult;
+typedef struct ImGuiMenuColumns ImGuiMenuColumns;
+typedef struct ImGuiItemHoveredDataBackup ImGuiItemHoveredDataBackup;
+typedef struct ImGuiInputTextState ImGuiInputTextState;
+typedef struct ImGuiGroupData ImGuiGroupData;
+typedef struct ImGuiDataTypeInfo ImGuiDataTypeInfo;
+typedef struct ImGuiColumns ImGuiColumns;
+typedef struct ImGuiColumnData ImGuiColumnData;
+typedef struct ImGuiColorMod ImGuiColorMod;
+typedef struct ImDrawDataBuilder ImDrawDataBuilder;
+typedef struct ImRect ImRect;
+typedef struct ImBitVector ImBitVector;
typedef struct ImGuiTextFilter ImGuiTextFilter;
typedef struct ImGuiTextBuffer ImGuiTextBuffer;
typedef struct ImGuiStyle ImGuiStyle;
typedef struct ImGuiStorage ImGuiStorage;
typedef struct ImGuiSizeCallbackData ImGuiSizeCallbackData;
-typedef struct ImGuiPlatformMonitor ImGuiPlatformMonitor;
-typedef struct ImGuiPlatformIO ImGuiPlatformIO;
typedef struct ImGuiPayload ImGuiPayload;
typedef struct ImGuiOnceUponAFrame ImGuiOnceUponAFrame;
typedef struct ImGuiListClipper ImGuiListClipper;
@@ -95,24 +117,18 @@ struct ImGuiInputTextCallbackData;
struct ImGuiListClipper;
struct ImGuiOnceUponAFrame;
struct ImGuiPayload;
-struct ImGuiPlatformIO;
-struct ImGuiPlatformMonitor;
struct ImGuiSizeCallbackData;
struct ImGuiStorage;
struct ImGuiStyle;
struct ImGuiTextBuffer;
struct ImGuiTextFilter;
-struct ImGuiViewport;
-struct ImGuiWindowClass;
-typedef void* ImTextureID;
-typedef unsigned int ImGuiID;
-typedef unsigned short ImWchar;
typedef int ImGuiCol;
typedef int ImGuiCond;
typedef int ImGuiDataType;
typedef int ImGuiDir;
typedef int ImGuiKey;
typedef int ImGuiNavInput;
+typedef int ImGuiMouseButton;
typedef int ImGuiMouseCursor;
typedef int ImGuiStyleVar;
typedef int ImDrawCornerFlags;
@@ -122,19 +138,23 @@ typedef int ImGuiBackendFlags;
typedef int ImGuiColorEditFlags;
typedef int ImGuiConfigFlags;
typedef int ImGuiComboFlags;
-typedef int ImGuiDockNodeFlags;
typedef int ImGuiDragDropFlags;
typedef int ImGuiFocusedFlags;
typedef int ImGuiHoveredFlags;
typedef int ImGuiInputTextFlags;
+typedef int ImGuiKeyModFlags;
typedef int ImGuiSelectableFlags;
typedef int ImGuiTabBarFlags;
typedef int ImGuiTabItemFlags;
typedef int ImGuiTreeNodeFlags;
-typedef int ImGuiViewportFlags;
typedef int ImGuiWindowFlags;
+typedef void* ImTextureID;
+typedef unsigned int ImGuiID;
typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData *data);
typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data);
+typedef unsigned short ImWchar16;
+typedef unsigned int ImWchar32;
+typedef ImWchar16 ImWchar;
typedef signed char ImS8;
typedef unsigned char ImU8;
typedef signed short ImS16;
@@ -145,27 +165,119 @@ typedef int64_t ImS64;
typedef uint64_t ImU64;
typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* cmd);
typedef unsigned short ImDrawIdx;
+struct ImBitVector;
+struct ImRect;
+struct ImDrawDataBuilder;
+struct ImDrawListSharedData;
+struct ImGuiColorMod;
+struct ImGuiColumnData;
+struct ImGuiColumns;
+struct ImGuiContext;
+struct ImGuiDataTypeInfo;
+struct ImGuiGroupData;
+struct ImGuiInputTextState;
+struct ImGuiItemHoveredDataBackup;
+struct ImGuiMenuColumns;
+struct ImGuiNavMoveResult;
+struct ImGuiNextWindowData;
+struct ImGuiNextItemData;
+struct ImGuiPopupData;
+struct ImGuiSettingsHandler;
+struct ImGuiStyleMod;
+struct ImGuiTabBar;
+struct ImGuiTabItem;
+struct ImGuiWindow;
+struct ImGuiWindowTempData;
+struct ImGuiWindowSettings;
+typedef int ImGuiLayoutType;
+typedef int ImGuiButtonFlags;
+typedef int ImGuiColumnsFlags;
+typedef int ImGuiDragFlags;
+typedef int ImGuiItemFlags;
+typedef int ImGuiItemStatusFlags;
+typedef int ImGuiNavHighlightFlags;
+typedef int ImGuiNavDirSourceFlags;
+typedef int ImGuiNavMoveFlags;
+typedef int ImGuiNextItemDataFlags;
+typedef int ImGuiNextWindowDataFlags;
+typedef int ImGuiSeparatorFlags;
+typedef int ImGuiSliderFlags;
+typedef int ImGuiTextFlags;
+typedef int ImGuiTooltipFlags;
+extern ImGuiContext* GImGui;
+typedef FILE* ImFileHandle;
+typedef int ImPoolIdx;
typedef struct ImVector{int Size;int Capacity;void* Data;} ImVector;
typedef struct ImVector_float {int Size;int Capacity;float* Data;} ImVector_float;
typedef struct ImVector_ImWchar {int Size;int Capacity;ImWchar* Data;} ImVector_ImWchar;
typedef struct ImVector_ImDrawVert {int Size;int Capacity;ImDrawVert* Data;} ImVector_ImDrawVert;
+typedef struct ImVector_ImGuiSettingsHandler {int Size;int Capacity;ImGuiSettingsHandler* Data;} ImVector_ImGuiSettingsHandler;
+typedef struct ImVector_ImVec4 {int Size;int Capacity;ImVec4* Data;} ImVector_ImVec4;
+typedef struct ImVector_ImGuiGroupData {int Size;int Capacity;ImGuiGroupData* Data;} ImVector_ImGuiGroupData;
+typedef struct ImVector_ImGuiID {int Size;int Capacity;ImGuiID* Data;} ImVector_ImGuiID;
+typedef struct ImVector_ImGuiWindowPtr {int Size;int Capacity;ImGuiWindow** Data;} ImVector_ImGuiWindowPtr;
+typedef struct ImVector_ImGuiColumnData {int Size;int Capacity;ImGuiColumnData* Data;} ImVector_ImGuiColumnData;
+typedef struct ImVector_ImGuiColumns {int Size;int Capacity;ImGuiColumns* Data;} ImVector_ImGuiColumns;
+typedef struct ImVector_ImVec2 {int Size;int Capacity;ImVec2* Data;} ImVector_ImVec2;
typedef struct ImVector_ImFontGlyph {int Size;int Capacity;ImFontGlyph* Data;} ImVector_ImFontGlyph;
typedef struct ImVector_ImGuiTextRange {int Size;int Capacity;ImGuiTextRange* Data;} ImVector_ImGuiTextRange;
typedef struct ImVector_ImGuiStoragePair {int Size;int Capacity;ImGuiStoragePair* Data;} ImVector_ImGuiStoragePair;
+typedef struct ImVector_ImGuiStyleMod {int Size;int Capacity;ImGuiStyleMod* Data;} ImVector_ImGuiStyleMod;
typedef struct ImVector_ImDrawChannel {int Size;int Capacity;ImDrawChannel* Data;} ImVector_ImDrawChannel;
-typedef struct ImVector_char {int Size;int Capacity;char* Data;} ImVector_char;
+typedef struct ImVector_ImDrawListPtr {int Size;int Capacity;ImDrawList** Data;} ImVector_ImDrawListPtr;
typedef struct ImVector_ImU32 {int Size;int Capacity;ImU32* Data;} ImVector_ImU32;
+typedef struct ImVector_ImGuiItemFlags {int Size;int Capacity;ImGuiItemFlags* Data;} ImVector_ImGuiItemFlags;
typedef struct ImVector_ImFontAtlasCustomRect {int Size;int Capacity;ImFontAtlasCustomRect* Data;} ImVector_ImFontAtlasCustomRect;
+typedef struct ImVector_ImGuiTabItem {int Size;int Capacity;ImGuiTabItem* Data;} ImVector_ImGuiTabItem;
+typedef struct ImVector_ImGuiShrinkWidthItem {int Size;int Capacity;ImGuiShrinkWidthItem* Data;} ImVector_ImGuiShrinkWidthItem;
+typedef struct ImVector_unsigned_char {int Size;int Capacity;unsigned char* Data;} ImVector_unsigned_char;
typedef struct ImVector_ImTextureID {int Size;int Capacity;ImTextureID* Data;} ImVector_ImTextureID;
-typedef struct ImVector_ImFontConfig {int Size;int Capacity;ImFontConfig* Data;} ImVector_ImFontConfig;
-typedef struct ImVector_ImGuiPlatformMonitor {int Size;int Capacity;ImGuiPlatformMonitor* Data;} ImVector_ImGuiPlatformMonitor;
-typedef struct ImVector_ImGuiViewportPtr {int Size;int Capacity;ImGuiViewport** Data;} ImVector_ImGuiViewportPtr;
typedef struct ImVector_ImFontPtr {int Size;int Capacity;ImFont** Data;} ImVector_ImFontPtr;
+typedef struct ImVector_ImFontConfig {int Size;int Capacity;ImFontConfig* Data;} ImVector_ImFontConfig;
+typedef struct ImVector_ImGuiColorMod {int Size;int Capacity;ImGuiColorMod* Data;} ImVector_ImGuiColorMod;
typedef struct ImVector_ImDrawCmd {int Size;int Capacity;ImDrawCmd* Data;} ImVector_ImDrawCmd;
-typedef struct ImVector_ImVec4 {int Size;int Capacity;ImVec4* Data;} ImVector_ImVec4;
+typedef struct ImVector_ImGuiPtrOrIndex {int Size;int Capacity;ImGuiPtrOrIndex* Data;} ImVector_ImGuiPtrOrIndex;
+typedef struct ImVector_ImGuiPopupData {int Size;int Capacity;ImGuiPopupData* Data;} ImVector_ImGuiPopupData;
typedef struct ImVector_ImDrawIdx {int Size;int Capacity;ImDrawIdx* Data;} ImVector_ImDrawIdx;
-typedef struct ImVector_ImVec2 {int Size;int Capacity;ImVec2* Data;} ImVector_ImVec2;
+typedef struct ImVector_char {int Size;int Capacity;char* Data;} ImVector_char;
+typedef struct ImVector_ImGuiWindowSettings {int Size;int Capacity;ImGuiWindowSettings* Data;} ImVector_ImGuiWindowSettings;
+typedef struct ImChunkStream_ImGuiWindowSettings {ImVector_ImGuiWindowSettings Buf;} ImChunkStream_ImGuiWindowSettings;
+typedef struct
+{
+ int where;
+ int insert_length;
+ int delete_length;
+ int char_storage;
+} StbUndoRecord;
+typedef struct
+{
+ StbUndoRecord undo_rec [99];
+ ImWchar undo_char[999];
+ short undo_point, redo_point;
+ int undo_char_point, redo_char_point;
+} StbUndoState;
+typedef struct
+{
+ int cursor;
+ int select_start;
+ int select_end;
+ unsigned char insert_mode;
+ unsigned char cursor_at_end_of_line;
+ unsigned char initialized;
+ unsigned char has_preferred_x;
+ unsigned char single_line;
+ unsigned char padding1, padding2, padding3;
+ float preferred_x;
+ StbUndoState undostate;
+} STB_TexteditState;
+typedef struct
+{
+ float x0,x1;
+ float baseline_y_delta;
+ float ymin,ymax;
+ int num_chars;
+} StbTexteditRow;
struct ImVec2
{
float x, y;
@@ -196,7 +308,6 @@ typedef enum {
ImGuiWindowFlags_NoNavInputs = 1 << 18,
ImGuiWindowFlags_NoNavFocus = 1 << 19,
ImGuiWindowFlags_UnsavedDocument = 1 << 20,
- ImGuiWindowFlags_NoDocking = 1 << 21,
ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse,
ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
@@ -205,8 +316,7 @@ typedef enum {
ImGuiWindowFlags_Tooltip = 1 << 25,
ImGuiWindowFlags_Popup = 1 << 26,
ImGuiWindowFlags_Modal = 1 << 27,
- ImGuiWindowFlags_ChildMenu = 1 << 28,
- ImGuiWindowFlags_DockNodeHost = 1 << 29
+ ImGuiWindowFlags_ChildMenu = 1 << 28
}ImGuiWindowFlags_;
typedef enum {
ImGuiInputTextFlags_None = 0,
@@ -308,15 +418,6 @@ typedef enum {
ImGuiHoveredFlags_RectOnly = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped,
ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows
}ImGuiHoveredFlags_;
-typedef enum {
- ImGuiDockNodeFlags_None = 0,
- ImGuiDockNodeFlags_KeepAliveOnly = 1 << 0,
- ImGuiDockNodeFlags_NoDockingInCentralNode = 1 << 2,
- ImGuiDockNodeFlags_PassthruCentralNode = 1 << 3,
- ImGuiDockNodeFlags_NoSplit = 1 << 4,
- ImGuiDockNodeFlags_NoResize = 1 << 5,
- ImGuiDockNodeFlags_AutoHideTabBar = 1 << 6
-}ImGuiDockNodeFlags_;
typedef enum {
ImGuiDragDropFlags_None = 0,
ImGuiDragDropFlags_SourceNoPreviewTooltip = 1 << 0,
@@ -376,6 +477,13 @@ typedef enum {
ImGuiKey_Z,
ImGuiKey_COUNT
}ImGuiKey_;
+typedef enum {
+ ImGuiKeyModFlags_None = 0,
+ ImGuiKeyModFlags_Ctrl = 1 << 0,
+ ImGuiKeyModFlags_Shift = 1 << 1,
+ ImGuiKeyModFlags_Alt = 1 << 2,
+ ImGuiKeyModFlags_Super = 1 << 3
+}ImGuiKeyModFlags_;
typedef enum {
ImGuiNavInput_Activate,
ImGuiNavInput_Cancel,
@@ -409,10 +517,6 @@ typedef enum {
ImGuiConfigFlags_NavNoCaptureKeyboard = 1 << 3,
ImGuiConfigFlags_NoMouse = 1 << 4,
ImGuiConfigFlags_NoMouseCursorChange = 1 << 5,
- ImGuiConfigFlags_DockingEnable = 1 << 6,
- ImGuiConfigFlags_ViewportsEnable = 1 << 10,
- ImGuiConfigFlags_DpiEnableScaleViewports= 1 << 14,
- ImGuiConfigFlags_DpiEnableScaleFonts = 1 << 15,
ImGuiConfigFlags_IsSRGB = 1 << 20,
ImGuiConfigFlags_IsTouchScreen = 1 << 21
}ImGuiConfigFlags_;
@@ -421,10 +525,7 @@ typedef enum {
ImGuiBackendFlags_HasGamepad = 1 << 0,
ImGuiBackendFlags_HasMouseCursors = 1 << 1,
ImGuiBackendFlags_HasSetMousePos = 1 << 2,
- ImGuiBackendFlags_RendererHasVtxOffset = 1 << 3,
- ImGuiBackendFlags_PlatformHasViewports = 1 << 10,
- ImGuiBackendFlags_HasMouseHoveredViewport=1 << 11,
- ImGuiBackendFlags_RendererHasViewports = 1 << 12
+ ImGuiBackendFlags_RendererHasVtxOffset = 1 << 3
}ImGuiBackendFlags_;
typedef enum {
ImGuiCol_Text,
@@ -465,8 +566,6 @@ typedef enum {
ImGuiCol_TabActive,
ImGuiCol_TabUnfocused,
ImGuiCol_TabUnfocusedActive,
- ImGuiCol_DockingPreview,
- ImGuiCol_DockingEmptyBg,
ImGuiCol_PlotLines,
ImGuiCol_PlotLinesHovered,
ImGuiCol_PlotHistogram,
@@ -516,6 +615,7 @@ typedef enum {
ImGuiColorEditFlags_NoLabel = 1 << 7,
ImGuiColorEditFlags_NoSidePreview = 1 << 8,
ImGuiColorEditFlags_NoDragDrop = 1 << 9,
+ ImGuiColorEditFlags_NoBorder = 1 << 10,
ImGuiColorEditFlags_AlphaBar = 1 << 16,
ImGuiColorEditFlags_AlphaPreview = 1 << 17,
ImGuiColorEditFlags_AlphaPreviewHalf= 1 << 18,
@@ -535,6 +635,12 @@ typedef enum {
ImGuiColorEditFlags__PickerMask = ImGuiColorEditFlags_PickerHueWheel|ImGuiColorEditFlags_PickerHueBar,
ImGuiColorEditFlags__InputMask = ImGuiColorEditFlags_InputRGB|ImGuiColorEditFlags_InputHSV
}ImGuiColorEditFlags_;
+typedef enum {
+ ImGuiMouseButton_Left = 0,
+ ImGuiMouseButton_Right = 1,
+ ImGuiMouseButton_Middle = 2,
+ ImGuiMouseButton_COUNT = 5
+}ImGuiMouseButton_;
typedef enum {
ImGuiMouseCursor_None = -1,
ImGuiMouseCursor_Arrow = 0,
@@ -545,6 +651,7 @@ typedef enum {
ImGuiMouseCursor_ResizeNESW,
ImGuiMouseCursor_ResizeNWSE,
ImGuiMouseCursor_Hand,
+ ImGuiMouseCursor_NotAllowed,
ImGuiMouseCursor_COUNT
}ImGuiMouseCursor_;
typedef enum {
@@ -589,6 +696,7 @@ struct ImGuiStyle
bool AntiAliasedLines;
bool AntiAliasedFill;
float CurveTessellationTol;
+ float CircleSegmentMaxError;
ImVec4 Colors[ImGuiCol_COUNT];
};
struct ImGuiIO
@@ -612,14 +720,6 @@ struct ImGuiIO
bool FontAllowUserScaling;
ImFont* FontDefault;
ImVec2 DisplayFramebufferScale;
- bool ConfigDockingNoSplit;
- bool ConfigDockingWithShift;
- bool ConfigDockingAlwaysTabBar;
- bool ConfigDockingTransparentPayload;
- bool ConfigViewportsNoAutoMerge;
- bool ConfigViewportsNoTaskBarIcon;
- bool ConfigViewportsNoDecoration;
- bool ConfigViewportsNoDefaultParent;
bool MouseDrawCursor;
bool ConfigMacOSXBehaviors;
bool ConfigInputTextCursorBlink;
@@ -634,12 +734,13 @@ struct ImGuiIO
const char* (*GetClipboardTextFn)(void* user_data);
void (*SetClipboardTextFn)(void* user_data, const char* text);
void* ClipboardUserData;
+ void (*ImeSetInputScreenPosFn)(int x, int y);
+ void* ImeWindowHandle;
void* RenderDrawListsFnUnused;
ImVec2 MousePos;
bool MouseDown[5];
float MouseWheel;
float MouseWheelH;
- ImGuiID MouseHoveredViewport;
bool KeyCtrl;
bool KeyShift;
bool KeyAlt;
@@ -660,6 +761,7 @@ struct ImGuiIO
int MetricsActiveWindows;
int MetricsActiveAllocations;
ImVec2 MouseDelta;
+ ImGuiKeyModFlags KeyMods;
ImVec2 MousePosPrev;
ImVec2 MouseClickedPos[5];
double MouseClickedTime[5];
@@ -676,6 +778,7 @@ struct ImGuiIO
float KeysDownDurationPrev[512];
float NavInputsDownDuration[ImGuiNavInput_COUNT];
float NavInputsDownDurationPrev[ImGuiNavInput_COUNT];
+ ImWchar16 InputQueueSurrogate;
ImVector_ImWchar InputQueueCharacters;
};
struct ImGuiInputTextCallbackData
@@ -700,15 +803,6 @@ struct ImGuiSizeCallbackData
ImVec2 CurrentSize;
ImVec2 DesiredSize;
};
-struct ImGuiWindowClass
-{
- ImGuiID ClassId;
- ImGuiID ParentViewportId;
- ImGuiViewportFlags ViewportFlagsOverrideSet;
- ImGuiViewportFlags ViewportFlagsOverrideClear;
- bool DockingAlwaysTabBar;
- bool DockingAllowUnclassed;
-};
struct ImGuiPayload
{
void* Data;
@@ -738,11 +832,15 @@ struct ImGuiStorage
{
ImVector_ImGuiStoragePair Data;
};
+typedef struct ImVector_ImGuiTabBar {int Size;int Capacity;ImGuiTabBar* Data;} ImVector_ImGuiTabBar;
+typedef struct ImPool_ImGuiTabBar {ImVector_ImGuiTabBar Buf;ImGuiStorage Map;ImPoolIdx FreeIdx;} ImPool_ImGuiTabBar;
struct ImGuiListClipper
{
- float StartPosY;
+ int DisplayStart, DisplayEnd;
+ int ItemsCount;
+ int StepNo;
float ItemsHeight;
- int ItemsCount, StepNo, DisplayStart, DisplayEnd;
+ float StartPosY;
};
struct ImColor
{
@@ -820,7 +918,6 @@ struct ImDrawData
ImVec2 DisplayPos;
ImVec2 DisplaySize;
ImVec2 FramebufferScale;
- ImGuiViewport* OwnerViewport;
};
struct ImFontConfig
{
@@ -846,7 +943,8 @@ struct ImFontConfig
};
struct ImFontGlyph
{
- ImWchar Codepoint;
+ unsigned int Codepoint : 31;
+ unsigned int Visible : 1;
float AdvanceX;
float X0, Y0, X1, Y1;
float U0, V0, U1, V1;
@@ -901,84 +999,730 @@ struct ImFont
short ConfigDataCount;
ImWchar FallbackChar;
ImWchar EllipsisChar;
+ bool DirtyLookupTables;
float Scale;
float Ascent, Descent;
int MetricsTotalSurface;
- bool DirtyLookupTables;
+ ImU8 Used4kPagesMap[(0xFFFF +1)/4096/8];
+};
+struct ImBitVector
+{
+ ImVector_ImU32 Storage;
+};
+typedef enum {
+ ImGuiButtonFlags_None = 0,
+ ImGuiButtonFlags_Repeat = 1 << 0,
+ ImGuiButtonFlags_PressedOnClick = 1 << 1,
+ ImGuiButtonFlags_PressedOnClickRelease = 1 << 2,
+ ImGuiButtonFlags_PressedOnClickReleaseAnywhere = 1 << 3,
+ ImGuiButtonFlags_PressedOnRelease = 1 << 4,
+ ImGuiButtonFlags_PressedOnDoubleClick = 1 << 5,
+ ImGuiButtonFlags_PressedOnDragDropHold = 1 << 6,
+ ImGuiButtonFlags_FlattenChildren = 1 << 7,
+ ImGuiButtonFlags_AllowItemOverlap = 1 << 8,
+ ImGuiButtonFlags_DontClosePopups = 1 << 9,
+ ImGuiButtonFlags_Disabled = 1 << 10,
+ ImGuiButtonFlags_AlignTextBaseLine = 1 << 11,
+ ImGuiButtonFlags_NoKeyModifiers = 1 << 12,
+ ImGuiButtonFlags_NoHoldingActiveId = 1 << 13,
+ ImGuiButtonFlags_NoNavFocus = 1 << 14,
+ ImGuiButtonFlags_NoHoveredOnFocus = 1 << 15,
+ ImGuiButtonFlags_MouseButtonLeft = 1 << 16,
+ ImGuiButtonFlags_MouseButtonRight = 1 << 17,
+ ImGuiButtonFlags_MouseButtonMiddle = 1 << 18,
+ ImGuiButtonFlags_MouseButtonMask_ = ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight | ImGuiButtonFlags_MouseButtonMiddle,
+ ImGuiButtonFlags_MouseButtonShift_ = 16,
+ ImGuiButtonFlags_MouseButtonDefault_ = ImGuiButtonFlags_MouseButtonLeft,
+ ImGuiButtonFlags_PressedOnMask_ = ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_PressedOnDragDropHold,
+ ImGuiButtonFlags_PressedOnDefault_ = ImGuiButtonFlags_PressedOnClickRelease
+}ImGuiButtonFlags_;
+typedef enum {
+ ImGuiSliderFlags_None = 0,
+ ImGuiSliderFlags_Vertical = 1 << 0
+}ImGuiSliderFlags_;
+typedef enum {
+ ImGuiDragFlags_None = 0,
+ ImGuiDragFlags_Vertical = 1 << 0
+}ImGuiDragFlags_;
+typedef enum {
+ ImGuiColumnsFlags_None = 0,
+ ImGuiColumnsFlags_NoBorder = 1 << 0,
+ ImGuiColumnsFlags_NoResize = 1 << 1,
+ ImGuiColumnsFlags_NoPreserveWidths = 1 << 2,
+ ImGuiColumnsFlags_NoForceWithinWindow = 1 << 3,
+ ImGuiColumnsFlags_GrowParentContentsSize= 1 << 4
+}ImGuiColumnsFlags_;
+typedef enum {
+ ImGuiSelectableFlags_NoHoldingActiveID = 1 << 20,
+ ImGuiSelectableFlags_SelectOnClick = 1 << 21,
+ ImGuiSelectableFlags_SelectOnRelease = 1 << 22,
+ ImGuiSelectableFlags_SpanAvailWidth = 1 << 23,
+ ImGuiSelectableFlags_DrawHoveredWhenHeld= 1 << 24,
+ ImGuiSelectableFlags_SetNavIdOnHover = 1 << 25
+}ImGuiSelectableFlagsPrivate_;
+typedef enum {
+ ImGuiTreeNodeFlags_ClipLabelForTrailingButton = 1 << 20
+}ImGuiTreeNodeFlagsPrivate_;
+typedef enum {
+ ImGuiSeparatorFlags_None = 0,
+ ImGuiSeparatorFlags_Horizontal = 1 << 0,
+ ImGuiSeparatorFlags_Vertical = 1 << 1,
+ ImGuiSeparatorFlags_SpanAllColumns = 1 << 2
+}ImGuiSeparatorFlags_;
+typedef enum {
+ ImGuiItemFlags_None = 0,
+ ImGuiItemFlags_NoTabStop = 1 << 0,
+ ImGuiItemFlags_ButtonRepeat = 1 << 1,
+ ImGuiItemFlags_Disabled = 1 << 2,
+ ImGuiItemFlags_NoNav = 1 << 3,
+ ImGuiItemFlags_NoNavDefaultFocus = 1 << 4,
+ ImGuiItemFlags_SelectableDontClosePopup = 1 << 5,
+ ImGuiItemFlags_MixedValue = 1 << 6,
+ ImGuiItemFlags_Default_ = 0
+}ImGuiItemFlags_;
+typedef enum {
+ ImGuiItemStatusFlags_None = 0,
+ ImGuiItemStatusFlags_HoveredRect = 1 << 0,
+ ImGuiItemStatusFlags_HasDisplayRect = 1 << 1,
+ ImGuiItemStatusFlags_Edited = 1 << 2,
+ ImGuiItemStatusFlags_ToggledSelection = 1 << 3,
+ ImGuiItemStatusFlags_ToggledOpen = 1 << 4,
+ ImGuiItemStatusFlags_HasDeactivated = 1 << 5,
+ ImGuiItemStatusFlags_Deactivated = 1 << 6
+}ImGuiItemStatusFlags_;
+typedef enum {
+ ImGuiTextFlags_None = 0,
+ ImGuiTextFlags_NoWidthForLargeClippedText = 1 << 0
+}ImGuiTextFlags_;
+typedef enum {
+ ImGuiTooltipFlags_None = 0,
+ ImGuiTooltipFlags_OverridePreviousTooltip = 1 << 0
+}ImGuiTooltipFlags_;
+typedef enum {
+ ImGuiLayoutType_Horizontal = 0,
+ ImGuiLayoutType_Vertical = 1
+}ImGuiLayoutType_;
+typedef enum {
+ ImGuiLogType_None = 0,
+ ImGuiLogType_TTY,
+ ImGuiLogType_File,
+ ImGuiLogType_Buffer,
+ ImGuiLogType_Clipboard
+}ImGuiLogType;
+typedef enum {
+ ImGuiAxis_None = -1,
+ ImGuiAxis_X = 0,
+ ImGuiAxis_Y = 1
+}ImGuiAxis;
+typedef enum {
+ ImGuiPlotType_Lines,
+ ImGuiPlotType_Histogram
+}ImGuiPlotType;
+typedef enum {
+ ImGuiInputSource_None = 0,
+ ImGuiInputSource_Mouse,
+ ImGuiInputSource_Nav,
+ ImGuiInputSource_NavKeyboard,
+ ImGuiInputSource_NavGamepad,
+ ImGuiInputSource_COUNT
+}ImGuiInputSource;
+typedef enum {
+ ImGuiInputReadMode_Down,
+ ImGuiInputReadMode_Pressed,
+ ImGuiInputReadMode_Released,
+ ImGuiInputReadMode_Repeat,
+ ImGuiInputReadMode_RepeatSlow,
+ ImGuiInputReadMode_RepeatFast
+}ImGuiInputReadMode;
+typedef enum {
+ ImGuiNavHighlightFlags_None = 0,
+ ImGuiNavHighlightFlags_TypeDefault = 1 << 0,
+ ImGuiNavHighlightFlags_TypeThin = 1 << 1,
+ ImGuiNavHighlightFlags_AlwaysDraw = 1 << 2,
+ ImGuiNavHighlightFlags_NoRounding = 1 << 3
+}ImGuiNavHighlightFlags_;
+typedef enum {
+ ImGuiNavDirSourceFlags_None = 0,
+ ImGuiNavDirSourceFlags_Keyboard = 1 << 0,
+ ImGuiNavDirSourceFlags_PadDPad = 1 << 1,
+ ImGuiNavDirSourceFlags_PadLStick = 1 << 2
+}ImGuiNavDirSourceFlags_;
+typedef enum {
+ ImGuiNavMoveFlags_None = 0,
+ ImGuiNavMoveFlags_LoopX = 1 << 0,
+ ImGuiNavMoveFlags_LoopY = 1 << 1,
+ ImGuiNavMoveFlags_WrapX = 1 << 2,
+ ImGuiNavMoveFlags_WrapY = 1 << 3,
+ ImGuiNavMoveFlags_AllowCurrentNavId = 1 << 4,
+ ImGuiNavMoveFlags_AlsoScoreVisibleSet = 1 << 5,
+ ImGuiNavMoveFlags_ScrollToEdge = 1 << 6
+}ImGuiNavMoveFlags_;
+typedef enum {
+ ImGuiNavForward_None,
+ ImGuiNavForward_ForwardQueued,
+ ImGuiNavForward_ForwardActive
+}ImGuiNavForward;
+typedef enum {
+ ImGuiNavLayer_Main = 0,
+ ImGuiNavLayer_Menu = 1,
+ ImGuiNavLayer_COUNT
+}ImGuiNavLayer;
+typedef enum {
+ ImGuiPopupPositionPolicy_Default,
+ ImGuiPopupPositionPolicy_ComboBox
+}ImGuiPopupPositionPolicy;
+struct ImVec1
+{
+ float x;
+};
+struct ImVec2ih
+{
+ short x, y;
+};
+struct ImRect
+{
+ ImVec2 Min;
+ ImVec2 Max;
+};
+struct ImGuiDataTypeInfo
+{
+ size_t Size;
+ const char* PrintFmt;
+ const char* ScanFmt;
+};
+struct ImGuiColorMod
+{
+ ImGuiCol Col;
+ ImVec4 BackupValue;
+};
+struct ImGuiStyleMod
+{
+ ImGuiStyleVar VarIdx;
+ union { int BackupInt[2]; float BackupFloat[2]; };
+};
+struct ImGuiGroupData
+{
+ ImVec2 BackupCursorPos;
+ ImVec2 BackupCursorMaxPos;
+ ImVec1 BackupIndent;
+ ImVec1 BackupGroupOffset;
+ ImVec2 BackupCurrLineSize;
+ float BackupCurrLineTextBaseOffset;
+ ImGuiID BackupActiveIdIsAlive;
+ bool BackupActiveIdPreviousFrameIsAlive;
+ bool EmitItem;
+};
+struct ImGuiMenuColumns
+{
+ float Spacing;
+ float Width, NextWidth;
+ float Pos[3], NextWidths[3];
+};
+struct ImGuiInputTextState
+{
+ ImGuiID ID;
+ int CurLenW, CurLenA;
+ ImVector_ImWchar TextW;
+ ImVector_char TextA;
+ ImVector_char InitialTextA;
+ bool TextAIsValid;
+ int BufCapacityA;
+ float ScrollX;
+ STB_TexteditState Stb;
+ float CursorAnim;
+ bool CursorFollow;
+ bool SelectedAllMouseLock;
+ ImGuiInputTextFlags UserFlags;
+ ImGuiInputTextCallback UserCallback;
+ void* UserCallbackData;
};
-struct ImGuiPlatformMonitor
+struct ImGuiWindowSettings
{
- ImVec2 MainPos, MainSize;
- ImVec2 WorkPos, WorkSize;
- float DpiScale;
+ ImGuiID ID;
+ ImVec2ih Pos;
+ ImVec2ih Size;
+ bool Collapsed;
+};
+struct ImGuiSettingsHandler
+{
+ const char* TypeName;
+ ImGuiID TypeHash;
+ void* (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name);
+ void (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line);
+ void (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf);
+ void* UserData;
+};
+struct ImGuiPopupData
+{
+ ImGuiID PopupId;
+ ImGuiWindow* Window;
+ ImGuiWindow* SourceWindow;
+ int OpenFrameCount;
+ ImGuiID OpenParentId;
+ ImVec2 OpenPopupPos;
+ ImVec2 OpenMousePos;
+};
+struct ImGuiColumnData
+{
+ float OffsetNorm;
+ float OffsetNormBeforeResize;
+ ImGuiColumnsFlags Flags;
+ ImRect ClipRect;
+};
+struct ImGuiColumns
+{
+ ImGuiID ID;
+ ImGuiColumnsFlags Flags;
+ bool IsFirstFrame;
+ bool IsBeingResized;
+ int Current;
+ int Count;
+ float OffMinX, OffMaxX;
+ float LineMinY, LineMaxY;
+ float HostCursorPosY;
+ float HostCursorMaxPosX;
+ ImRect HostClipRect;
+ ImRect HostWorkRect;
+ ImVector_ImGuiColumnData Columns;
+ ImDrawListSplitter Splitter;
+};
+struct ImDrawListSharedData
+{
+ ImVec2 TexUvWhitePixel;
+ ImFont* Font;
+ float FontSize;
+ float CurveTessellationTol;
+ float CircleSegmentMaxError;
+ ImVec4 ClipRectFullscreen;
+ ImDrawListFlags InitialFlags;
+ ImVec2 ArcFastVtx[12 * 1];
+ ImU8 CircleSegmentCounts[64];
+};
+struct ImDrawDataBuilder
+{
+ ImVector_ImDrawListPtr Layers[2];
};
-struct ImGuiPlatformIO
+struct ImGuiNavMoveResult
{
- void (*Platform_CreateWindow)(ImGuiViewport* vp);
- void (*Platform_DestroyWindow)(ImGuiViewport* vp);
- void (*Platform_ShowWindow)(ImGuiViewport* vp);
- void (*Platform_SetWindowPos)(ImGuiViewport* vp, ImVec2 pos);
- ImVec2 (*Platform_GetWindowPos)(ImGuiViewport* vp);
- void (*Platform_SetWindowSize)(ImGuiViewport* vp, ImVec2 size);
- ImVec2 (*Platform_GetWindowSize)(ImGuiViewport* vp);
- void (*Platform_SetWindowFocus)(ImGuiViewport* vp);
- bool (*Platform_GetWindowFocus)(ImGuiViewport* vp);
- bool (*Platform_GetWindowMinimized)(ImGuiViewport* vp);
- void (*Platform_SetWindowTitle)(ImGuiViewport* vp, const char* title);
- void (*Platform_SetWindowAlpha)(ImGuiViewport* vp, float alpha);
- void (*Platform_UpdateWindow)(ImGuiViewport* vp);
- void (*Platform_RenderWindow)(ImGuiViewport* vp, void* render_arg);
- void (*Platform_SwapBuffers)(ImGuiViewport* vp, void* render_arg);
- float (*Platform_GetWindowDpiScale)(ImGuiViewport* vp);
- void (*Platform_OnChangedViewport)(ImGuiViewport* vp);
- void (*Platform_SetImeInputPos)(ImGuiViewport* vp, ImVec2 pos);
- int (*Platform_CreateVkSurface)(ImGuiViewport* vp, ImU64 vk_inst, const void* vk_allocators, ImU64* out_vk_surface);
- void (*Renderer_CreateWindow)(ImGuiViewport* vp);
- void (*Renderer_DestroyWindow)(ImGuiViewport* vp);
- void (*Renderer_SetWindowSize)(ImGuiViewport* vp, ImVec2 size);
- void (*Renderer_RenderWindow)(ImGuiViewport* vp, void* render_arg);
- void (*Renderer_SwapBuffers)(ImGuiViewport* vp, void* render_arg);
- ImVector_ImGuiPlatformMonitor Monitors;
- ImGuiViewport* MainViewport;
- ImVector_ImGuiViewportPtr Viewports;
+ ImGuiWindow* Window;
+ ImGuiID ID;
+ ImGuiID FocusScopeId;
+ float DistBox;
+ float DistCenter;
+ float DistAxial;
+ ImRect RectRel;
};
typedef enum {
- ImGuiViewportFlags_None = 0,
- ImGuiViewportFlags_NoDecoration = 1 << 0,
- ImGuiViewportFlags_NoTaskBarIcon = 1 << 1,
- ImGuiViewportFlags_NoFocusOnAppearing = 1 << 2,
- ImGuiViewportFlags_NoFocusOnClick = 1 << 3,
- ImGuiViewportFlags_NoInputs = 1 << 4,
- ImGuiViewportFlags_NoRendererClear = 1 << 5,
- ImGuiViewportFlags_TopMost = 1 << 6,
- ImGuiViewportFlags_Minimized = 1 << 7,
- ImGuiViewportFlags_NoAutoMerge = 1 << 8,
- ImGuiViewportFlags_CanHostOtherWindows = 1 << 9
-}ImGuiViewportFlags_;
-struct ImGuiViewport
+ ImGuiNextWindowDataFlags_None = 0,
+ ImGuiNextWindowDataFlags_HasPos = 1 << 0,
+ ImGuiNextWindowDataFlags_HasSize = 1 << 1,
+ ImGuiNextWindowDataFlags_HasContentSize = 1 << 2,
+ ImGuiNextWindowDataFlags_HasCollapsed = 1 << 3,
+ ImGuiNextWindowDataFlags_HasSizeConstraint = 1 << 4,
+ ImGuiNextWindowDataFlags_HasFocus = 1 << 5,
+ ImGuiNextWindowDataFlags_HasBgAlpha = 1 << 6
+}ImGuiNextWindowDataFlags_;
+struct ImGuiNextWindowData
+{
+ ImGuiNextWindowDataFlags Flags;
+ ImGuiCond PosCond;
+ ImGuiCond SizeCond;
+ ImGuiCond CollapsedCond;
+ ImVec2 PosVal;
+ ImVec2 PosPivotVal;
+ ImVec2 SizeVal;
+ ImVec2 ContentSizeVal;
+ bool CollapsedVal;
+ ImRect SizeConstraintRect;
+ ImGuiSizeCallback SizeCallback;
+ void* SizeCallbackUserData;
+ float BgAlphaVal;
+ ImVec2 MenuBarOffsetMinVal;
+};
+typedef enum {
+ ImGuiNextItemDataFlags_None = 0,
+ ImGuiNextItemDataFlags_HasWidth = 1 << 0,
+ ImGuiNextItemDataFlags_HasOpen = 1 << 1
+}ImGuiNextItemDataFlags_;
+struct ImGuiNextItemData
+{
+ ImGuiNextItemDataFlags Flags;
+ float Width;
+ ImGuiID FocusScopeId;
+ ImGuiCond OpenCond;
+ bool OpenVal;
+};
+struct ImGuiShrinkWidthItem
+{
+ int Index;
+ float Width;
+};
+struct ImGuiPtrOrIndex
+{
+ void* Ptr;
+ int Index;
+};
+struct ImGuiContext
{
+ bool Initialized;
+ bool FontAtlasOwnedByContext;
+ ImGuiIO IO;
+ ImGuiStyle Style;
+ ImFont* Font;
+ float FontSize;
+ float FontBaseSize;
+ ImDrawListSharedData DrawListSharedData;
+ double Time;
+ int FrameCount;
+ int FrameCountEnded;
+ int FrameCountRendered;
+ bool WithinFrameScope;
+ bool WithinFrameScopeWithImplicitWindow;
+ bool WithinEndChild;
+ ImVector_ImGuiWindowPtr Windows;
+ ImVector_ImGuiWindowPtr WindowsFocusOrder;
+ ImVector_ImGuiWindowPtr WindowsTempSortBuffer;
+ ImVector_ImGuiWindowPtr CurrentWindowStack;
+ ImGuiStorage WindowsById;
+ int WindowsActiveCount;
+ ImGuiWindow* CurrentWindow;
+ ImGuiWindow* HoveredWindow;
+ ImGuiWindow* HoveredRootWindow;
+ ImGuiWindow* MovingWindow;
+ ImGuiWindow* WheelingWindow;
+ ImVec2 WheelingWindowRefMousePos;
+ float WheelingWindowTimer;
+ ImGuiID HoveredId;
+ bool HoveredIdAllowOverlap;
+ ImGuiID HoveredIdPreviousFrame;
+ float HoveredIdTimer;
+ float HoveredIdNotActiveTimer;
+ ImGuiID ActiveId;
+ ImGuiID ActiveIdIsAlive;
+ float ActiveIdTimer;
+ bool ActiveIdIsJustActivated;
+ bool ActiveIdAllowOverlap;
+ bool ActiveIdHasBeenPressedBefore;
+ bool ActiveIdHasBeenEditedBefore;
+ bool ActiveIdHasBeenEditedThisFrame;
+ ImU32 ActiveIdUsingNavDirMask;
+ ImU32 ActiveIdUsingNavInputMask;
+ ImU64 ActiveIdUsingKeyInputMask;
+ ImVec2 ActiveIdClickOffset;
+ ImGuiWindow* ActiveIdWindow;
+ ImGuiInputSource ActiveIdSource;
+ int ActiveIdMouseButton;
+ ImGuiID ActiveIdPreviousFrame;
+ bool ActiveIdPreviousFrameIsAlive;
+ bool ActiveIdPreviousFrameHasBeenEditedBefore;
+ ImGuiWindow* ActiveIdPreviousFrameWindow;
+ ImGuiID LastActiveId;
+ float LastActiveIdTimer;
+ ImGuiNextWindowData NextWindowData;
+ ImGuiNextItemData NextItemData;
+ ImVector_ImGuiColorMod ColorModifiers;
+ ImVector_ImGuiStyleMod StyleModifiers;
+ ImVector_ImFontPtr FontStack;
+ ImVector_ImGuiPopupData OpenPopupStack;
+ ImVector_ImGuiPopupData BeginPopupStack;
+ ImGuiWindow* NavWindow;
+ ImGuiID NavId;
+ ImGuiID NavFocusScopeId;
+ ImGuiID NavActivateId;
+ ImGuiID NavActivateDownId;
+ ImGuiID NavActivatePressedId;
+ ImGuiID NavInputId;
+ ImGuiID NavJustTabbedId;
+ ImGuiID NavJustMovedToId;
+ ImGuiID NavJustMovedToFocusScopeId;
+ ImGuiKeyModFlags NavJustMovedToKeyMods;
+ ImGuiID NavNextActivateId;
+ ImGuiInputSource NavInputSource;
+ ImRect NavScoringRect;
+ int NavScoringCount;
+ ImGuiNavLayer NavLayer;
+ int NavIdTabCounter;
+ bool NavIdIsAlive;
+ bool NavMousePosDirty;
+ bool NavDisableHighlight;
+ bool NavDisableMouseHover;
+ bool NavAnyRequest;
+ bool NavInitRequest;
+ bool NavInitRequestFromMove;
+ ImGuiID NavInitResultId;
+ ImRect NavInitResultRectRel;
+ bool NavMoveFromClampedRefRect;
+ bool NavMoveRequest;
+ ImGuiNavMoveFlags NavMoveRequestFlags;
+ ImGuiNavForward NavMoveRequestForward;
+ ImGuiKeyModFlags NavMoveRequestKeyMods;
+ ImGuiDir NavMoveDir, NavMoveDirLast;
+ ImGuiDir NavMoveClipDir;
+ ImGuiNavMoveResult NavMoveResultLocal;
+ ImGuiNavMoveResult NavMoveResultLocalVisibleSet;
+ ImGuiNavMoveResult NavMoveResultOther;
+ ImGuiWindow* NavWindowingTarget;
+ ImGuiWindow* NavWindowingTargetAnim;
+ ImGuiWindow* NavWindowingList;
+ float NavWindowingTimer;
+ float NavWindowingHighlightAlpha;
+ bool NavWindowingToggleLayer;
+ ImGuiWindow* FocusRequestCurrWindow;
+ ImGuiWindow* FocusRequestNextWindow;
+ int FocusRequestCurrCounterRegular;
+ int FocusRequestCurrCounterTabStop;
+ int FocusRequestNextCounterRegular;
+ int FocusRequestNextCounterTabStop;
+ bool FocusTabPressed;
+ ImDrawData DrawData;
+ ImDrawDataBuilder DrawDataBuilder;
+ float DimBgRatio;
+ ImDrawList BackgroundDrawList;
+ ImDrawList ForegroundDrawList;
+ ImGuiMouseCursor MouseCursor;
+ bool DragDropActive;
+ bool DragDropWithinSource;
+ bool DragDropWithinTarget;
+ ImGuiDragDropFlags DragDropSourceFlags;
+ int DragDropSourceFrameCount;
+ int DragDropMouseButton;
+ ImGuiPayload DragDropPayload;
+ ImRect DragDropTargetRect;
+ ImGuiID DragDropTargetId;
+ ImGuiDragDropFlags DragDropAcceptFlags;
+ float DragDropAcceptIdCurrRectSurface;
+ ImGuiID DragDropAcceptIdCurr;
+ ImGuiID DragDropAcceptIdPrev;
+ int DragDropAcceptFrameCount;
+ ImVector_unsigned_char DragDropPayloadBufHeap;
+ unsigned char DragDropPayloadBufLocal[16];
+ ImGuiTabBar* CurrentTabBar;
+ ImPool_ImGuiTabBar TabBars;
+ ImVector_ImGuiPtrOrIndex CurrentTabBarStack;
+ ImVector_ImGuiShrinkWidthItem ShrinkWidthBuffer;
+ ImVec2 LastValidMousePos;
+ ImGuiInputTextState InputTextState;
+ ImFont InputTextPasswordFont;
+ ImGuiID TempInputId;
+ ImGuiColorEditFlags ColorEditOptions;
+ float ColorEditLastHue;
+ float ColorEditLastSat;
+ float ColorEditLastColor[3];
+ ImVec4 ColorPickerRef;
+ bool DragCurrentAccumDirty;
+ float DragCurrentAccum;
+ float DragSpeedDefaultRatio;
+ float ScrollbarClickDeltaToGrabCenter;
+ int TooltipOverrideCount;
+ ImVector_char ClipboardHandlerData;
+ ImVector_ImGuiID MenusIdSubmittedThisFrame;
+ ImVec2 PlatformImePos;
+ ImVec2 PlatformImeLastPos;
+ bool SettingsLoaded;
+ float SettingsDirtyTimer;
+ ImGuiTextBuffer SettingsIniData;
+ ImVector_ImGuiSettingsHandler SettingsHandlers;
+ ImChunkStream_ImGuiWindowSettings SettingsWindows;
+ bool LogEnabled;
+ ImGuiLogType LogType;
+ ImFileHandle LogFile;
+ ImGuiTextBuffer LogBuffer;
+ float LogLinePosY;
+ bool LogLineFirstItem;
+ int LogDepthRef;
+ int LogDepthToExpand;
+ int LogDepthToExpandDefault;
+ bool DebugItemPickerActive;
+ ImGuiID DebugItemPickerBreakId;
+ float FramerateSecPerFrame[120];
+ int FramerateSecPerFrameIdx;
+ float FramerateSecPerFrameAccum;
+ int WantCaptureMouseNextFrame;
+ int WantCaptureKeyboardNextFrame;
+ int WantTextInputNextFrame;
+ char TempBuffer[1024*3+1];
+};
+struct ImGuiWindowTempData
+{
+ ImVec2 CursorPos;
+ ImVec2 CursorPosPrevLine;
+ ImVec2 CursorStartPos;
+ ImVec2 CursorMaxPos;
+ ImVec2 CurrLineSize;
+ ImVec2 PrevLineSize;
+ float CurrLineTextBaseOffset;
+ float PrevLineTextBaseOffset;
+ ImVec1 Indent;
+ ImVec1 ColumnsOffset;
+ ImVec1 GroupOffset;
+ ImGuiID LastItemId;
+ ImGuiItemStatusFlags LastItemStatusFlags;
+ ImRect LastItemRect;
+ ImRect LastItemDisplayRect;
+ ImGuiNavLayer NavLayerCurrent;
+ int NavLayerCurrentMask;
+ int NavLayerActiveMask;
+ int NavLayerActiveMaskNext;
+ ImGuiID NavFocusScopeIdCurrent;
+ bool NavHideHighlightOneFrame;
+ bool NavHasScroll;
+ bool MenuBarAppending;
+ ImVec2 MenuBarOffset;
+ ImGuiMenuColumns MenuColumns;
+ int TreeDepth;
+ ImU32 TreeJumpToParentOnPopMask;
+ ImVector_ImGuiWindowPtr ChildWindows;
+ ImGuiStorage* StateStorage;
+ ImGuiColumns* CurrentColumns;
+ ImGuiLayoutType LayoutType;
+ ImGuiLayoutType ParentLayoutType;
+ int FocusCounterRegular;
+ int FocusCounterTabStop;
+ ImGuiItemFlags ItemFlags;
+ float ItemWidth;
+ float TextWrapPos;
+ ImVector_ImGuiItemFlags ItemFlagsStack;
+ ImVector_float ItemWidthStack;
+ ImVector_float TextWrapPosStack;
+ ImVector_ImGuiGroupData GroupStack;
+ short StackSizesBackup[6];
+};
+struct ImGuiWindow
+{
+ char* Name;
ImGuiID ID;
- ImGuiViewportFlags Flags;
+ ImGuiWindowFlags Flags;
ImVec2 Pos;
ImVec2 Size;
- float DpiScale;
- ImDrawData* DrawData;
- ImGuiID ParentViewportId;
- void* RendererUserData;
- void* PlatformUserData;
- void* PlatformHandle;
- void* PlatformHandleRaw;
- bool PlatformRequestClose;
- bool PlatformRequestMove;
- bool PlatformRequestResize;
+ ImVec2 SizeFull;
+ ImVec2 ContentSize;
+ ImVec2 ContentSizeExplicit;
+ ImVec2 WindowPadding;
+ float WindowRounding;
+ float WindowBorderSize;
+ int NameBufLen;
+ ImGuiID MoveId;
+ ImGuiID ChildId;
+ ImVec2 Scroll;
+ ImVec2 ScrollMax;
+ ImVec2 ScrollTarget;
+ ImVec2 ScrollTargetCenterRatio;
+ ImVec2 ScrollbarSizes;
+ bool ScrollbarX, ScrollbarY;
+ bool Active;
+ bool WasActive;
+ bool WriteAccessed;
+ bool Collapsed;
+ bool WantCollapseToggle;
+ bool SkipItems;
+ bool Appearing;
+ bool Hidden;
+ bool IsFallbackWindow;
+ bool HasCloseButton;
+ signed char ResizeBorderHeld;
+ short BeginCount;
+ short BeginOrderWithinParent;
+ short BeginOrderWithinContext;
+ ImGuiID PopupId;
+ ImS8 AutoFitFramesX, AutoFitFramesY;
+ ImS8 AutoFitChildAxises;
+ bool AutoFitOnlyGrows;
+ ImGuiDir AutoPosLastDirection;
+ int HiddenFramesCanSkipItems;
+ int HiddenFramesCannotSkipItems;
+ ImGuiCond SetWindowPosAllowFlags;
+ ImGuiCond SetWindowSizeAllowFlags;
+ ImGuiCond SetWindowCollapsedAllowFlags;
+ ImVec2 SetWindowPosVal;
+ ImVec2 SetWindowPosPivot;
+ ImVector_ImGuiID IDStack;
+ ImGuiWindowTempData DC;
+ ImRect OuterRectClipped;
+ ImRect InnerRect;
+ ImRect InnerClipRect;
+ ImRect WorkRect;
+ ImRect ClipRect;
+ ImRect ContentRegionRect;
+ int LastFrameActive;
+ float LastTimeActive;
+ float ItemWidthDefault;
+ ImGuiStorage StateStorage;
+ ImVector_ImGuiColumns ColumnsStorage;
+ float FontWindowScale;
+ int SettingsOffset;
+ ImDrawList* DrawList;
+ ImDrawList DrawListInst;
+ ImGuiWindow* ParentWindow;
+ ImGuiWindow* RootWindow;
+ ImGuiWindow* RootWindowForTitleBarHighlight;
+ ImGuiWindow* RootWindowForNav;
+ ImGuiWindow* NavLastChildNavWindow;
+ ImGuiID NavLastIds[ImGuiNavLayer_COUNT];
+ ImRect NavRectRel[ImGuiNavLayer_COUNT];
+ bool MemoryCompacted;
+ int MemoryDrawListIdxCapacity;
+ int MemoryDrawListVtxCapacity;
};
- struct ImGuiTextRange
- {
+struct ImGuiItemHoveredDataBackup
+{
+ ImGuiID LastItemId;
+ ImGuiItemStatusFlags LastItemStatusFlags;
+ ImRect LastItemRect;
+ ImRect LastItemDisplayRect;
+};
+typedef enum {
+ ImGuiTabBarFlags_DockNode = 1 << 20,
+ ImGuiTabBarFlags_IsFocused = 1 << 21,
+ ImGuiTabBarFlags_SaveSettings = 1 << 22
+}ImGuiTabBarFlagsPrivate_;
+typedef enum {
+ ImGuiTabItemFlags_NoCloseButton = 1 << 20
+}ImGuiTabItemFlagsPrivate_;
+struct ImGuiTabItem
+{
+ ImGuiID ID;
+ ImGuiTabItemFlags Flags;
+ int LastFrameVisible;
+ int LastFrameSelected;
+ int NameOffset;
+ float Offset;
+ float Width;
+ float ContentWidth;
+};
+struct ImGuiTabBar
+{
+ ImVector_ImGuiTabItem Tabs;
+ ImGuiID ID;
+ ImGuiID SelectedTabId;
+ ImGuiID NextSelectedTabId;
+ ImGuiID VisibleTabId;
+ int CurrFrameVisible;
+ int PrevFrameVisible;
+ ImRect BarRect;
+ float LastTabContentHeight;
+ float OffsetMax;
+ float OffsetMaxIdeal;
+ float OffsetNextTab;
+ float ScrollingAnim;
+ float ScrollingTarget;
+ float ScrollingTargetDistToVisibility;
+ float ScrollingSpeed;
+ ImGuiTabBarFlags Flags;
+ ImGuiID ReorderRequestTabId;
+ ImS8 ReorderRequestDir;
+ bool WantLayout;
+ bool VisibleTabWasSubmitted;
+ short LastTabItemIdx;
+ ImVec2 FramePadding;
+ ImGuiTextBuffer TabsNames;
+};
+struct ImGuiTextRange
+{
const char* b;
const char* e;
};
- struct ImGuiStoragePair
- {
+struct ImGuiStoragePair
+{
ImGuiID key;
union { int val_i; float val_f; void* val_p; };
};
@@ -986,29 +1730,7 @@ struct ImGuiViewport
struct GLFWwindow;
struct SDL_Window;
typedef union SDL_Event SDL_Event;
-inline ImVec2_Simple ImVec2ToSimple(ImVec2 vec)
-{
- ImVec2_Simple result;
- result.x = vec.x;
- result.y = vec.y;
- return result;
-}
-inline ImVec4_Simple ImVec4ToSimple(ImVec4 vec)
-{
- ImVec4_Simple result;
- result.x = vec.x;
- result.y = vec.y;
- result.z = vec.z;
- result.w = vec.w;
- return result;
-}
-inline ImColor_Simple ImColorToSimple(ImColor col)
-{
- ImColor_Simple result;
- result.Value = ImVec4ToSimple(col.Value);
- return result;
-}
-#endif // ndef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
+#endif // CIMGUI_DEFINE_ENUMS_AND_STRUCTS
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
typedef ImGuiStorage::ImGuiStoragePair ImGuiStoragePair;
@@ -1016,34 +1738,48 @@ typedef ImGuiTextFilter::ImGuiTextRange ImGuiTextRange;
typedef ImVector ImVector_float;
typedef ImVector ImVector_ImWchar;
typedef ImVector ImVector_ImDrawVert;
+typedef ImVector ImVector_ImGuiSettingsHandler;
+typedef ImVector ImVector_ImVec4;
+typedef ImVector ImVector_ImGuiGroupData;
+typedef ImVector ImVector_ImGuiID;
+typedef ImVector ImVector_ImGuiWindowPtr;
+typedef ImVector ImVector_ImGuiColumnData;
+typedef ImVector ImVector_ImGuiColumns;
+typedef ImVector ImVector_ImVec2;
typedef ImVector ImVector_ImFontGlyph;
typedef ImVector ImVector_ImGuiTextRange;
typedef ImVector ImVector_ImGuiStoragePair;
+typedef ImVector ImVector_ImGuiStyleMod;
typedef ImVector ImVector_ImDrawChannel;
-typedef ImVector ImVector_char;
+typedef ImVector ImVector_ImDrawListPtr;
typedef ImVector ImVector_ImU32;
+typedef ImVector ImVector_ImGuiItemFlags;
typedef ImVector ImVector_ImFontAtlasCustomRect;
+typedef ImVector ImVector_ImGuiTabItem;
+typedef ImVector ImVector_ImGuiShrinkWidthItem;
+typedef ImVector ImVector_unsigned_char;
typedef ImVector ImVector_ImTextureID;
-typedef ImVector ImVector_ImFontConfig;
-typedef ImVector ImVector_ImGuiPlatformMonitor;
-typedef ImVector ImVector_ImGuiViewportPtr;
typedef ImVector ImVector_ImFontPtr;
+typedef ImVector ImVector_ImFontConfig;
+typedef ImVector ImVector_ImGuiColorMod;
typedef ImVector ImVector_ImDrawCmd;
-typedef ImVector ImVector_ImVec4;
+typedef ImVector ImVector_ImGuiPtrOrIndex;
+typedef ImVector ImVector_ImGuiPopupData;
typedef ImVector ImVector_ImDrawIdx;
-typedef ImVector ImVector_ImVec2;
+typedef ImVector ImVector_char;
+typedef ImChunkStream ImChunkStream_ImGuiWindowSettings;
+typedef ImPool ImPool_ImGuiTabBar;
#endif // CIMGUI_DEFINE_ENUMS_AND_STRUCTS
-CIMGUI_API ImVec2* ImVec2_ImVec2(void);
+CIMGUI_API ImVec2* ImVec2_ImVec2Nil(void);
CIMGUI_API void ImVec2_destroy(ImVec2* self);
CIMGUI_API ImVec2* ImVec2_ImVec2Float(float _x,float _y);
-CIMGUI_API ImVec4* ImVec4_ImVec4(void);
+CIMGUI_API ImVec4* ImVec4_ImVec4Nil(void);
CIMGUI_API void ImVec4_destroy(ImVec4* self);
CIMGUI_API ImVec4* ImVec4_ImVec4Float(float _x,float _y,float _z,float _w);
CIMGUI_API ImGuiContext* igCreateContext(ImFontAtlas* shared_font_atlas);
CIMGUI_API void igDestroyContext(ImGuiContext* ctx);
CIMGUI_API ImGuiContext* igGetCurrentContext(void);
CIMGUI_API void igSetCurrentContext(ImGuiContext* ctx);
-CIMGUI_API bool igDebugCheckVersionAndDataLayout(const char* version_str,size_t sz_io,size_t sz_style,size_t sz_vec2,size_t sz_vec4,size_t sz_drawvert,size_t sz_drawidx);
CIMGUI_API ImGuiIO* igGetIO(void);
CIMGUI_API ImGuiStyle* igGetStyle(void);
CIMGUI_API void igNewFrame(void);
@@ -1063,7 +1799,7 @@ CIMGUI_API void igStyleColorsClassic(ImGuiStyle* dst);
CIMGUI_API void igStyleColorsLight(ImGuiStyle* dst);
CIMGUI_API bool igBegin(const char* name,bool* p_open,ImGuiWindowFlags flags);
CIMGUI_API void igEnd(void);
-CIMGUI_API bool igBeginChild(const char* str_id,const ImVec2 size,bool border,ImGuiWindowFlags flags);
+CIMGUI_API bool igBeginChildStr(const char* str_id,const ImVec2 size,bool border,ImGuiWindowFlags flags);
CIMGUI_API bool igBeginChildID(ImGuiID id,const ImVec2 size,bool border,ImGuiWindowFlags flags);
CIMGUI_API void igEndChild(void);
CIMGUI_API bool igIsWindowAppearing(void);
@@ -1071,10 +1807,8 @@ CIMGUI_API bool igIsWindowCollapsed(void);
CIMGUI_API bool igIsWindowFocused(ImGuiFocusedFlags flags);
CIMGUI_API bool igIsWindowHovered(ImGuiHoveredFlags flags);
CIMGUI_API ImDrawList* igGetWindowDrawList(void);
-CIMGUI_API float igGetWindowDpiScale(void);
-CIMGUI_API ImGuiViewport* igGetWindowViewport(void);
-CIMGUI_API ImVec2 igGetWindowPos(void);
-CIMGUI_API ImVec2 igGetWindowSize(void);
+CIMGUI_API void igGetWindowPos(ImVec2 *pOut);
+CIMGUI_API void igGetWindowSize(ImVec2 *pOut);
CIMGUI_API float igGetWindowWidth(void);
CIMGUI_API float igGetWindowHeight(void);
CIMGUI_API void igSetNextWindowPos(const ImVec2 pos,ImGuiCond cond,const ImVec2 pivot);
@@ -1084,35 +1818,34 @@ CIMGUI_API void igSetNextWindowContentSize(const ImVec2 size);
CIMGUI_API void igSetNextWindowCollapsed(bool collapsed,ImGuiCond cond);
CIMGUI_API void igSetNextWindowFocus(void);
CIMGUI_API void igSetNextWindowBgAlpha(float alpha);
-CIMGUI_API void igSetNextWindowViewport(ImGuiID viewport_id);
CIMGUI_API void igSetWindowPosVec2(const ImVec2 pos,ImGuiCond cond);
CIMGUI_API void igSetWindowSizeVec2(const ImVec2 size,ImGuiCond cond);
CIMGUI_API void igSetWindowCollapsedBool(bool collapsed,ImGuiCond cond);
-CIMGUI_API void igSetWindowFocus(void);
+CIMGUI_API void igSetWindowFocusNil(void);
CIMGUI_API void igSetWindowFontScale(float scale);
CIMGUI_API void igSetWindowPosStr(const char* name,const ImVec2 pos,ImGuiCond cond);
CIMGUI_API void igSetWindowSizeStr(const char* name,const ImVec2 size,ImGuiCond cond);
CIMGUI_API void igSetWindowCollapsedStr(const char* name,bool collapsed,ImGuiCond cond);
CIMGUI_API void igSetWindowFocusStr(const char* name);
-CIMGUI_API ImVec2 igGetContentRegionMax(void);
-CIMGUI_API ImVec2 igGetContentRegionAvail(void);
-CIMGUI_API ImVec2 igGetWindowContentRegionMin(void);
-CIMGUI_API ImVec2 igGetWindowContentRegionMax(void);
+CIMGUI_API void igGetContentRegionMax(ImVec2 *pOut);
+CIMGUI_API void igGetContentRegionAvail(ImVec2 *pOut);
+CIMGUI_API void igGetWindowContentRegionMin(ImVec2 *pOut);
+CIMGUI_API void igGetWindowContentRegionMax(ImVec2 *pOut);
CIMGUI_API float igGetWindowContentRegionWidth(void);
CIMGUI_API float igGetScrollX(void);
CIMGUI_API float igGetScrollY(void);
CIMGUI_API float igGetScrollMaxX(void);
CIMGUI_API float igGetScrollMaxY(void);
-CIMGUI_API void igSetScrollX(float scroll_x);
-CIMGUI_API void igSetScrollY(float scroll_y);
+CIMGUI_API void igSetScrollXFloat(float scroll_x);
+CIMGUI_API void igSetScrollYFloat(float scroll_y);
CIMGUI_API void igSetScrollHereX(float center_x_ratio);
CIMGUI_API void igSetScrollHereY(float center_y_ratio);
-CIMGUI_API void igSetScrollFromPosX(float local_x,float center_x_ratio);
-CIMGUI_API void igSetScrollFromPosY(float local_y,float center_y_ratio);
+CIMGUI_API void igSetScrollFromPosXFloat(float local_x,float center_x_ratio);
+CIMGUI_API void igSetScrollFromPosYFloat(float local_y,float center_y_ratio);
CIMGUI_API void igPushFont(ImFont* font);
CIMGUI_API void igPopFont(void);
CIMGUI_API void igPushStyleColorU32(ImGuiCol idx,ImU32 col);
-CIMGUI_API void igPushStyleColor(ImGuiCol idx,const ImVec4 col);
+CIMGUI_API void igPushStyleColorVec4(ImGuiCol idx,const ImVec4 col);
CIMGUI_API void igPopStyleColor(int count);
CIMGUI_API void igPushStyleVarFloat(ImGuiStyleVar idx,float val);
CIMGUI_API void igPushStyleVarVec2(ImGuiStyleVar idx,const ImVec2 val);
@@ -1120,8 +1853,8 @@ CIMGUI_API void igPopStyleVar(int count);
CIMGUI_API const ImVec4* igGetStyleColorVec4(ImGuiCol idx);
CIMGUI_API ImFont* igGetFont(void);
CIMGUI_API float igGetFontSize(void);
-CIMGUI_API ImVec2 igGetFontTexUvWhitePixel(void);
-CIMGUI_API ImU32 igGetColorU32(ImGuiCol idx,float alpha_mul);
+CIMGUI_API void igGetFontTexUvWhitePixel(ImVec2 *pOut);
+CIMGUI_API ImU32 igGetColorU32Col(ImGuiCol idx,float alpha_mul);
CIMGUI_API ImU32 igGetColorU32Vec4(const ImVec4 col);
CIMGUI_API ImU32 igGetColorU32U32(ImU32 col);
CIMGUI_API void igPushItemWidth(float item_width);
@@ -1143,14 +1876,14 @@ CIMGUI_API void igIndent(float indent_w);
CIMGUI_API void igUnindent(float indent_w);
CIMGUI_API void igBeginGroup(void);
CIMGUI_API void igEndGroup(void);
-CIMGUI_API ImVec2 igGetCursorPos(void);
+CIMGUI_API void igGetCursorPos(ImVec2 *pOut);
CIMGUI_API float igGetCursorPosX(void);
CIMGUI_API float igGetCursorPosY(void);
CIMGUI_API void igSetCursorPos(const ImVec2 local_pos);
CIMGUI_API void igSetCursorPosX(float local_x);
CIMGUI_API void igSetCursorPosY(float local_y);
-CIMGUI_API ImVec2 igGetCursorStartPos(void);
-CIMGUI_API ImVec2 igGetCursorScreenPos(void);
+CIMGUI_API void igGetCursorStartPos(ImVec2 *pOut);
+CIMGUI_API void igGetCursorScreenPos(ImVec2 *pOut);
CIMGUI_API void igSetCursorScreenPos(const ImVec2 pos);
CIMGUI_API void igAlignTextToFramePadding(void);
CIMGUI_API float igGetTextLineHeight(void);
@@ -1158,12 +1891,12 @@ CIMGUI_API float igGetTextLineHeightWithSpacing(void);
CIMGUI_API float igGetFrameHeight(void);
CIMGUI_API float igGetFrameHeightWithSpacing(void);
CIMGUI_API void igPushIDStr(const char* str_id);
-CIMGUI_API void igPushIDRange(const char* str_id_begin,const char* str_id_end);
+CIMGUI_API void igPushIDStrStr(const char* str_id_begin,const char* str_id_end);
CIMGUI_API void igPushIDPtr(const void* ptr_id);
CIMGUI_API void igPushIDInt(int int_id);
CIMGUI_API void igPopID(void);
CIMGUI_API ImGuiID igGetIDStr(const char* str_id);
-CIMGUI_API ImGuiID igGetIDRange(const char* str_id_begin,const char* str_id_end);
+CIMGUI_API ImGuiID igGetIDStrStr(const char* str_id_begin,const char* str_id_end);
CIMGUI_API ImGuiID igGetIDPtr(const void* ptr_id);
CIMGUI_API void igTextUnformatted(const char* text,const char* text_end);
CIMGUI_API void igText(const char* fmt,...);
@@ -1192,7 +1925,7 @@ CIMGUI_API void igProgressBar(float fraction,const ImVec2 size_arg,const char* o
CIMGUI_API void igBullet(void);
CIMGUI_API bool igBeginCombo(const char* label,const char* preview_value,ImGuiComboFlags flags);
CIMGUI_API void igEndCombo(void);
-CIMGUI_API bool igCombo(const char* label,int* current_item,const char* const items[],int items_count,int popup_max_height_in_items);
+CIMGUI_API bool igComboStr_arr(const char* label,int* current_item,const char* const items[],int items_count,int popup_max_height_in_items);
CIMGUI_API bool igComboStr(const char* label,int* current_item,const char* items_separated_by_zeros,int popup_max_height_in_items);
CIMGUI_API bool igComboFnPtr(const char* label,int* current_item,bool(*items_getter)(void* data,int idx,const char** out_text),void* data,int items_count,int popup_max_height_in_items);
CIMGUI_API bool igDragFloat(const char* label,float* v,float v_speed,float v_min,float v_max,const char* format,float power);
@@ -1255,17 +1988,17 @@ CIMGUI_API void igTreePushStr(const char* str_id);
CIMGUI_API void igTreePushPtr(const void* ptr_id);
CIMGUI_API void igTreePop(void);
CIMGUI_API float igGetTreeNodeToLabelSpacing(void);
-CIMGUI_API bool igCollapsingHeader(const char* label,ImGuiTreeNodeFlags flags);
+CIMGUI_API bool igCollapsingHeaderTreeNodeFlags(const char* label,ImGuiTreeNodeFlags flags);
CIMGUI_API bool igCollapsingHeaderBoolPtr(const char* label,bool* p_open,ImGuiTreeNodeFlags flags);
CIMGUI_API void igSetNextItemOpen(bool is_open,ImGuiCond cond);
-CIMGUI_API bool igSelectable(const char* label,bool selected,ImGuiSelectableFlags flags,const ImVec2 size);
+CIMGUI_API bool igSelectableBool(const char* label,bool selected,ImGuiSelectableFlags flags,const ImVec2 size);
CIMGUI_API bool igSelectableBoolPtr(const char* label,bool* p_selected,ImGuiSelectableFlags flags,const ImVec2 size);
CIMGUI_API bool igListBoxStr_arr(const char* label,int* current_item,const char* const items[],int items_count,int height_in_items);
CIMGUI_API bool igListBoxFnPtr(const char* label,int* current_item,bool(*items_getter)(void* data,int idx,const char** out_text),void* data,int items_count,int height_in_items);
CIMGUI_API bool igListBoxHeaderVec2(const char* label,const ImVec2 size);
CIMGUI_API bool igListBoxHeaderInt(const char* label,int items_count,int height_in_items);
CIMGUI_API void igListBoxFooter(void);
-CIMGUI_API void igPlotLines(const char* label,const float* values,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size,int stride);
+CIMGUI_API void igPlotLinesFloatPtr(const char* label,const float* values,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size,int stride);
CIMGUI_API void igPlotLinesFnPtr(const char* label,float(*values_getter)(void* data,int idx),void* data,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size);
CIMGUI_API void igPlotHistogramFloatPtr(const char* label,const float* values,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size,int stride);
CIMGUI_API void igPlotHistogramFnPtr(const char* label,float(*values_getter)(void* data,int idx),void* data,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size);
@@ -1273,10 +2006,10 @@ CIMGUI_API void igValueBool(const char* prefix,bool b);
CIMGUI_API void igValueInt(const char* prefix,int v);
CIMGUI_API void igValueUint(const char* prefix,unsigned int v);
CIMGUI_API void igValueFloat(const char* prefix,float v,const char* float_format);
-CIMGUI_API bool igBeginMainMenuBar(void);
-CIMGUI_API void igEndMainMenuBar(void);
CIMGUI_API bool igBeginMenuBar(void);
CIMGUI_API void igEndMenuBar(void);
+CIMGUI_API bool igBeginMainMenuBar(void);
+CIMGUI_API void igEndMainMenuBar(void);
CIMGUI_API bool igBeginMenu(const char* label,bool enabled);
CIMGUI_API void igEndMenu(void);
CIMGUI_API bool igMenuItemBool(const char* label,const char* shortcut,bool selected,bool enabled);
@@ -1287,13 +2020,13 @@ CIMGUI_API void igSetTooltip(const char* fmt,...);
CIMGUI_API void igSetTooltipV(const char* fmt,va_list args);
CIMGUI_API void igOpenPopup(const char* str_id);
CIMGUI_API bool igBeginPopup(const char* str_id,ImGuiWindowFlags flags);
-CIMGUI_API bool igBeginPopupContextItem(const char* str_id,int mouse_button);
-CIMGUI_API bool igBeginPopupContextWindow(const char* str_id,int mouse_button,bool also_over_items);
-CIMGUI_API bool igBeginPopupContextVoid(const char* str_id,int mouse_button);
+CIMGUI_API bool igBeginPopupContextItem(const char* str_id,ImGuiMouseButton mouse_button);
+CIMGUI_API bool igBeginPopupContextWindow(const char* str_id,ImGuiMouseButton mouse_button,bool also_over_items);
+CIMGUI_API bool igBeginPopupContextVoid(const char* str_id,ImGuiMouseButton mouse_button);
CIMGUI_API bool igBeginPopupModal(const char* name,bool* p_open,ImGuiWindowFlags flags);
CIMGUI_API void igEndPopup(void);
-CIMGUI_API bool igOpenPopupOnItemClick(const char* str_id,int mouse_button);
-CIMGUI_API bool igIsPopupOpen(const char* str_id);
+CIMGUI_API bool igOpenPopupOnItemClick(const char* str_id,ImGuiMouseButton mouse_button);
+CIMGUI_API bool igIsPopupOpenStr(const char* str_id);
CIMGUI_API void igCloseCurrentPopup(void);
CIMGUI_API void igColumns(int count,const char* id,bool border);
CIMGUI_API void igNextColumn(void);
@@ -1308,12 +2041,6 @@ CIMGUI_API void igEndTabBar(void);
CIMGUI_API bool igBeginTabItem(const char* label,bool* p_open,ImGuiTabItemFlags flags);
CIMGUI_API void igEndTabItem(void);
CIMGUI_API void igSetTabItemClosed(const char* tab_or_docked_window_label);
-CIMGUI_API void igDockSpace(ImGuiID id,const ImVec2 size,ImGuiDockNodeFlags flags,const ImGuiWindowClass* window_class);
-CIMGUI_API ImGuiID igDockSpaceOverViewport(ImGuiViewport* viewport,ImGuiDockNodeFlags flags,const ImGuiWindowClass* window_class);
-CIMGUI_API void igSetNextWindowDockID(ImGuiID dock_id,ImGuiCond cond);
-CIMGUI_API void igSetNextWindowClass(const ImGuiWindowClass* window_class);
-CIMGUI_API ImGuiID igGetWindowDockID(void);
-CIMGUI_API bool igIsWindowDocked(void);
CIMGUI_API void igLogToTTY(int auto_open_depth);
CIMGUI_API void igLogToFile(int auto_open_depth,const char* filename);
CIMGUI_API void igLogToClipboard(int auto_open_depth);
@@ -1333,57 +2060,56 @@ CIMGUI_API void igSetKeyboardFocusHere(int offset);
CIMGUI_API bool igIsItemHovered(ImGuiHoveredFlags flags);
CIMGUI_API bool igIsItemActive(void);
CIMGUI_API bool igIsItemFocused(void);
-CIMGUI_API bool igIsItemClicked(int mouse_button);
+CIMGUI_API bool igIsItemClicked(ImGuiMouseButton mouse_button);
CIMGUI_API bool igIsItemVisible(void);
CIMGUI_API bool igIsItemEdited(void);
CIMGUI_API bool igIsItemActivated(void);
CIMGUI_API bool igIsItemDeactivated(void);
CIMGUI_API bool igIsItemDeactivatedAfterEdit(void);
+CIMGUI_API bool igIsItemToggledOpen(void);
CIMGUI_API bool igIsAnyItemHovered(void);
CIMGUI_API bool igIsAnyItemActive(void);
CIMGUI_API bool igIsAnyItemFocused(void);
-CIMGUI_API ImVec2 igGetItemRectMin(void);
-CIMGUI_API ImVec2 igGetItemRectMax(void);
-CIMGUI_API ImVec2 igGetItemRectSize(void);
+CIMGUI_API void igGetItemRectMin(ImVec2 *pOut);
+CIMGUI_API void igGetItemRectMax(ImVec2 *pOut);
+CIMGUI_API void igGetItemRectSize(ImVec2 *pOut);
CIMGUI_API void igSetItemAllowOverlap(void);
-CIMGUI_API bool igIsRectVisible(const ImVec2 size);
+CIMGUI_API bool igIsRectVisibleNil(const ImVec2 size);
CIMGUI_API bool igIsRectVisibleVec2(const ImVec2 rect_min,const ImVec2 rect_max);
CIMGUI_API double igGetTime(void);
CIMGUI_API int igGetFrameCount(void);
CIMGUI_API ImDrawList* igGetBackgroundDrawList(void);
-CIMGUI_API ImDrawList* igGetForegroundDrawList(void);
-CIMGUI_API ImDrawList* igGetBackgroundDrawListViewportPtr(ImGuiViewport* viewport);
-CIMGUI_API ImDrawList* igGetForegroundDrawListViewportPtr(ImGuiViewport* viewport);
+CIMGUI_API ImDrawList* igGetForegroundDrawListNil(void);
CIMGUI_API ImDrawListSharedData* igGetDrawListSharedData(void);
CIMGUI_API const char* igGetStyleColorName(ImGuiCol idx);
CIMGUI_API void igSetStateStorage(ImGuiStorage* storage);
CIMGUI_API ImGuiStorage* igGetStateStorage(void);
-CIMGUI_API ImVec2 igCalcTextSize(const char* text,const char* text_end,bool hide_text_after_double_hash,float wrap_width);
CIMGUI_API void igCalcListClipping(int items_count,float items_height,int* out_items_display_start,int* out_items_display_end);
CIMGUI_API bool igBeginChildFrame(ImGuiID id,const ImVec2 size,ImGuiWindowFlags flags);
CIMGUI_API void igEndChildFrame(void);
-CIMGUI_API ImVec4 igColorConvertU32ToFloat4(ImU32 in);
+CIMGUI_API void igCalcTextSize(ImVec2 *pOut,const char* text,const char* text_end,bool hide_text_after_double_hash,float wrap_width);
+CIMGUI_API void igColorConvertU32ToFloat4(ImVec4 *pOut,ImU32 in);
CIMGUI_API ImU32 igColorConvertFloat4ToU32(const ImVec4 in);
CIMGUI_API int igGetKeyIndex(ImGuiKey imgui_key);
CIMGUI_API bool igIsKeyDown(int user_key_index);
CIMGUI_API bool igIsKeyPressed(int user_key_index,bool repeat);
CIMGUI_API bool igIsKeyReleased(int user_key_index);
CIMGUI_API int igGetKeyPressedAmount(int key_index,float repeat_delay,float rate);
-CIMGUI_API bool igIsMouseDown(int button);
-CIMGUI_API bool igIsAnyMouseDown(void);
-CIMGUI_API bool igIsMouseClicked(int button,bool repeat);
-CIMGUI_API bool igIsMouseDoubleClicked(int button);
-CIMGUI_API bool igIsMouseReleased(int button);
-CIMGUI_API bool igIsMouseDragging(int button,float lock_threshold);
+CIMGUI_API void igCaptureKeyboardFromApp(bool want_capture_keyboard_value);
+CIMGUI_API bool igIsMouseDown(ImGuiMouseButton button);
+CIMGUI_API bool igIsMouseClicked(ImGuiMouseButton button,bool repeat);
+CIMGUI_API bool igIsMouseReleased(ImGuiMouseButton button);
+CIMGUI_API bool igIsMouseDoubleClicked(ImGuiMouseButton button);
CIMGUI_API bool igIsMouseHoveringRect(const ImVec2 r_min,const ImVec2 r_max,bool clip);
CIMGUI_API bool igIsMousePosValid(const ImVec2* mouse_pos);
-CIMGUI_API ImVec2 igGetMousePos(void);
-CIMGUI_API ImVec2 igGetMousePosOnOpeningCurrentPopup(void);
-CIMGUI_API ImVec2 igGetMouseDragDelta(int button,float lock_threshold);
-CIMGUI_API void igResetMouseDragDelta(int button);
+CIMGUI_API bool igIsAnyMouseDown(void);
+CIMGUI_API void igGetMousePos(ImVec2 *pOut);
+CIMGUI_API void igGetMousePosOnOpeningCurrentPopup(ImVec2 *pOut);
+CIMGUI_API bool igIsMouseDragging(ImGuiMouseButton button,float lock_threshold);
+CIMGUI_API void igGetMouseDragDelta(ImVec2 *pOut,ImGuiMouseButton button,float lock_threshold);
+CIMGUI_API void igResetMouseDragDelta(ImGuiMouseButton button);
CIMGUI_API ImGuiMouseCursor igGetMouseCursor(void);
-CIMGUI_API void igSetMouseCursor(ImGuiMouseCursor type);
-CIMGUI_API void igCaptureKeyboardFromApp(bool want_capture_keyboard_value);
+CIMGUI_API void igSetMouseCursor(ImGuiMouseCursor cursor_type);
CIMGUI_API void igCaptureMouseFromApp(bool want_capture_mouse_value);
CIMGUI_API const char* igGetClipboardText(void);
CIMGUI_API void igSetClipboardText(const char* text);
@@ -1391,20 +2117,15 @@ CIMGUI_API void igLoadIniSettingsFromDisk(const char* ini_filename);
CIMGUI_API void igLoadIniSettingsFromMemory(const char* ini_data,size_t ini_size);
CIMGUI_API void igSaveIniSettingsToDisk(const char* ini_filename);
CIMGUI_API const char* igSaveIniSettingsToMemory(size_t* out_ini_size);
+CIMGUI_API bool igDebugCheckVersionAndDataLayout(const char* version_str,size_t sz_io,size_t sz_style,size_t sz_vec2,size_t sz_vec4,size_t sz_drawvert,size_t sz_drawidx);
CIMGUI_API void igSetAllocatorFunctions(void*(*alloc_func)(size_t sz,void* user_data),void(*free_func)(void* ptr,void* user_data),void* user_data);
CIMGUI_API void* igMemAlloc(size_t size);
CIMGUI_API void igMemFree(void* ptr);
-CIMGUI_API ImGuiPlatformIO* igGetPlatformIO(void);
-CIMGUI_API ImGuiViewport* igGetMainViewport(void);
-CIMGUI_API void igUpdatePlatformWindows(void);
-CIMGUI_API void igRenderPlatformWindowsDefault(void* platform_arg,void* renderer_arg);
-CIMGUI_API void igDestroyPlatformWindows(void);
-CIMGUI_API ImGuiViewport* igFindViewportByID(ImGuiID id);
-CIMGUI_API ImGuiViewport* igFindViewportByPlatformHandle(void* platform_handle);
CIMGUI_API ImGuiStyle* ImGuiStyle_ImGuiStyle(void);
CIMGUI_API void ImGuiStyle_destroy(ImGuiStyle* self);
CIMGUI_API void ImGuiStyle_ScaleAllSizes(ImGuiStyle* self,float scale_factor);
CIMGUI_API void ImGuiIO_AddInputCharacter(ImGuiIO* self,unsigned int c);
+CIMGUI_API void ImGuiIO_AddInputCharacterUTF16(ImGuiIO* self,ImWchar16 c);
CIMGUI_API void ImGuiIO_AddInputCharactersUTF8(ImGuiIO* self,const char* str);
CIMGUI_API void ImGuiIO_ClearInputCharacters(ImGuiIO* self);
CIMGUI_API ImGuiIO* ImGuiIO_ImGuiIO(void);
@@ -1414,8 +2135,6 @@ CIMGUI_API void ImGuiInputTextCallbackData_destroy(ImGuiInputTextCallbackData* s
CIMGUI_API void ImGuiInputTextCallbackData_DeleteChars(ImGuiInputTextCallbackData* self,int pos,int bytes_count);
CIMGUI_API void ImGuiInputTextCallbackData_InsertChars(ImGuiInputTextCallbackData* self,int pos,const char* text,const char* text_end);
CIMGUI_API bool ImGuiInputTextCallbackData_HasSelection(ImGuiInputTextCallbackData* self);
-CIMGUI_API ImGuiWindowClass* ImGuiWindowClass_ImGuiWindowClass(void);
-CIMGUI_API void ImGuiWindowClass_destroy(ImGuiWindowClass* self);
CIMGUI_API ImGuiPayload* ImGuiPayload_ImGuiPayload(void);
CIMGUI_API void ImGuiPayload_destroy(ImGuiPayload* self);
CIMGUI_API void ImGuiPayload_Clear(ImGuiPayload* self);
@@ -1431,7 +2150,7 @@ CIMGUI_API bool ImGuiTextFilter_PassFilter(ImGuiTextFilter* self,const char* tex
CIMGUI_API void ImGuiTextFilter_Build(ImGuiTextFilter* self);
CIMGUI_API void ImGuiTextFilter_Clear(ImGuiTextFilter* self);
CIMGUI_API bool ImGuiTextFilter_IsActive(ImGuiTextFilter* self);
-CIMGUI_API ImGuiTextRange* ImGuiTextRange_ImGuiTextRange(void);
+CIMGUI_API ImGuiTextRange* ImGuiTextRange_ImGuiTextRangeNil(void);
CIMGUI_API void ImGuiTextRange_destroy(ImGuiTextRange* self);
CIMGUI_API ImGuiTextRange* ImGuiTextRange_ImGuiTextRangeStr(const char* _b,const char* _e);
CIMGUI_API bool ImGuiTextRange_empty(ImGuiTextRange* self);
@@ -1471,14 +2190,14 @@ CIMGUI_API void ImGuiListClipper_destroy(ImGuiListClipper* self);
CIMGUI_API bool ImGuiListClipper_Step(ImGuiListClipper* self);
CIMGUI_API void ImGuiListClipper_Begin(ImGuiListClipper* self,int items_count,float items_height);
CIMGUI_API void ImGuiListClipper_End(ImGuiListClipper* self);
-CIMGUI_API ImColor* ImColor_ImColor(void);
+CIMGUI_API ImColor* ImColor_ImColorNil(void);
CIMGUI_API void ImColor_destroy(ImColor* self);
CIMGUI_API ImColor* ImColor_ImColorInt(int r,int g,int b,int a);
CIMGUI_API ImColor* ImColor_ImColorU32(ImU32 rgba);
CIMGUI_API ImColor* ImColor_ImColorFloat(float r,float g,float b,float a);
CIMGUI_API ImColor* ImColor_ImColorVec4(const ImVec4 col);
CIMGUI_API void ImColor_SetHSV(ImColor* self,float h,float s,float v,float a);
-CIMGUI_API ImColor ImColor_HSV(ImColor* self,float h,float s,float v,float a);
+CIMGUI_API void ImColor_HSV(ImColor *pOut,ImColor* self,float h,float s,float v,float a);
CIMGUI_API ImDrawCmd* ImDrawCmd_ImDrawCmd(void);
CIMGUI_API void ImDrawCmd_destroy(ImDrawCmd* self);
CIMGUI_API ImDrawListSplitter* ImDrawListSplitter_ImDrawListSplitter(void);
@@ -1495,8 +2214,8 @@ CIMGUI_API void ImDrawList_PushClipRectFullScreen(ImDrawList* self);
CIMGUI_API void ImDrawList_PopClipRect(ImDrawList* self);
CIMGUI_API void ImDrawList_PushTextureID(ImDrawList* self,ImTextureID texture_id);
CIMGUI_API void ImDrawList_PopTextureID(ImDrawList* self);
-CIMGUI_API ImVec2 ImDrawList_GetClipRectMin(ImDrawList* self);
-CIMGUI_API ImVec2 ImDrawList_GetClipRectMax(ImDrawList* self);
+CIMGUI_API void ImDrawList_GetClipRectMin(ImVec2 *pOut,ImDrawList* self);
+CIMGUI_API void ImDrawList_GetClipRectMax(ImVec2 *pOut,ImDrawList* self);
CIMGUI_API void ImDrawList_AddLine(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,ImU32 col,float thickness);
CIMGUI_API void ImDrawList_AddRect(ImDrawList* self,const ImVec2 p_min,const ImVec2 p_max,ImU32 col,float rounding,ImDrawCornerFlags rounding_corners,float thickness);
CIMGUI_API void ImDrawList_AddRectFilled(ImDrawList* self,const ImVec2 p_min,const ImVec2 p_max,ImU32 col,float rounding,ImDrawCornerFlags rounding_corners);
@@ -1507,11 +2226,13 @@ CIMGUI_API void ImDrawList_AddTriangle(ImDrawList* self,const ImVec2 p1,const Im
CIMGUI_API void ImDrawList_AddTriangleFilled(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,ImU32 col);
CIMGUI_API void ImDrawList_AddCircle(ImDrawList* self,const ImVec2 center,float radius,ImU32 col,int num_segments,float thickness);
CIMGUI_API void ImDrawList_AddCircleFilled(ImDrawList* self,const ImVec2 center,float radius,ImU32 col,int num_segments);
-CIMGUI_API void ImDrawList_AddText(ImDrawList* self,const ImVec2 pos,ImU32 col,const char* text_begin,const char* text_end);
+CIMGUI_API void ImDrawList_AddNgon(ImDrawList* self,const ImVec2 center,float radius,ImU32 col,int num_segments,float thickness);
+CIMGUI_API void ImDrawList_AddNgonFilled(ImDrawList* self,const ImVec2 center,float radius,ImU32 col,int num_segments);
+CIMGUI_API void ImDrawList_AddTextVec2(ImDrawList* self,const ImVec2 pos,ImU32 col,const char* text_begin,const char* text_end);
CIMGUI_API void ImDrawList_AddTextFontPtr(ImDrawList* self,const ImFont* font,float font_size,const ImVec2 pos,ImU32 col,const char* text_begin,const char* text_end,float wrap_width,const ImVec4* cpu_fine_clip_rect);
CIMGUI_API void ImDrawList_AddPolyline(ImDrawList* self,const ImVec2* points,int num_points,ImU32 col,bool closed,float thickness);
CIMGUI_API void ImDrawList_AddConvexPolyFilled(ImDrawList* self,const ImVec2* points,int num_points,ImU32 col);
-CIMGUI_API void ImDrawList_AddBezierCurve(ImDrawList* self,const ImVec2 pos0,const ImVec2 cp0,const ImVec2 cp1,const ImVec2 pos1,ImU32 col,float thickness,int num_segments);
+CIMGUI_API void ImDrawList_AddBezierCurve(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,ImU32 col,float thickness,int num_segments);
CIMGUI_API void ImDrawList_AddImage(ImDrawList* self,ImTextureID user_texture_id,const ImVec2 p_min,const ImVec2 p_max,const ImVec2 uv_min,const ImVec2 uv_max,ImU32 col);
CIMGUI_API void ImDrawList_AddImageQuad(ImDrawList* self,ImTextureID user_texture_id,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,const ImVec2 uv1,const ImVec2 uv2,const ImVec2 uv3,const ImVec2 uv4,ImU32 col);
CIMGUI_API void ImDrawList_AddImageRounded(ImDrawList* self,ImTextureID user_texture_id,const ImVec2 p_min,const ImVec2 p_max,const ImVec2 uv_min,const ImVec2 uv_max,ImU32 col,float rounding,ImDrawCornerFlags rounding_corners);
@@ -1522,7 +2243,7 @@ CIMGUI_API void ImDrawList_PathFillConvex(ImDrawList* self,ImU32 col);
CIMGUI_API void ImDrawList_PathStroke(ImDrawList* self,ImU32 col,bool closed,float thickness);
CIMGUI_API void ImDrawList_PathArcTo(ImDrawList* self,const ImVec2 center,float radius,float a_min,float a_max,int num_segments);
CIMGUI_API void ImDrawList_PathArcToFast(ImDrawList* self,const ImVec2 center,float radius,int a_min_of_12,int a_max_of_12);
-CIMGUI_API void ImDrawList_PathBezierCurveTo(ImDrawList* self,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,int num_segments);
+CIMGUI_API void ImDrawList_PathBezierCurveTo(ImDrawList* self,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,int num_segments);
CIMGUI_API void ImDrawList_PathRect(ImDrawList* self,const ImVec2 rect_min,const ImVec2 rect_max,float rounding,ImDrawCornerFlags rounding_corners);
CIMGUI_API void ImDrawList_AddCallback(ImDrawList* self,ImDrawCallback callback,void* callback_data);
CIMGUI_API void ImDrawList_AddDrawCmd(ImDrawList* self);
@@ -1533,6 +2254,7 @@ CIMGUI_API void ImDrawList_ChannelsSetCurrent(ImDrawList* self,int n);
CIMGUI_API void ImDrawList_Clear(ImDrawList* self);
CIMGUI_API void ImDrawList_ClearFreeMemory(ImDrawList* self);
CIMGUI_API void ImDrawList_PrimReserve(ImDrawList* self,int idx_count,int vtx_count);
+CIMGUI_API void ImDrawList_PrimUnreserve(ImDrawList* self,int idx_count,int vtx_count);
CIMGUI_API void ImDrawList_PrimRect(ImDrawList* self,const ImVec2 a,const ImVec2 b,ImU32 col);
CIMGUI_API void ImDrawList_PrimRectUV(ImDrawList* self,const ImVec2 a,const ImVec2 b,const ImVec2 uv_a,const ImVec2 uv_b,ImU32 col);
CIMGUI_API void ImDrawList_PrimQuadUV(ImDrawList* self,const ImVec2 a,const ImVec2 b,const ImVec2 c,const ImVec2 d,const ImVec2 uv_a,const ImVec2 uv_b,const ImVec2 uv_c,const ImVec2 uv_d,ImU32 col);
@@ -1551,8 +2273,8 @@ CIMGUI_API void ImFontConfig_destroy(ImFontConfig* self);
CIMGUI_API ImFontGlyphRangesBuilder* ImFontGlyphRangesBuilder_ImFontGlyphRangesBuilder(void);
CIMGUI_API void ImFontGlyphRangesBuilder_destroy(ImFontGlyphRangesBuilder* self);
CIMGUI_API void ImFontGlyphRangesBuilder_Clear(ImFontGlyphRangesBuilder* self);
-CIMGUI_API bool ImFontGlyphRangesBuilder_GetBit(ImFontGlyphRangesBuilder* self,int n);
-CIMGUI_API void ImFontGlyphRangesBuilder_SetBit(ImFontGlyphRangesBuilder* self,int n);
+CIMGUI_API bool ImFontGlyphRangesBuilder_GetBit(ImFontGlyphRangesBuilder* self,size_t n);
+CIMGUI_API void ImFontGlyphRangesBuilder_SetBit(ImFontGlyphRangesBuilder* self,size_t n);
CIMGUI_API void ImFontGlyphRangesBuilder_AddChar(ImFontGlyphRangesBuilder* self,ImWchar c);
CIMGUI_API void ImFontGlyphRangesBuilder_AddText(ImFontGlyphRangesBuilder* self,const char* text,const char* text_end);
CIMGUI_API void ImFontGlyphRangesBuilder_AddRanges(ImFontGlyphRangesBuilder* self,const ImWchar* ranges);
@@ -1597,7 +2319,7 @@ CIMGUI_API const ImFontGlyph* ImFont_FindGlyphNoFallback(ImFont* self,ImWchar c)
CIMGUI_API float ImFont_GetCharAdvance(ImFont* self,ImWchar c);
CIMGUI_API bool ImFont_IsLoaded(ImFont* self);
CIMGUI_API const char* ImFont_GetDebugName(ImFont* self);
-CIMGUI_API ImVec2 ImFont_CalcTextSizeA(ImFont* self,float size,float max_width,float wrap_width,const char* text_begin,const char* text_end,const char** remaining);
+CIMGUI_API void ImFont_CalcTextSizeA(ImVec2 *pOut,ImFont* self,float size,float max_width,float wrap_width,const char* text_begin,const char* text_end,const char** remaining);
CIMGUI_API const char* ImFont_CalcWordWrapPositionA(ImFont* self,float scale,const char* text,const char* text_end,float wrap_width);
CIMGUI_API void ImFont_RenderChar(ImFont* self,ImDrawList* draw_list,float size,ImVec2 pos,ImU32 col,ImWchar c);
CIMGUI_API void ImFont_RenderText(ImFont* self,ImDrawList* draw_list,float size,ImVec2 pos,ImU32 col,const ImVec4 clip_rect,const char* text_begin,const char* text_end,float wrap_width,bool cpu_fine_clip);
@@ -1606,57 +2328,377 @@ CIMGUI_API void ImFont_ClearOutputData(ImFont* self);
CIMGUI_API void ImFont_GrowIndex(ImFont* self,int new_size);
CIMGUI_API void ImFont_AddGlyph(ImFont* self,ImWchar c,float x0,float y0,float x1,float y1,float u0,float v0,float u1,float v1,float advance_x);
CIMGUI_API void ImFont_AddRemapChar(ImFont* self,ImWchar dst,ImWchar src,bool overwrite_dst);
+CIMGUI_API void ImFont_SetGlyphVisible(ImFont* self,ImWchar c,bool visible);
CIMGUI_API void ImFont_SetFallbackChar(ImFont* self,ImWchar c);
-CIMGUI_API ImGuiPlatformMonitor* ImGuiPlatformMonitor_ImGuiPlatformMonitor(void);
-CIMGUI_API void ImGuiPlatformMonitor_destroy(ImGuiPlatformMonitor* self);
-CIMGUI_API ImGuiPlatformIO* ImGuiPlatformIO_ImGuiPlatformIO(void);
-CIMGUI_API void ImGuiPlatformIO_destroy(ImGuiPlatformIO* self);
-CIMGUI_API ImGuiViewport* ImGuiViewport_ImGuiViewport(void);
-CIMGUI_API void ImGuiViewport_destroy(ImGuiViewport* self);
-CIMGUI_API void igGetWindowPos_nonUDT(ImVec2 *pOut);
-CIMGUI_API ImVec2_Simple igGetWindowPos_nonUDT2(void);
-CIMGUI_API void igGetWindowSize_nonUDT(ImVec2 *pOut);
-CIMGUI_API ImVec2_Simple igGetWindowSize_nonUDT2(void);
-CIMGUI_API void igGetContentRegionMax_nonUDT(ImVec2 *pOut);
-CIMGUI_API ImVec2_Simple igGetContentRegionMax_nonUDT2(void);
-CIMGUI_API void igGetContentRegionAvail_nonUDT(ImVec2 *pOut);
-CIMGUI_API ImVec2_Simple igGetContentRegionAvail_nonUDT2(void);
-CIMGUI_API void igGetWindowContentRegionMin_nonUDT(ImVec2 *pOut);
-CIMGUI_API ImVec2_Simple igGetWindowContentRegionMin_nonUDT2(void);
-CIMGUI_API void igGetWindowContentRegionMax_nonUDT(ImVec2 *pOut);
-CIMGUI_API ImVec2_Simple igGetWindowContentRegionMax_nonUDT2(void);
-CIMGUI_API void igGetFontTexUvWhitePixel_nonUDT(ImVec2 *pOut);
-CIMGUI_API ImVec2_Simple igGetFontTexUvWhitePixel_nonUDT2(void);
-CIMGUI_API void igGetCursorPos_nonUDT(ImVec2 *pOut);
-CIMGUI_API ImVec2_Simple igGetCursorPos_nonUDT2(void);
-CIMGUI_API void igGetCursorStartPos_nonUDT(ImVec2 *pOut);
-CIMGUI_API ImVec2_Simple igGetCursorStartPos_nonUDT2(void);
-CIMGUI_API void igGetCursorScreenPos_nonUDT(ImVec2 *pOut);
-CIMGUI_API ImVec2_Simple igGetCursorScreenPos_nonUDT2(void);
-CIMGUI_API void igGetItemRectMin_nonUDT(ImVec2 *pOut);
-CIMGUI_API ImVec2_Simple igGetItemRectMin_nonUDT2(void);
-CIMGUI_API void igGetItemRectMax_nonUDT(ImVec2 *pOut);
-CIMGUI_API ImVec2_Simple igGetItemRectMax_nonUDT2(void);
-CIMGUI_API void igGetItemRectSize_nonUDT(ImVec2 *pOut);
-CIMGUI_API ImVec2_Simple igGetItemRectSize_nonUDT2(void);
-CIMGUI_API void igCalcTextSize_nonUDT(ImVec2 *pOut,const char* text,const char* text_end,bool hide_text_after_double_hash,float wrap_width);
-CIMGUI_API ImVec2_Simple igCalcTextSize_nonUDT2(const char* text,const char* text_end,bool hide_text_after_double_hash,float wrap_width);
-CIMGUI_API void igColorConvertU32ToFloat4_nonUDT(ImVec4 *pOut,ImU32 in);
-CIMGUI_API ImVec4_Simple igColorConvertU32ToFloat4_nonUDT2(ImU32 in);
-CIMGUI_API void igGetMousePos_nonUDT(ImVec2 *pOut);
-CIMGUI_API ImVec2_Simple igGetMousePos_nonUDT2(void);
-CIMGUI_API void igGetMousePosOnOpeningCurrentPopup_nonUDT(ImVec2 *pOut);
-CIMGUI_API ImVec2_Simple igGetMousePosOnOpeningCurrentPopup_nonUDT2(void);
-CIMGUI_API void igGetMouseDragDelta_nonUDT(ImVec2 *pOut,int button,float lock_threshold);
-CIMGUI_API ImVec2_Simple igGetMouseDragDelta_nonUDT2(int button,float lock_threshold);
-CIMGUI_API void ImColor_HSV_nonUDT(ImColor *pOut,ImColor* self,float h,float s,float v,float a);
-CIMGUI_API ImColor_Simple ImColor_HSV_nonUDT2(ImColor* self,float h,float s,float v,float a);
-CIMGUI_API void ImDrawList_GetClipRectMin_nonUDT(ImVec2 *pOut,ImDrawList* self);
-CIMGUI_API ImVec2_Simple ImDrawList_GetClipRectMin_nonUDT2(ImDrawList* self);
-CIMGUI_API void ImDrawList_GetClipRectMax_nonUDT(ImVec2 *pOut,ImDrawList* self);
-CIMGUI_API ImVec2_Simple ImDrawList_GetClipRectMax_nonUDT2(ImDrawList* self);
-CIMGUI_API void ImFont_CalcTextSizeA_nonUDT(ImVec2 *pOut,ImFont* self,float size,float max_width,float wrap_width,const char* text_begin,const char* text_end,const char** remaining);
-CIMGUI_API ImVec2_Simple ImFont_CalcTextSizeA_nonUDT2(ImFont* self,float size,float max_width,float wrap_width,const char* text_begin,const char* text_end,const char** remaining);
+CIMGUI_API bool ImFont_IsGlyphRangeUnused(ImFont* self,unsigned int c_begin,unsigned int c_last);
+CIMGUI_API ImU32 igImHashData(const void* data,size_t data_size,ImU32 seed);
+CIMGUI_API ImU32 igImHashStr(const char* data,size_t data_size,ImU32 seed);
+CIMGUI_API ImU32 igImAlphaBlendColors(ImU32 col_a,ImU32 col_b);
+CIMGUI_API bool igImIsPowerOfTwo(int v);
+CIMGUI_API int igImUpperPowerOfTwo(int v);
+CIMGUI_API int igImStricmp(const char* str1,const char* str2);
+CIMGUI_API int igImStrnicmp(const char* str1,const char* str2,size_t count);
+CIMGUI_API void igImStrncpy(char* dst,const char* src,size_t count);
+CIMGUI_API char* igImStrdup(const char* str);
+CIMGUI_API char* igImStrdupcpy(char* dst,size_t* p_dst_size,const char* str);
+CIMGUI_API const char* igImStrchrRange(const char* str_begin,const char* str_end,char c);
+CIMGUI_API int igImStrlenW(const ImWchar* str);
+CIMGUI_API const char* igImStreolRange(const char* str,const char* str_end);
+CIMGUI_API const ImWchar* igImStrbolW(const ImWchar* buf_mid_line,const ImWchar* buf_begin);
+CIMGUI_API const char* igImStristr(const char* haystack,const char* haystack_end,const char* needle,const char* needle_end);
+CIMGUI_API void igImStrTrimBlanks(char* str);
+CIMGUI_API const char* igImStrSkipBlank(const char* str);
+CIMGUI_API int igImFormatString(char* buf,size_t buf_size,const char* fmt,...);
+CIMGUI_API int igImFormatStringV(char* buf,size_t buf_size,const char* fmt,va_list args);
+CIMGUI_API const char* igImParseFormatFindStart(const char* format);
+CIMGUI_API const char* igImParseFormatFindEnd(const char* format);
+CIMGUI_API const char* igImParseFormatTrimDecorations(const char* format,char* buf,size_t buf_size);
+CIMGUI_API int igImParseFormatPrecision(const char* format,int default_value);
+CIMGUI_API bool igImCharIsBlankA(char c);
+CIMGUI_API bool igImCharIsBlankW(unsigned int c);
+CIMGUI_API int igImTextStrToUtf8(char* buf,int buf_size,const ImWchar* in_text,const ImWchar* in_text_end);
+CIMGUI_API int igImTextCharFromUtf8(unsigned int* out_char,const char* in_text,const char* in_text_end);
+CIMGUI_API int igImTextStrFromUtf8(ImWchar* buf,int buf_size,const char* in_text,const char* in_text_end,const char** in_remaining);
+CIMGUI_API int igImTextCountCharsFromUtf8(const char* in_text,const char* in_text_end);
+CIMGUI_API int igImTextCountUtf8BytesFromChar(const char* in_text,const char* in_text_end);
+CIMGUI_API int igImTextCountUtf8BytesFromStr(const ImWchar* in_text,const ImWchar* in_text_end);
+CIMGUI_API ImFileHandle igImFileOpen(const char* filename,const char* mode);
+CIMGUI_API bool igImFileClose(ImFileHandle file);
+CIMGUI_API ImU64 igImFileGetSize(ImFileHandle file);
+CIMGUI_API ImU64 igImFileRead(void* data,ImU64 size,ImU64 count,ImFileHandle file);
+CIMGUI_API ImU64 igImFileWrite(const void* data,ImU64 size,ImU64 count,ImFileHandle file);
+CIMGUI_API void* igImFileLoadToMemory(const char* filename,const char* mode,size_t* out_file_size,int padding_bytes);
+CIMGUI_API float igImPowFloat(float x,float y);
+CIMGUI_API double igImPowdouble(double x,double y);
+CIMGUI_API void igImMin(ImVec2 *pOut,const ImVec2 lhs,const ImVec2 rhs);
+CIMGUI_API void igImMax(ImVec2 *pOut,const ImVec2 lhs,const ImVec2 rhs);
+CIMGUI_API void igImClamp(ImVec2 *pOut,const ImVec2 v,const ImVec2 mn,ImVec2 mx);
+CIMGUI_API void igImLerpVec2Float(ImVec2 *pOut,const ImVec2 a,const ImVec2 b,float t);
+CIMGUI_API void igImLerpVec2Vec2(ImVec2 *pOut,const ImVec2 a,const ImVec2 b,const ImVec2 t);
+CIMGUI_API void igImLerpVec4(ImVec4 *pOut,const ImVec4 a,const ImVec4 b,float t);
+CIMGUI_API float igImSaturate(float f);
+CIMGUI_API float igImLengthSqrVec2(const ImVec2 lhs);
+CIMGUI_API float igImLengthSqrVec4(const ImVec4 lhs);
+CIMGUI_API float igImInvLength(const ImVec2 lhs,float fail_value);
+CIMGUI_API float igImFloorFloat(float f);
+CIMGUI_API void igImFloorVec2(ImVec2 *pOut,const ImVec2 v);
+CIMGUI_API int igImModPositive(int a,int b);
+CIMGUI_API float igImDot(const ImVec2 a,const ImVec2 b);
+CIMGUI_API void igImRotate(ImVec2 *pOut,const ImVec2 v,float cos_a,float sin_a);
+CIMGUI_API float igImLinearSweep(float current,float target,float speed);
+CIMGUI_API void igImMul(ImVec2 *pOut,const ImVec2 lhs,const ImVec2 rhs);
+CIMGUI_API void igImBezierCalc(ImVec2 *pOut,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,float t);
+CIMGUI_API void igImBezierClosestPoint(ImVec2 *pOut,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,const ImVec2 p,int num_segments);
+CIMGUI_API void igImBezierClosestPointCasteljau(ImVec2 *pOut,const ImVec2 p1,const ImVec2 p2,const ImVec2 p3,const ImVec2 p4,const ImVec2 p,float tess_tol);
+CIMGUI_API void igImLineClosestPoint(ImVec2 *pOut,const ImVec2 a,const ImVec2 b,const ImVec2 p);
+CIMGUI_API bool igImTriangleContainsPoint(const ImVec2 a,const ImVec2 b,const ImVec2 c,const ImVec2 p);
+CIMGUI_API void igImTriangleClosestPoint(ImVec2 *pOut,const ImVec2 a,const ImVec2 b,const ImVec2 c,const ImVec2 p);
+CIMGUI_API void igImTriangleBarycentricCoords(const ImVec2 a,const ImVec2 b,const ImVec2 c,const ImVec2 p,float out_u,float out_v,float out_w);
+CIMGUI_API float igImTriangleArea(const ImVec2 a,const ImVec2 b,const ImVec2 c);
+CIMGUI_API ImGuiDir igImGetDirQuadrantFromDelta(float dx,float dy);
+CIMGUI_API bool igImBitArrayTestBit(const ImU32* arr,int n);
+CIMGUI_API void igImBitArrayClearBit(ImU32* arr,int n);
+CIMGUI_API void igImBitArraySetBit(ImU32* arr,int n);
+CIMGUI_API void igImBitArraySetBitRange(ImU32* arr,int n,int n2);
+CIMGUI_API void ImBitVector_Create(ImBitVector* self,int sz);
+CIMGUI_API void ImBitVector_Clear(ImBitVector* self);
+CIMGUI_API bool ImBitVector_TestBit(ImBitVector* self,int n);
+CIMGUI_API void ImBitVector_SetBit(ImBitVector* self,int n);
+CIMGUI_API void ImBitVector_ClearBit(ImBitVector* self,int n);
+CIMGUI_API ImVec1* ImVec1_ImVec1Nil(void);
+CIMGUI_API void ImVec1_destroy(ImVec1* self);
+CIMGUI_API ImVec1* ImVec1_ImVec1Float(float _x);
+CIMGUI_API ImVec2ih* ImVec2ih_ImVec2ihNil(void);
+CIMGUI_API void ImVec2ih_destroy(ImVec2ih* self);
+CIMGUI_API ImVec2ih* ImVec2ih_ImVec2ihshort(short _x,short _y);
+CIMGUI_API ImVec2ih* ImVec2ih_ImVec2ihVec2(const ImVec2 rhs);
+CIMGUI_API ImRect* ImRect_ImRectNil(void);
+CIMGUI_API void ImRect_destroy(ImRect* self);
+CIMGUI_API ImRect* ImRect_ImRectVec2(const ImVec2 min,const ImVec2 max);
+CIMGUI_API ImRect* ImRect_ImRectVec4(const ImVec4 v);
+CIMGUI_API ImRect* ImRect_ImRectFloat(float x1,float y1,float x2,float y2);
+CIMGUI_API void ImRect_GetCenter(ImVec2 *pOut,ImRect* self);
+CIMGUI_API void ImRect_GetSize(ImVec2 *pOut,ImRect* self);
+CIMGUI_API float ImRect_GetWidth(ImRect* self);
+CIMGUI_API float ImRect_GetHeight(ImRect* self);
+CIMGUI_API void ImRect_GetTL(ImVec2 *pOut,ImRect* self);
+CIMGUI_API void ImRect_GetTR(ImVec2 *pOut,ImRect* self);
+CIMGUI_API void ImRect_GetBL(ImVec2 *pOut,ImRect* self);
+CIMGUI_API void ImRect_GetBR(ImVec2 *pOut,ImRect* self);
+CIMGUI_API bool ImRect_ContainsVec2(ImRect* self,const ImVec2 p);
+CIMGUI_API bool ImRect_ContainsRect(ImRect* self,const ImRect r);
+CIMGUI_API bool ImRect_Overlaps(ImRect* self,const ImRect r);
+CIMGUI_API void ImRect_AddVec2(ImRect* self,const ImVec2 p);
+CIMGUI_API void ImRect_AddRect(ImRect* self,const ImRect r);
+CIMGUI_API void ImRect_ExpandFloat(ImRect* self,const float amount);
+CIMGUI_API void ImRect_ExpandVec2(ImRect* self,const ImVec2 amount);
+CIMGUI_API void ImRect_Translate(ImRect* self,const ImVec2 d);
+CIMGUI_API void ImRect_TranslateX(ImRect* self,float dx);
+CIMGUI_API void ImRect_TranslateY(ImRect* self,float dy);
+CIMGUI_API void ImRect_ClipWith(ImRect* self,const ImRect r);
+CIMGUI_API void ImRect_ClipWithFull(ImRect* self,const ImRect r);
+CIMGUI_API void ImRect_Floor(ImRect* self);
+CIMGUI_API bool ImRect_IsInverted(ImRect* self);
+CIMGUI_API ImGuiStyleMod* ImGuiStyleMod_ImGuiStyleModInt(ImGuiStyleVar idx,int v);
+CIMGUI_API void ImGuiStyleMod_destroy(ImGuiStyleMod* self);
+CIMGUI_API ImGuiStyleMod* ImGuiStyleMod_ImGuiStyleModFloat(ImGuiStyleVar idx,float v);
+CIMGUI_API ImGuiStyleMod* ImGuiStyleMod_ImGuiStyleModVec2(ImGuiStyleVar idx,ImVec2 v);
+CIMGUI_API ImGuiMenuColumns* ImGuiMenuColumns_ImGuiMenuColumns(void);
+CIMGUI_API void ImGuiMenuColumns_destroy(ImGuiMenuColumns* self);
+CIMGUI_API void ImGuiMenuColumns_Update(ImGuiMenuColumns* self,int count,float spacing,bool clear);
+CIMGUI_API float ImGuiMenuColumns_DeclColumns(ImGuiMenuColumns* self,float w0,float w1,float w2);
+CIMGUI_API float ImGuiMenuColumns_CalcExtraSpace(ImGuiMenuColumns* self,float avail_w);
+CIMGUI_API ImGuiInputTextState* ImGuiInputTextState_ImGuiInputTextState(void);
+CIMGUI_API void ImGuiInputTextState_destroy(ImGuiInputTextState* self);
+CIMGUI_API void ImGuiInputTextState_ClearText(ImGuiInputTextState* self);
+CIMGUI_API void ImGuiInputTextState_ClearFreeMemory(ImGuiInputTextState* self);
+CIMGUI_API int ImGuiInputTextState_GetUndoAvailCount(ImGuiInputTextState* self);
+CIMGUI_API int ImGuiInputTextState_GetRedoAvailCount(ImGuiInputTextState* self);
+CIMGUI_API void ImGuiInputTextState_OnKeyPressed(ImGuiInputTextState* self,int key);
+CIMGUI_API void ImGuiInputTextState_CursorAnimReset(ImGuiInputTextState* self);
+CIMGUI_API void ImGuiInputTextState_CursorClamp(ImGuiInputTextState* self);
+CIMGUI_API bool ImGuiInputTextState_HasSelection(ImGuiInputTextState* self);
+CIMGUI_API void ImGuiInputTextState_ClearSelection(ImGuiInputTextState* self);
+CIMGUI_API void ImGuiInputTextState_SelectAll(ImGuiInputTextState* self);
+CIMGUI_API ImGuiWindowSettings* ImGuiWindowSettings_ImGuiWindowSettings(void);
+CIMGUI_API void ImGuiWindowSettings_destroy(ImGuiWindowSettings* self);
+CIMGUI_API char* ImGuiWindowSettings_GetName(ImGuiWindowSettings* self);
+CIMGUI_API ImGuiSettingsHandler* ImGuiSettingsHandler_ImGuiSettingsHandler(void);
+CIMGUI_API void ImGuiSettingsHandler_destroy(ImGuiSettingsHandler* self);
+CIMGUI_API ImGuiPopupData* ImGuiPopupData_ImGuiPopupData(void);
+CIMGUI_API void ImGuiPopupData_destroy(ImGuiPopupData* self);
+CIMGUI_API ImGuiColumnData* ImGuiColumnData_ImGuiColumnData(void);
+CIMGUI_API void ImGuiColumnData_destroy(ImGuiColumnData* self);
+CIMGUI_API ImGuiColumns* ImGuiColumns_ImGuiColumns(void);
+CIMGUI_API void ImGuiColumns_destroy(ImGuiColumns* self);
+CIMGUI_API void ImGuiColumns_Clear(ImGuiColumns* self);
+CIMGUI_API ImDrawListSharedData* ImDrawListSharedData_ImDrawListSharedData(void);
+CIMGUI_API void ImDrawListSharedData_destroy(ImDrawListSharedData* self);
+CIMGUI_API void ImDrawListSharedData_SetCircleSegmentMaxError(ImDrawListSharedData* self,float max_error);
+CIMGUI_API void ImDrawDataBuilder_Clear(ImDrawDataBuilder* self);
+CIMGUI_API void ImDrawDataBuilder_ClearFreeMemory(ImDrawDataBuilder* self);
+CIMGUI_API void ImDrawDataBuilder_FlattenIntoSingleLayer(ImDrawDataBuilder* self);
+CIMGUI_API ImGuiNavMoveResult* ImGuiNavMoveResult_ImGuiNavMoveResult(void);
+CIMGUI_API void ImGuiNavMoveResult_destroy(ImGuiNavMoveResult* self);
+CIMGUI_API void ImGuiNavMoveResult_Clear(ImGuiNavMoveResult* self);
+CIMGUI_API ImGuiNextWindowData* ImGuiNextWindowData_ImGuiNextWindowData(void);
+CIMGUI_API void ImGuiNextWindowData_destroy(ImGuiNextWindowData* self);
+CIMGUI_API void ImGuiNextWindowData_ClearFlags(ImGuiNextWindowData* self);
+CIMGUI_API ImGuiNextItemData* ImGuiNextItemData_ImGuiNextItemData(void);
+CIMGUI_API void ImGuiNextItemData_destroy(ImGuiNextItemData* self);
+CIMGUI_API void ImGuiNextItemData_ClearFlags(ImGuiNextItemData* self);
+CIMGUI_API ImGuiPtrOrIndex* ImGuiPtrOrIndex_ImGuiPtrOrIndexPtr(void* ptr);
+CIMGUI_API void ImGuiPtrOrIndex_destroy(ImGuiPtrOrIndex* self);
+CIMGUI_API ImGuiPtrOrIndex* ImGuiPtrOrIndex_ImGuiPtrOrIndexInt(int index);
+CIMGUI_API ImGuiContext* ImGuiContext_ImGuiContext(ImFontAtlas* shared_font_atlas);
+CIMGUI_API void ImGuiContext_destroy(ImGuiContext* self);
+CIMGUI_API ImGuiWindowTempData* ImGuiWindowTempData_ImGuiWindowTempData(void);
+CIMGUI_API void ImGuiWindowTempData_destroy(ImGuiWindowTempData* self);
+CIMGUI_API ImGuiWindow* ImGuiWindow_ImGuiWindow(ImGuiContext* context,const char* name);
+CIMGUI_API void ImGuiWindow_destroy(ImGuiWindow* self);
+CIMGUI_API ImGuiID ImGuiWindow_GetIDStr(ImGuiWindow* self,const char* str,const char* str_end);
+CIMGUI_API ImGuiID ImGuiWindow_GetIDPtr(ImGuiWindow* self,const void* ptr);
+CIMGUI_API ImGuiID ImGuiWindow_GetIDInt(ImGuiWindow* self,int n);
+CIMGUI_API ImGuiID ImGuiWindow_GetIDNoKeepAliveStr(ImGuiWindow* self,const char* str,const char* str_end);
+CIMGUI_API ImGuiID ImGuiWindow_GetIDNoKeepAlivePtr(ImGuiWindow* self,const void* ptr);
+CIMGUI_API ImGuiID ImGuiWindow_GetIDNoKeepAliveInt(ImGuiWindow* self,int n);
+CIMGUI_API ImGuiID ImGuiWindow_GetIDFromRectangle(ImGuiWindow* self,const ImRect r_abs);
+CIMGUI_API void ImGuiWindow_Rect(ImRect *pOut,ImGuiWindow* self);
+CIMGUI_API float ImGuiWindow_CalcFontSize(ImGuiWindow* self);
+CIMGUI_API float ImGuiWindow_TitleBarHeight(ImGuiWindow* self);
+CIMGUI_API void ImGuiWindow_TitleBarRect(ImRect *pOut,ImGuiWindow* self);
+CIMGUI_API float ImGuiWindow_MenuBarHeight(ImGuiWindow* self);
+CIMGUI_API void ImGuiWindow_MenuBarRect(ImRect *pOut,ImGuiWindow* self);
+CIMGUI_API ImGuiItemHoveredDataBackup* ImGuiItemHoveredDataBackup_ImGuiItemHoveredDataBackup(void);
+CIMGUI_API void ImGuiItemHoveredDataBackup_destroy(ImGuiItemHoveredDataBackup* self);
+CIMGUI_API void ImGuiItemHoveredDataBackup_Backup(ImGuiItemHoveredDataBackup* self);
+CIMGUI_API void ImGuiItemHoveredDataBackup_Restore(ImGuiItemHoveredDataBackup* self);
+CIMGUI_API ImGuiTabItem* ImGuiTabItem_ImGuiTabItem(void);
+CIMGUI_API void ImGuiTabItem_destroy(ImGuiTabItem* self);
+CIMGUI_API ImGuiTabBar* ImGuiTabBar_ImGuiTabBar(void);
+CIMGUI_API void ImGuiTabBar_destroy(ImGuiTabBar* self);
+CIMGUI_API int ImGuiTabBar_GetTabOrder(ImGuiTabBar* self,const ImGuiTabItem* tab);
+CIMGUI_API const char* ImGuiTabBar_GetTabName(ImGuiTabBar* self,const ImGuiTabItem* tab);
+CIMGUI_API ImGuiWindow* igGetCurrentWindowRead(void);
+CIMGUI_API ImGuiWindow* igGetCurrentWindow(void);
+CIMGUI_API ImGuiWindow* igFindWindowByID(ImGuiID id);
+CIMGUI_API ImGuiWindow* igFindWindowByName(const char* name);
+CIMGUI_API void igUpdateWindowParentAndRootLinks(ImGuiWindow* window,ImGuiWindowFlags flags,ImGuiWindow* parent_window);
+CIMGUI_API void igCalcWindowExpectedSize(ImVec2 *pOut,ImGuiWindow* window);
+CIMGUI_API bool igIsWindowChildOf(ImGuiWindow* window,ImGuiWindow* potential_parent);
+CIMGUI_API bool igIsWindowNavFocusable(ImGuiWindow* window);
+CIMGUI_API void igGetWindowAllowedExtentRect(ImRect *pOut,ImGuiWindow* window);
+CIMGUI_API void igSetWindowPosWindowPtr(ImGuiWindow* window,const ImVec2 pos,ImGuiCond cond);
+CIMGUI_API void igSetWindowSizeWindowPtr(ImGuiWindow* window,const ImVec2 size,ImGuiCond cond);
+CIMGUI_API void igSetWindowCollapsedWindowPtr(ImGuiWindow* window,bool collapsed,ImGuiCond cond);
+CIMGUI_API void igFocusWindow(ImGuiWindow* window);
+CIMGUI_API void igFocusTopMostWindowUnderOne(ImGuiWindow* under_this_window,ImGuiWindow* ignore_window);
+CIMGUI_API void igBringWindowToFocusFront(ImGuiWindow* window);
+CIMGUI_API void igBringWindowToDisplayFront(ImGuiWindow* window);
+CIMGUI_API void igBringWindowToDisplayBack(ImGuiWindow* window);
+CIMGUI_API void igSetCurrentFont(ImFont* font);
+CIMGUI_API ImFont* igGetDefaultFont(void);
+CIMGUI_API ImDrawList* igGetForegroundDrawListWindowPtr(ImGuiWindow* window);
+CIMGUI_API void igInitialize(ImGuiContext* context);
+CIMGUI_API void igShutdown(ImGuiContext* context);
+CIMGUI_API void igUpdateHoveredWindowAndCaptureFlags(void);
+CIMGUI_API void igStartMouseMovingWindow(ImGuiWindow* window);
+CIMGUI_API void igUpdateMouseMovingWindowNewFrame(void);
+CIMGUI_API void igUpdateMouseMovingWindowEndFrame(void);
+CIMGUI_API void igMarkIniSettingsDirtyNil(void);
+CIMGUI_API void igMarkIniSettingsDirtyWindowPtr(ImGuiWindow* window);
+CIMGUI_API ImGuiWindowSettings* igCreateNewWindowSettings(const char* name);
+CIMGUI_API ImGuiWindowSettings* igFindWindowSettings(ImGuiID id);
+CIMGUI_API ImGuiWindowSettings* igFindOrCreateWindowSettings(const char* name);
+CIMGUI_API ImGuiSettingsHandler* igFindSettingsHandler(const char* type_name);
+CIMGUI_API void igSetScrollXWindowPtr(ImGuiWindow* window,float new_scroll_x);
+CIMGUI_API void igSetScrollYWindowPtr(ImGuiWindow* window,float new_scroll_y);
+CIMGUI_API void igSetScrollFromPosXWindowPtr(ImGuiWindow* window,float local_x,float center_x_ratio);
+CIMGUI_API void igSetScrollFromPosYWindowPtr(ImGuiWindow* window,float local_y,float center_y_ratio);
+CIMGUI_API void igScrollToBringRectIntoView(ImVec2 *pOut,ImGuiWindow* window,const ImRect item_rect);
+CIMGUI_API ImGuiID igGetItemID(void);
+CIMGUI_API ImGuiItemStatusFlags igGetItemStatusFlags(void);
+CIMGUI_API ImGuiID igGetActiveID(void);
+CIMGUI_API ImGuiID igGetFocusID(void);
+CIMGUI_API void igSetActiveID(ImGuiID id,ImGuiWindow* window);
+CIMGUI_API void igSetFocusID(ImGuiID id,ImGuiWindow* window);
+CIMGUI_API void igClearActiveID(void);
+CIMGUI_API ImGuiID igGetHoveredID(void);
+CIMGUI_API void igSetHoveredID(ImGuiID id);
+CIMGUI_API void igKeepAliveID(ImGuiID id);
+CIMGUI_API void igMarkItemEdited(ImGuiID id);
+CIMGUI_API void igPushOverrideID(ImGuiID id);
+CIMGUI_API void igItemSizeVec2(const ImVec2 size,float text_baseline_y);
+CIMGUI_API void igItemSizeRect(const ImRect bb,float text_baseline_y);
+CIMGUI_API bool igItemAdd(const ImRect bb,ImGuiID id,const ImRect* nav_bb);
+CIMGUI_API bool igItemHoverable(const ImRect bb,ImGuiID id);
+CIMGUI_API bool igIsClippedEx(const ImRect bb,ImGuiID id,bool clip_even_when_logged);
+CIMGUI_API bool igFocusableItemRegister(ImGuiWindow* window,ImGuiID id);
+CIMGUI_API void igFocusableItemUnregister(ImGuiWindow* window);
+CIMGUI_API void igCalcItemSize(ImVec2 *pOut,ImVec2 size,float default_w,float default_h);
+CIMGUI_API float igCalcWrapWidthForPos(const ImVec2 pos,float wrap_pos_x);
+CIMGUI_API void igPushMultiItemsWidths(int components,float width_full);
+CIMGUI_API void igPushItemFlag(ImGuiItemFlags option,bool enabled);
+CIMGUI_API void igPopItemFlag(void);
+CIMGUI_API bool igIsItemToggledSelection(void);
+CIMGUI_API void igGetContentRegionMaxAbs(ImVec2 *pOut);
+CIMGUI_API void igShrinkWidths(ImGuiShrinkWidthItem* items,int count,float width_excess);
+CIMGUI_API void igLogBegin(ImGuiLogType type,int auto_open_depth);
+CIMGUI_API void igLogToBuffer(int auto_open_depth);
+CIMGUI_API bool igBeginChildEx(const char* name,ImGuiID id,const ImVec2 size_arg,bool border,ImGuiWindowFlags flags);
+CIMGUI_API void igOpenPopupEx(ImGuiID id);
+CIMGUI_API void igClosePopupToLevel(int remaining,bool restore_focus_to_window_under_popup);
+CIMGUI_API void igClosePopupsOverWindow(ImGuiWindow* ref_window,bool restore_focus_to_window_under_popup);
+CIMGUI_API bool igIsPopupOpenID(ImGuiID id);
+CIMGUI_API bool igBeginPopupEx(ImGuiID id,ImGuiWindowFlags extra_flags);
+CIMGUI_API void igBeginTooltipEx(ImGuiWindowFlags extra_flags,ImGuiTooltipFlags tooltip_flags);
+CIMGUI_API ImGuiWindow* igGetTopMostPopupModal(void);
+CIMGUI_API void igFindBestWindowPosForPopup(ImVec2 *pOut,ImGuiWindow* window);
+CIMGUI_API void igFindBestWindowPosForPopupEx(ImVec2 *pOut,const ImVec2 ref_pos,const ImVec2 size,ImGuiDir* last_dir,const ImRect r_outer,const ImRect r_avoid,ImGuiPopupPositionPolicy policy);
+CIMGUI_API void igNavInitWindow(ImGuiWindow* window,bool force_reinit);
+CIMGUI_API bool igNavMoveRequestButNoResultYet(void);
+CIMGUI_API void igNavMoveRequestCancel(void);
+CIMGUI_API void igNavMoveRequestForward(ImGuiDir move_dir,ImGuiDir clip_dir,const ImRect bb_rel,ImGuiNavMoveFlags move_flags);
+CIMGUI_API void igNavMoveRequestTryWrapping(ImGuiWindow* window,ImGuiNavMoveFlags move_flags);
+CIMGUI_API float igGetNavInputAmount(ImGuiNavInput n,ImGuiInputReadMode mode);
+CIMGUI_API void igGetNavInputAmount2d(ImVec2 *pOut,ImGuiNavDirSourceFlags dir_sources,ImGuiInputReadMode mode,float slow_factor,float fast_factor);
+CIMGUI_API int igCalcTypematicRepeatAmount(float t0,float t1,float repeat_delay,float repeat_rate);
+CIMGUI_API void igActivateItem(ImGuiID id);
+CIMGUI_API void igSetNavID(ImGuiID id,int nav_layer,ImGuiID focus_scope_id);
+CIMGUI_API void igSetNavIDWithRectRel(ImGuiID id,int nav_layer,ImGuiID focus_scope_id,const ImRect rect_rel);
+CIMGUI_API void igPushFocusScope(ImGuiID id);
+CIMGUI_API void igPopFocusScope(void);
+CIMGUI_API ImGuiID igGetFocusScopeID(void);
+CIMGUI_API bool igIsActiveIdUsingNavDir(ImGuiDir dir);
+CIMGUI_API bool igIsActiveIdUsingNavInput(ImGuiNavInput input);
+CIMGUI_API bool igIsActiveIdUsingKey(ImGuiKey key);
+CIMGUI_API bool igIsMouseDragPastThreshold(ImGuiMouseButton button,float lock_threshold);
+CIMGUI_API bool igIsKeyPressedMap(ImGuiKey key,bool repeat);
+CIMGUI_API bool igIsNavInputDown(ImGuiNavInput n);
+CIMGUI_API bool igIsNavInputTest(ImGuiNavInput n,ImGuiInputReadMode rm);
+CIMGUI_API ImGuiKeyModFlags igGetMergedKeyModFlags(void);
+CIMGUI_API bool igBeginDragDropTargetCustom(const ImRect bb,ImGuiID id);
+CIMGUI_API void igClearDragDrop(void);
+CIMGUI_API bool igIsDragDropPayloadBeingAccepted(void);
+CIMGUI_API void igBeginColumns(const char* str_id,int count,ImGuiColumnsFlags flags);
+CIMGUI_API void igEndColumns(void);
+CIMGUI_API void igPushColumnClipRect(int column_index);
+CIMGUI_API void igPushColumnsBackground(void);
+CIMGUI_API void igPopColumnsBackground(void);
+CIMGUI_API ImGuiID igGetColumnsID(const char* str_id,int count);
+CIMGUI_API ImGuiColumns* igFindOrCreateColumns(ImGuiWindow* window,ImGuiID id);
+CIMGUI_API float igGetColumnOffsetFromNorm(const ImGuiColumns* columns,float offset_norm);
+CIMGUI_API float igGetColumnNormFromOffset(const ImGuiColumns* columns,float offset);
+CIMGUI_API bool igBeginTabBarEx(ImGuiTabBar* tab_bar,const ImRect bb,ImGuiTabBarFlags flags);
+CIMGUI_API ImGuiTabItem* igTabBarFindTabByID(ImGuiTabBar* tab_bar,ImGuiID tab_id);
+CIMGUI_API void igTabBarRemoveTab(ImGuiTabBar* tab_bar,ImGuiID tab_id);
+CIMGUI_API void igTabBarCloseTab(ImGuiTabBar* tab_bar,ImGuiTabItem* tab);
+CIMGUI_API void igTabBarQueueChangeTabOrder(ImGuiTabBar* tab_bar,const ImGuiTabItem* tab,int dir);
+CIMGUI_API bool igTabItemEx(ImGuiTabBar* tab_bar,const char* label,bool* p_open,ImGuiTabItemFlags flags);
+CIMGUI_API void igTabItemCalcSize(ImVec2 *pOut,const char* label,bool has_close_button);
+CIMGUI_API void igTabItemBackground(ImDrawList* draw_list,const ImRect bb,ImGuiTabItemFlags flags,ImU32 col);
+CIMGUI_API bool igTabItemLabelAndCloseButton(ImDrawList* draw_list,const ImRect bb,ImGuiTabItemFlags flags,ImVec2 frame_padding,const char* label,ImGuiID tab_id,ImGuiID close_button_id);
+CIMGUI_API void igRenderText(ImVec2 pos,const char* text,const char* text_end,bool hide_text_after_hash);
+CIMGUI_API void igRenderTextWrapped(ImVec2 pos,const char* text,const char* text_end,float wrap_width);
+CIMGUI_API void igRenderTextClipped(const ImVec2 pos_min,const ImVec2 pos_max,const char* text,const char* text_end,const ImVec2* text_size_if_known,const ImVec2 align,const ImRect* clip_rect);
+CIMGUI_API void igRenderTextClippedEx(ImDrawList* draw_list,const ImVec2 pos_min,const ImVec2 pos_max,const char* text,const char* text_end,const ImVec2* text_size_if_known,const ImVec2 align,const ImRect* clip_rect);
+CIMGUI_API void igRenderTextEllipsis(ImDrawList* draw_list,const ImVec2 pos_min,const ImVec2 pos_max,float clip_max_x,float ellipsis_max_x,const char* text,const char* text_end,const ImVec2* text_size_if_known);
+CIMGUI_API void igRenderFrame(ImVec2 p_min,ImVec2 p_max,ImU32 fill_col,bool border,float rounding);
+CIMGUI_API void igRenderFrameBorder(ImVec2 p_min,ImVec2 p_max,float rounding);
+CIMGUI_API void igRenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list,ImVec2 p_min,ImVec2 p_max,ImU32 fill_col,float grid_step,ImVec2 grid_off,float rounding,int rounding_corners_flags);
+CIMGUI_API void igRenderNavHighlight(const ImRect bb,ImGuiID id,ImGuiNavHighlightFlags flags);
+CIMGUI_API const char* igFindRenderedTextEnd(const char* text,const char* text_end);
+CIMGUI_API void igLogRenderedText(const ImVec2* ref_pos,const char* text,const char* text_end);
+CIMGUI_API void igRenderArrow(ImDrawList* draw_list,ImVec2 pos,ImU32 col,ImGuiDir dir,float scale);
+CIMGUI_API void igRenderBullet(ImDrawList* draw_list,ImVec2 pos,ImU32 col);
+CIMGUI_API void igRenderCheckMark(ImDrawList* draw_list,ImVec2 pos,ImU32 col,float sz);
+CIMGUI_API void igRenderMouseCursor(ImDrawList* draw_list,ImVec2 pos,float scale,ImGuiMouseCursor mouse_cursor,ImU32 col_fill,ImU32 col_border,ImU32 col_shadow);
+CIMGUI_API void igRenderArrowPointingAt(ImDrawList* draw_list,ImVec2 pos,ImVec2 half_sz,ImGuiDir direction,ImU32 col);
+CIMGUI_API void igRenderRectFilledRangeH(ImDrawList* draw_list,const ImRect rect,ImU32 col,float x_start_norm,float x_end_norm,float rounding);
+CIMGUI_API void igTextEx(const char* text,const char* text_end,ImGuiTextFlags flags);
+CIMGUI_API bool igButtonEx(const char* label,const ImVec2 size_arg,ImGuiButtonFlags flags);
+CIMGUI_API bool igCloseButton(ImGuiID id,const ImVec2 pos);
+CIMGUI_API bool igCollapseButton(ImGuiID id,const ImVec2 pos);
+CIMGUI_API bool igArrowButtonEx(const char* str_id,ImGuiDir dir,ImVec2 size_arg,ImGuiButtonFlags flags);
+CIMGUI_API void igScrollbar(ImGuiAxis axis);
+CIMGUI_API bool igScrollbarEx(const ImRect bb,ImGuiID id,ImGuiAxis axis,float* p_scroll_v,float avail_v,float contents_v,ImDrawCornerFlags rounding_corners);
+CIMGUI_API void igGetWindowScrollbarRect(ImRect *pOut,ImGuiWindow* window,ImGuiAxis axis);
+CIMGUI_API ImGuiID igGetWindowScrollbarID(ImGuiWindow* window,ImGuiAxis axis);
+CIMGUI_API ImGuiID igGetWindowResizeID(ImGuiWindow* window,int n);
+CIMGUI_API void igSeparatorEx(ImGuiSeparatorFlags flags);
+CIMGUI_API bool igButtonBehavior(const ImRect bb,ImGuiID id,bool* out_hovered,bool* out_held,ImGuiButtonFlags flags);
+CIMGUI_API bool igDragBehavior(ImGuiID id,ImGuiDataType data_type,void* p_v,float v_speed,const void* p_min,const void* p_max,const char* format,float power,ImGuiDragFlags flags);
+CIMGUI_API bool igSliderBehavior(const ImRect bb,ImGuiID id,ImGuiDataType data_type,void* p_v,const void* p_min,const void* p_max,const char* format,float power,ImGuiSliderFlags flags,ImRect* out_grab_bb);
+CIMGUI_API bool igSplitterBehavior(const ImRect bb,ImGuiID id,ImGuiAxis axis,float* size1,float* size2,float min_size1,float min_size2,float hover_extend,float hover_visibility_delay);
+CIMGUI_API bool igTreeNodeBehavior(ImGuiID id,ImGuiTreeNodeFlags flags,const char* label,const char* label_end);
+CIMGUI_API bool igTreeNodeBehaviorIsOpen(ImGuiID id,ImGuiTreeNodeFlags flags);
+CIMGUI_API void igTreePushOverrideID(ImGuiID id);
+CIMGUI_API const ImGuiDataTypeInfo* igDataTypeGetInfo(ImGuiDataType data_type);
+CIMGUI_API int igDataTypeFormatString(char* buf,int buf_size,ImGuiDataType data_type,const void* p_data,const char* format);
+CIMGUI_API void igDataTypeApplyOp(ImGuiDataType data_type,int op,void* output,void* arg_1,const void* arg_2);
+CIMGUI_API bool igDataTypeApplyOpFromText(const char* buf,const char* initial_value_buf,ImGuiDataType data_type,void* p_data,const char* format);
+CIMGUI_API bool igInputTextEx(const char* label,const char* hint,char* buf,int buf_size,const ImVec2 size_arg,ImGuiInputTextFlags flags,ImGuiInputTextCallback callback,void* user_data);
+CIMGUI_API bool igTempInputText(const ImRect bb,ImGuiID id,const char* label,char* buf,int buf_size,ImGuiInputTextFlags flags);
+CIMGUI_API bool igTempInputScalar(const ImRect bb,ImGuiID id,const char* label,ImGuiDataType data_type,void* p_data,const char* format);
+CIMGUI_API bool igTempInputIsActive(ImGuiID id);
+CIMGUI_API ImGuiInputTextState* igGetInputTextState(ImGuiID id);
+CIMGUI_API void igColorTooltip(const char* text,const float* col,ImGuiColorEditFlags flags);
+CIMGUI_API void igColorEditOptionsPopup(const float* col,ImGuiColorEditFlags flags);
+CIMGUI_API void igColorPickerOptionsPopup(const float* ref_col,ImGuiColorEditFlags flags);
+CIMGUI_API int igPlotEx(ImGuiPlotType plot_type,const char* label,float(*values_getter)(void* data,int idx),void* data,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 frame_size);
+CIMGUI_API void igShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list,int vert_start_idx,int vert_end_idx,ImVec2 gradient_p0,ImVec2 gradient_p1,ImU32 col0,ImU32 col1);
+CIMGUI_API void igShadeVertsLinearUV(ImDrawList* draw_list,int vert_start_idx,int vert_end_idx,const ImVec2 a,const ImVec2 b,const ImVec2 uv_a,const ImVec2 uv_b,bool clamp);
+CIMGUI_API void igGcCompactTransientWindowBuffers(ImGuiWindow* window);
+CIMGUI_API void igGcAwakeTransientWindowBuffers(ImGuiWindow* window);
+CIMGUI_API void igDebugDrawItemRect(ImU32 col);
+CIMGUI_API void igDebugStartItemPicker(void);
+CIMGUI_API bool igImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas);
+CIMGUI_API void igImFontAtlasBuildInit(ImFontAtlas* atlas);
+CIMGUI_API void igImFontAtlasBuildSetupFont(ImFontAtlas* atlas,ImFont* font,ImFontConfig* font_config,float ascent,float descent);
+CIMGUI_API void igImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas,void* stbrp_context_opaque);
+CIMGUI_API void igImFontAtlasBuildFinish(ImFontAtlas* atlas);
+CIMGUI_API void igImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256],float in_multiply_factor);
+CIMGUI_API void igImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256],unsigned char* pixels,int x,int y,int w,int h,int stride);
/////////////////////////hand written functions
@@ -1670,10 +2712,13 @@ CIMGUI_API float igGET_FLT_MAX();
CIMGUI_API void igColorConvertRGBtoHSV(float r,float g,float b,float *out_h,float *out_s,float *out_v);
CIMGUI_API void igColorConvertHSVtoRGB(float h,float s,float v,float *out_r,float *out_g,float *out_b);
+
CIMGUI_API ImVector_ImWchar* ImVector_ImWchar_create();
CIMGUI_API void ImVector_ImWchar_destroy(ImVector_ImWchar* self);
CIMGUI_API void ImVector_ImWchar_Init(ImVector_ImWchar* p);
CIMGUI_API void ImVector_ImWchar_UnInit(ImVector_ImWchar* p);
+
+
#endif //CIMGUI_INCLUDED
diff --git a/Sources/Demos/Metal/ViewController.swift b/Sources/Demos/Metal/ViewController.swift
index 5f0b1fc..6143194 100644
--- a/Sources/Demos/Metal/ViewController.swift
+++ b/Sources/Demos/Metal/ViewController.swift
@@ -41,8 +41,7 @@ final class ViewController: NSViewController {
// we receive events for all controls, not just Dear ImGui widgets. If we had native controls in our
// window, we'd want to be much more careful than just ingesting the complete event stream, though we
// do make an effort to be good citizens by passing along events when Dear ImGui doesn't want to capture.
- let eventMask: NSEvent.EventTypeMask = [ .keyDown, .keyUp, .flagsChanged, .scrollWheel ]
- NSEvent.addLocalMonitorForEvents(matching: eventMask) { [unowned self](event) -> NSEvent? in
+ NSEvent.addLocalMonitorForEvents(matching: .any) { [unowned self](event) -> NSEvent? in
let wantsCapture: Bool = ImGui_ImplOSX_HandleEvent(event, self.view)
if event.type == .keyDown && wantsCapture {
return nil
diff --git a/Sources/Demos/Metal/imgui_impl_metal.swift b/Sources/Demos/Metal/imgui_impl_metal.swift
index 8ee9411..1c7992d 100644
--- a/Sources/Demos/Metal/imgui_impl_metal.swift
+++ b/Sources/Demos/Metal/imgui_impl_metal.swift
@@ -303,10 +303,10 @@ class MetalContext {
[0.0, 0.0, 1/(F-N), 0.0],
[(R+L)/(L-R), (T+B)/(B-T), N/(F-N), 1.0])
- commandEncoder.setVertexBytes(UnsafeRawPointer(&ortho_projection),
- length: MemoryLayout.size,
- index: 1)
-
+ withUnsafeMutablePointer(to: &ortho_projection) {
+ commandEncoder.setVertexBytes($0, length: MemoryLayout.size, index: 1)
+ }
+
commandEncoder.setRenderPipelineState(renderPipelineState)
commandEncoder.setVertexBuffer(vertexBuffer.buffer, offset: 0, index: 0)
diff --git a/Sources/Demos/Metal/imgui_impl_osx.swift b/Sources/Demos/Metal/imgui_impl_osx.swift
index 4fedf33..b1c20eb 100644
--- a/Sources/Demos/Metal/imgui_impl_osx.swift
+++ b/Sources/Demos/Metal/imgui_impl_osx.swift
@@ -16,10 +16,9 @@ var g_MouseCursorHidden: Bool = false
func ImGui_ImplOSX_Init() {
let io = ImGuiGetIO()!
-
- io.pointee.ConfigFlags |= Int32(ImGuiConfigFlags_DockingEnable.rawValue)
- io.pointee.ConfigFlags |= Int32(ImGuiConfigFlags_DpiEnableScaleViewports.rawValue)
- io.pointee.ConfigFlags |= Int32(ImGuiConfigFlags_DpiEnableScaleFonts.rawValue)
+ //io.pointee.ConfigFlags |= Int32(ImGuiConfigFlags_DockingEnable.rawValue)
+ //io.pointee.ConfigFlags |= Int32(ImGuiConfigFlags_DpiEnableScaleViewports.rawValue)
+ //io.pointee.ConfigFlags |= Int32(ImGuiConfigFlags_DpiEnableScaleFonts.rawValue)
// Setup back-end capabilities flags
io.pointee.BackendFlags |= Int32(ImGuiBackendFlags_HasMouseCursors.rawValue) // We can honor GetMouseCursor() values (optional)
@@ -32,30 +31,31 @@ func ImGui_ImplOSX_Init() {
// Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
let offset_for_function_keys: Int32 = 256 - 0xF700
- var keyMap = CArray(&io.pointee.KeyMap)
-
- keyMap[ImGuiKey_Tab] = Int32(Character("\t").asciiValue!)
- keyMap[ImGuiKey_LeftArrow] = Int32(NSLeftArrowFunctionKey) + offset_for_function_keys
- keyMap[ImGuiKey_RightArrow] = Int32(NSRightArrowFunctionKey) + offset_for_function_keys
- keyMap[ImGuiKey_UpArrow] = Int32(NSUpArrowFunctionKey) + offset_for_function_keys
- keyMap[ImGuiKey_DownArrow] = Int32(NSDownArrowFunctionKey) + offset_for_function_keys
- keyMap[ImGuiKey_PageUp] = Int32(NSPageUpFunctionKey) + offset_for_function_keys
- keyMap[ImGuiKey_PageDown] = Int32(NSPageDownFunctionKey) + offset_for_function_keys
- keyMap[ImGuiKey_Home] = Int32(NSHomeFunctionKey) + offset_for_function_keys
- keyMap[ImGuiKey_End] = Int32(NSEndFunctionKey) + offset_for_function_keys
- keyMap[ImGuiKey_Insert] = Int32(NSInsertFunctionKey) + offset_for_function_keys
- keyMap[ImGuiKey_Delete] = Int32(NSDeleteFunctionKey) + offset_for_function_keys
- keyMap[ImGuiKey_Backspace] = 127
- keyMap[ImGuiKey_Space] = 32
- keyMap[ImGuiKey_Enter] = 13
- keyMap[ImGuiKey_Escape] = 27
- keyMap[ImGuiKey_KeyPadEnter] = 13
- keyMap[ImGuiKey_A] = Int32(Character("A").asciiValue!)
- keyMap[ImGuiKey_C] = Int32(Character("C").asciiValue!)
- keyMap[ImGuiKey_V] = Int32(Character("V").asciiValue!)
- keyMap[ImGuiKey_X] = Int32(Character("X").asciiValue!)
- keyMap[ImGuiKey_Y] = Int32(Character("Y").asciiValue!)
- keyMap[ImGuiKey_Z] = Int32(Character("Z").asciiValue!)
+
+ CArray.write(&io.pointee.KeyMap) { keyMap in
+ keyMap[Int(ImGuiKey_Tab.rawValue)] = Int32(Character("\t").asciiValue!)
+ keyMap[Int(ImGuiKey_LeftArrow.rawValue)] = Int32(NSLeftArrowFunctionKey) + offset_for_function_keys
+ keyMap[Int(ImGuiKey_RightArrow.rawValue)] = Int32(NSRightArrowFunctionKey) + offset_for_function_keys
+ keyMap[Int(ImGuiKey_UpArrow.rawValue)] = Int32(NSUpArrowFunctionKey) + offset_for_function_keys
+ keyMap[Int(ImGuiKey_DownArrow.rawValue)] = Int32(NSDownArrowFunctionKey) + offset_for_function_keys
+ keyMap[Int(ImGuiKey_PageUp.rawValue)] = Int32(NSPageUpFunctionKey) + offset_for_function_keys
+ keyMap[Int(ImGuiKey_PageDown.rawValue)] = Int32(NSPageDownFunctionKey) + offset_for_function_keys
+ keyMap[Int(ImGuiKey_Home.rawValue)] = Int32(NSHomeFunctionKey) + offset_for_function_keys
+ keyMap[Int(ImGuiKey_End.rawValue)] = Int32(NSEndFunctionKey) + offset_for_function_keys
+ keyMap[Int(ImGuiKey_Insert.rawValue)] = Int32(NSInsertFunctionKey) + offset_for_function_keys
+ keyMap[Int(ImGuiKey_Delete.rawValue)] = Int32(NSDeleteFunctionKey) + offset_for_function_keys
+ keyMap[Int(ImGuiKey_Backspace.rawValue)] = 127
+ keyMap[Int(ImGuiKey_Space.rawValue)] = 32
+ keyMap[Int(ImGuiKey_Enter.rawValue)] = 13
+ keyMap[Int(ImGuiKey_Escape.rawValue)] = 27
+ keyMap[Int(ImGuiKey_KeyPadEnter.rawValue)] = 13
+ keyMap[Int(ImGuiKey_A.rawValue)] = Int32(Character("A").asciiValue!)
+ keyMap[Int(ImGuiKey_C.rawValue)] = Int32(Character("C").asciiValue!)
+ keyMap[Int(ImGuiKey_V.rawValue)] = Int32(Character("V").asciiValue!)
+ keyMap[Int(ImGuiKey_X.rawValue)] = Int32(Character("X").asciiValue!)
+ keyMap[Int(ImGuiKey_Y.rawValue)] = Int32(Character("Y").asciiValue!)
+ keyMap[Int(ImGuiKey_Z.rawValue)] = Int32(Character("Z").asciiValue!)
+ }
// Load cursors. Some of them are undocumented.
g_MouseCursorHidden = false
@@ -126,12 +126,15 @@ func ImGui_ImplOSX_UpdateMouseCursor() {
}
func set(_ tuple: inout (T, T, T, T, T), value: T, at index: Int) {
- UnsafeMutableBufferPointer(start: &tuple.0, count: MemoryLayout.size(ofValue: tuple))[index] = value
+ withUnsafeMutablePointer(to: &tuple.0) {
+ $0[index] = value
+ }
}
func get(value tuple: inout (T, T, T, T, T), at index: Int) -> T {
- let ptr = UnsafeMutableBufferPointer(start: &tuple.0, count: MemoryLayout.size(ofValue: tuple))
- return ptr[index]
+ return withUnsafeMutablePointer(to: &tuple.0) {
+ return $0[index]
+ }
}
@discardableResult func ImGui_ImplOSX_HandleEvent(_ event: NSEvent, _ view: NSView) -> Bool {
@@ -139,21 +142,21 @@ func get(value tuple: inout (T, T, T, T, T), at index: Int) -> T {
if event.type == .leftMouseDown || event.type == .rightMouseDown || event.type == .otherMouseDown {
let button = event.buttonNumber
- var mouseButtons = CArray(&io.pointee.MouseDown)
- if button >= 0 && button < mouseButtons.count {
- mouseButtons[button] = true
+ CArray.write(&io.pointee.MouseDown) { mouseButtons in
+ if button >= 0 && button < mouseButtons.count {
+ mouseButtons[Int(button)] = true
+ }
}
-
return io.pointee.WantCaptureMouse
}
if event.type == .leftMouseUp || event.type == .rightMouseUp || event.type == .otherMouseUp {
let button = event.buttonNumber
- var mouseButtons = CArray(&io.pointee.MouseDown)
- if button >= 0 && button < mouseButtons.count {
- mouseButtons[button] = false
+ CArray.write(&io.pointee.MouseDown) { mouseButtons in
+ if button >= 0 && button < mouseButtons.count {
+ mouseButtons[button] = false
+ }
}
-
return io.pointee.WantCaptureMouse
}
@@ -247,8 +250,10 @@ func get(value tuple: inout (T, T, T, T, T), at index: Int) -> T {
func resetKeys() {
let io = ImGuiGetIO()!
- var keysDown = CArray(&io.pointee.KeysDown)
- for n in 0...write(&io.pointee.KeysDown) { keysDown in
+ for n in 0..(_ strings: [String], _ body:
}
/// https://forums.developer.apple.com/thread/72120
-public struct CArray {
- @usableFromInline var ptr: UnsafeMutableBufferPointer
-
- public init(_ start: inout T, _ count: Int) {
- ptr = UnsafeMutableBufferPointer(start: &start, count: count)
- }
-
- public var count: Int {
- ptr.count
- }
-
- public subscript(index: I) -> T where I: FixedWidthInteger {
- get {
- ptr[Int(index)]
- }
- set {
- ptr[Int(index)] = newValue
+/// https://forums.swift.org/t/fixed-size-array-hacks/32962/4
+/// https://github.com/stephentyrone/swift-numerics/blob/static-array/Sources/StaticArray/StaticArray.swift
+public enum CArray {
+ @discardableResult
+ @_transparent
+ public static func write(_ cArray: inout C, _ body: (UnsafeMutableBufferPointer) throws -> O) rethrows -> O {
+ try withUnsafeMutablePointer(to: &cArray) {
+ try body(UnsafeMutableBufferPointer(start: UnsafeMutableRawPointer($0).assumingMemoryBound(to: T.self),
+ count: (MemoryLayout.stride / MemoryLayout.stride)))
}
}
- public subscript(representable: R) -> T where R: RawRepresentable, R.RawValue: FixedWidthInteger {
- get {
- self[representable.rawValue]
- }
- set {
- self[representable.rawValue] = newValue
+ @discardableResult
+ @_transparent
+ public static func read(_ cArray: C, _ body: (UnsafeBufferPointer) throws -> O) rethrows -> O {
+ try withUnsafePointer(to: cArray) {
+ try body(UnsafeBufferPointer(start: UnsafeRawPointer($0).assumingMemoryBound(to: T.self),
+ count: (MemoryLayout.stride / MemoryLayout.stride)))
}
}
}
-// swiftlint:disable large_tuple
-extension CArray {
- public init(_ cArray: inout (T, T)) {
- self.init(&cArray.0, MemoryLayout.size(ofValue: cArray))
- }
-
- public init(_ cArray: inout (T, T, T)) {
- self.init(&cArray.0, MemoryLayout.size(ofValue: cArray))
- }
-
- public init(_ cArray: inout (T, T, T, T)) {
- self.init(&cArray.0, MemoryLayout.size(ofValue: cArray))
- }
-
- public init(_ cArray: inout (T, T, T, T, T)) {
- self.init(&cArray.0, MemoryLayout.size(ofValue: cArray))
- }
-
- public init(_ cArray: inout (T, T, T, T, T, T)) {
- self.init(&cArray.0, MemoryLayout.size(ofValue: cArray))
- }
-
- public init(_ cArray: inout (T, T, T, T, T, T, T)) {
- self.init(&cArray.0, MemoryLayout.size(ofValue: cArray))
- }
-
- public init(_ cArray: inout (T, T, T, T, T, T, T, T)) {
- self.init(&cArray.0, MemoryLayout.size(ofValue: cArray))
- }
-
- public init(_ cArray: inout (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) {
- self.init(&cArray.0, MemoryLayout.size(ofValue: cArray))
- }
-
- // swiftlint:disable:next line_length
- public init(_ cArray: inout (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) {
- self.init(&cArray.0, MemoryLayout.size(ofValue: cArray))
- }
-}
-
/// Offset of _MEMBER within _TYPE. Standardized as offsetof() in modern C++.
public func IM_OFFSETOF(_ member: PartialKeyPath) -> Int {
MemoryLayout.offset(of: member)!
diff --git a/Sources/ImGui/ImGui+Definitions.swift b/Sources/ImGui/ImGui+Definitions.swift
index 75dac1e..0c26152 100644
--- a/Sources/ImGui/ImGui+Definitions.swift
+++ b/Sources/ImGui/ImGui+Definitions.swift
@@ -5,26 +5,98 @@ import CImGui
// swiftlint:disable identifier_name
// Undeclared type definitions
-public typealias ImDrawListSharedData = OpaquePointer
-public typealias ImGuiContext = OpaquePointer
+public typealias ImChunkStream = OpaquePointer
+public typealias ImPool = OpaquePointer
-@inlinable public func ImColorHSV(_ this: UnsafeMutablePointer!, _ h: Float, _ s: Float, _ v: Float, _ a: Float) -> ImColor {
- return ImColor_HSV(this,h,s,v,a)
+@inlinable public func ImAlphaBlendColors(_ col_a: ImU32, _ col_b: ImU32) -> ImU32 {
+ return igImAlphaBlendColors(col_a,col_b)
}
-@inlinable public func ImColorHSVnonUDT(_ pOut: UnsafeMutablePointer!, _ this: UnsafeMutablePointer!, _ h: Float, _ s: Float, _ v: Float, _ a: Float) -> Void {
- return ImColor_HSV_nonUDT(pOut,this,h,s,v,a)
+@inlinable public func ImBezierCalc(_ pOut: UnsafeMutablePointer!, _ p1: ImVec2, _ p2: ImVec2, _ p3: ImVec2, _ p4: ImVec2, _ t: Float) -> Void {
+ return igImBezierCalc(pOut,p1,p2,p3,p4,t)
}
-@inlinable public func ImColorHSVnonUDT2(_ this: UnsafeMutablePointer!, _ h: Float, _ s: Float, _ v: Float, _ a: Float) -> ImColor_Simple {
- return ImColor_HSV_nonUDT2(this,h,s,v,a)
+@inlinable public func ImBezierClosestPoint(_ pOut: UnsafeMutablePointer!, _ p1: ImVec2, _ p2: ImVec2, _ p3: ImVec2, _ p4: ImVec2, _ p: ImVec2, _ num_segments: Int32) -> Void {
+ return igImBezierClosestPoint(pOut,p1,p2,p3,p4,p,num_segments)
+}
+
+@inlinable public func ImBezierClosestPointCasteljau(_ pOut: UnsafeMutablePointer!, _ p1: ImVec2, _ p2: ImVec2, _ p3: ImVec2, _ p4: ImVec2, _ p: ImVec2, _ tess_tol: Float) -> Void {
+ return igImBezierClosestPointCasteljau(pOut,p1,p2,p3,p4,p,tess_tol)
+}
+
+@inlinable public func ImBitArrayClearBit(_ arr: UnsafeMutablePointer!, _ n: Int32) -> Void {
+ return igImBitArrayClearBit(arr,n)
+}
+
+@inlinable public func ImBitArraySetBit(_ arr: UnsafeMutablePointer!, _ n: Int32) -> Void {
+ return igImBitArraySetBit(arr,n)
+}
+
+@inlinable public func ImBitArraySetBitRange(_ arr: UnsafeMutablePointer!, _ n: Int32, _ n2: Int32) -> Void {
+ return igImBitArraySetBitRange(arr,n,n2)
+}
+
+@inlinable @discardableResult public func ImBitArrayTestBit(_ arr: UnsafePointer!, _ n: Int32) -> Bool {
+ return igImBitArrayTestBit(arr,n)
+}
+
+@inlinable public func ImBitVectorClear(_ this: UnsafeMutablePointer!) -> Void {
+ return ImBitVector_Clear(this)
+}
+
+@inlinable public func ImBitVectorClearBit(_ this: UnsafeMutablePointer!, _ n: Int32) -> Void {
+ return ImBitVector_ClearBit(this,n)
+}
+
+@inlinable public func ImBitVectorCreate(_ this: UnsafeMutablePointer!, _ sz: Int32) -> Void {
+ return ImBitVector_Create(this,sz)
+}
+
+@inlinable public func ImBitVectorSetBit(_ this: UnsafeMutablePointer!, _ n: Int32) -> Void {
+ return ImBitVector_SetBit(this,n)
+}
+
+@inlinable @discardableResult public func ImBitVectorTestBit(_ this: UnsafeMutablePointer!, _ n: Int32) -> Bool {
+ return ImBitVector_TestBit(this,n)
+}
+
+@inlinable @discardableResult public func ImCharIsBlankA(_ c: CChar) -> Bool {
+ return igImCharIsBlankA(c)
+}
+
+@inlinable @discardableResult public func ImCharIsBlankW(_ c: UInt32) -> Bool {
+ return igImCharIsBlankW(c)
+}
+
+@inlinable public func ImClamp(_ pOut: UnsafeMutablePointer!, _ v: ImVec2, _ mn: ImVec2, _ mx: ImVec2) -> Void {
+ return igImClamp(pOut,v,mn,mx)
+}
+
+@inlinable public func ImColorHSV(_ pOut: UnsafeMutablePointer!, _ this: UnsafeMutablePointer!, _ h: Float, _ s: Float, _ v: Float, _ a: Float) -> Void {
+ return ImColor_HSV(pOut,this,h,s,v,a)
}
@inlinable public func ImColorSetHSV(_ this: UnsafeMutablePointer!, _ h: Float, _ s: Float, _ v: Float, _ a: Float) -> Void {
return ImColor_SetHSV(this,h,s,v,a)
}
+@inlinable public func ImDot(_ a: ImVec2, _ b: ImVec2) -> Float {
+ return igImDot(a,b)
+}
+
+@inlinable public func ImDrawDataBuilderClear(_ this: UnsafeMutablePointer!) -> Void {
+ return ImDrawDataBuilder_Clear(this)
+}
+
+@inlinable public func ImDrawDataBuilderClearFreeMemory(_ this: UnsafeMutablePointer!) -> Void {
+ return ImDrawDataBuilder_ClearFreeMemory(this)
+}
+
+@inlinable public func ImDrawDataBuilderFlattenIntoSingleLayer(_ this: UnsafeMutablePointer!) -> Void {
+ return ImDrawDataBuilder_FlattenIntoSingleLayer(this)
+}
+
@inlinable public func ImDrawDataClear(_ this: UnsafeMutablePointer!) -> Void {
return ImDrawData_Clear(this)
}
@@ -37,8 +109,8 @@ public typealias ImGuiContext = OpaquePointer
return ImDrawData_ScaleClipRects(this,fb_scale)
}
-@inlinable public func ImDrawListAddBezierCurve(_ this: UnsafeMutablePointer!, _ pos0: ImVec2, _ cp0: ImVec2, _ cp1: ImVec2, _ pos1: ImVec2, _ col: ImU32, _ thickness: Float, _ num_segments: Int32) -> Void {
- return ImDrawList_AddBezierCurve(this,pos0,cp0,cp1,pos1,col,thickness,num_segments)
+@inlinable public func ImDrawListAddBezierCurve(_ this: UnsafeMutablePointer!, _ p1: ImVec2, _ p2: ImVec2, _ p3: ImVec2, _ p4: ImVec2, _ col: ImU32, _ thickness: Float, _ num_segments: Int32) -> Void {
+ return ImDrawList_AddBezierCurve(this,p1,p2,p3,p4,col,thickness,num_segments)
}
@inlinable public func ImDrawListAddCallback(_ this: UnsafeMutablePointer!, _ callback: @escaping ImDrawCallback, _ callback_data: UnsafeMutableRawPointer!) -> Void {
@@ -77,6 +149,14 @@ public typealias ImGuiContext = OpaquePointer
return ImDrawList_AddLine(this,p1,p2,col,thickness)
}
+@inlinable public func ImDrawListAddNgon(_ this: UnsafeMutablePointer!, _ center: ImVec2, _ radius: Float, _ col: ImU32, _ num_segments: Int32, _ thickness: Float) -> Void {
+ return ImDrawList_AddNgon(this,center,radius,col,num_segments,thickness)
+}
+
+@inlinable public func ImDrawListAddNgonFilled(_ this: UnsafeMutablePointer!, _ center: ImVec2, _ radius: Float, _ col: ImU32, _ num_segments: Int32) -> Void {
+ return ImDrawList_AddNgonFilled(this,center,radius,col,num_segments)
+}
+
@inlinable public func ImDrawListAddPolyline(_ this: UnsafeMutablePointer!, _ points: UnsafePointer!, _ num_points: Int32, _ col: ImU32, _ closed: Bool, _ thickness: Float) -> Void {
return ImDrawList_AddPolyline(this,points,num_points,col,closed,thickness)
}
@@ -104,12 +184,12 @@ public typealias ImGuiContext = OpaquePointer
@inlinable public func ImDrawListAddText(_ this: UnsafeMutablePointer!, _ pos: ImVec2, _ col: ImU32, _ text_begin: String?, _ text_end: String?) -> Void {
text_begin!.withCString { text_beginPtr in
text_end!.withCString { text_endPtr in
- return ImDrawList_AddText(this,pos,col,text_beginPtr,text_endPtr)
+ return ImDrawList_AddTextVec2(this,pos,col,text_beginPtr,text_endPtr)
}
}
}
-@inlinable public func ImDrawListAddTextFontPtr(_ this: UnsafeMutablePointer!, _ font: UnsafePointer!, _ font_size: Float, _ pos: ImVec2, _ col: ImU32, _ text_begin: String?, _ text_end: String?, _ wrap_width: Float, _ cpu_fine_clip_rect: UnsafePointer!) -> Void {
+@inlinable public func ImDrawListAddText(_ this: UnsafeMutablePointer!, _ font: UnsafePointer!, _ font_size: Float, _ pos: ImVec2, _ col: ImU32, _ text_begin: String?, _ text_end: String?, _ wrap_width: Float, _ cpu_fine_clip_rect: UnsafePointer!) -> Void {
text_begin!.withCString { text_beginPtr in
text_end!.withCString { text_endPtr in
return ImDrawList_AddTextFontPtr(this,font,font_size,pos,col,text_beginPtr,text_endPtr,wrap_width,cpu_fine_clip_rect)
@@ -149,28 +229,12 @@ public typealias ImGuiContext = OpaquePointer
return ImDrawList_CloneOutput(this)
}
-@inlinable public func ImDrawListGetClipRectMax(_ this: UnsafeMutablePointer!) -> ImVec2 {
- return ImDrawList_GetClipRectMax(this)
-}
-
-@inlinable public func ImDrawListGetClipRectMaxnonUDT(_ pOut: UnsafeMutablePointer!, _ this: UnsafeMutablePointer!) -> Void {
- return ImDrawList_GetClipRectMax_nonUDT(pOut,this)
-}
-
-@inlinable public func ImDrawListGetClipRectMaxnonUDT2(_ this: UnsafeMutablePointer!) -> ImVec2_Simple {
- return ImDrawList_GetClipRectMax_nonUDT2(this)
-}
-
-@inlinable public func ImDrawListGetClipRectMin(_ this: UnsafeMutablePointer!) -> ImVec2 {
- return ImDrawList_GetClipRectMin(this)
-}
-
-@inlinable public func ImDrawListGetClipRectMinnonUDT(_ pOut: UnsafeMutablePointer!, _ this: UnsafeMutablePointer!) -> Void {
- return ImDrawList_GetClipRectMin_nonUDT(pOut,this)
+@inlinable public func ImDrawListGetClipRectMax(_ pOut: UnsafeMutablePointer!, _ this: UnsafeMutablePointer!) -> Void {
+ return ImDrawList_GetClipRectMax(pOut,this)
}
-@inlinable public func ImDrawListGetClipRectMinnonUDT2(_ this: UnsafeMutablePointer!) -> ImVec2_Simple {
- return ImDrawList_GetClipRectMin_nonUDT2(this)
+@inlinable public func ImDrawListGetClipRectMin(_ pOut: UnsafeMutablePointer!, _ this: UnsafeMutablePointer!) -> Void {
+ return ImDrawList_GetClipRectMin(pOut,this)
}
@inlinable public func ImDrawListPathArcTo(_ this: UnsafeMutablePointer!, _ center: ImVec2, _ radius: Float, _ a_min: Float, _ a_max: Float, _ num_segments: Int32) -> Void {
@@ -181,8 +245,8 @@ public typealias ImGuiContext = OpaquePointer
return ImDrawList_PathArcToFast(this,center,radius,a_min_of_12,a_max_of_12)
}
-@inlinable public func ImDrawListPathBezierCurveTo(_ this: UnsafeMutablePointer!, _ p1: ImVec2, _ p2: ImVec2, _ p3: ImVec2, _ num_segments: Int32) -> Void {
- return ImDrawList_PathBezierCurveTo(this,p1,p2,p3,num_segments)
+@inlinable public func ImDrawListPathBezierCurveTo(_ this: UnsafeMutablePointer!, _ p2: ImVec2, _ p3: ImVec2, _ p4: ImVec2, _ num_segments: Int32) -> Void {
+ return ImDrawList_PathBezierCurveTo(this,p2,p3,p4,num_segments)
}
@inlinable public func ImDrawListPathClear(_ this: UnsafeMutablePointer!) -> Void {
@@ -233,6 +297,10 @@ public typealias ImGuiContext = OpaquePointer
return ImDrawList_PrimReserve(this,idx_count,vtx_count)
}
+@inlinable public func ImDrawListPrimUnreserve(_ this: UnsafeMutablePointer!, _ idx_count: Int32, _ vtx_count: Int32) -> Void {
+ return ImDrawList_PrimUnreserve(this,idx_count,vtx_count)
+}
+
@inlinable public func ImDrawListPrimVtx(_ this: UnsafeMutablePointer!, _ pos: ImVec2, _ uv: ImVec2, _ col: ImU32) -> Void {
return ImDrawList_PrimVtx(this,pos,uv,col)
}
@@ -257,6 +325,14 @@ public typealias ImGuiContext = OpaquePointer
return ImDrawList_PushTextureID(this,texture_id)
}
+@inlinable public func ImDrawListSharedDataSetCircleSegmentMaxError(_ this: UnsafeMutablePointer!, _ max_error: Float) -> Void {
+ return ImDrawListSharedData_SetCircleSegmentMaxError(this,max_error)
+}
+
+@inlinable public func ImDrawListSplit(_ this: UnsafeMutablePointer!, _ draw_list: UnsafeMutablePointer!, _ count: Int32) -> Void {
+ return ImDrawListSplitter_Split(this,draw_list,count)
+}
+
@inlinable public func ImDrawListSplitterClear(_ this: UnsafeMutablePointer!) -> Void {
return ImDrawListSplitter_Clear(this)
}
@@ -273,10 +349,6 @@ public typealias ImGuiContext = OpaquePointer
return ImDrawListSplitter_SetCurrentChannel(this,draw_list,channel_idx)
}
-@inlinable public func ImDrawListSplitterSplit(_ this: UnsafeMutablePointer!, _ draw_list: UnsafeMutablePointer!, _ count: Int32) -> Void {
- return ImDrawListSplitter_Split(this,draw_list,count)
-}
-
@inlinable public func ImDrawListUpdateClipRect(_ this: UnsafeMutablePointer!) -> Void {
return ImDrawList_UpdateClipRect(this)
}
@@ -285,6 +357,46 @@ public typealias ImGuiContext = OpaquePointer
return ImDrawList_UpdateTextureID(this)
}
+@inlinable @discardableResult public func ImFileClose(_ file: ImFileHandle) -> Bool {
+ return igImFileClose(file)
+}
+
+@inlinable public func ImFileGetSize(_ file: ImFileHandle) -> ImU64 {
+ return igImFileGetSize(file)
+}
+
+@inlinable public func ImFileLoadToMemory(_ filename: String?, _ mode: String?, _ out_file_size: UnsafeMutablePointer!, _ padding_bytes: Int32) -> UnsafeMutableRawPointer! {
+ filename!.withCString { filenamePtr in
+ mode!.withCString { modePtr in
+ return igImFileLoadToMemory(filenamePtr,modePtr,out_file_size,padding_bytes)
+ }
+ }
+}
+
+@inlinable public func ImFileOpen(_ filename: String?, _ mode: String?) -> ImFileHandle {
+ filename!.withCString { filenamePtr in
+ mode!.withCString { modePtr in
+ return igImFileOpen(filenamePtr,modePtr)
+ }
+ }
+}
+
+@inlinable public func ImFileRead(_ data: UnsafeMutableRawPointer!, _ size: ImU64, _ count: ImU64, _ file: ImFileHandle) -> ImU64 {
+ return igImFileRead(data,size,count,file)
+}
+
+@inlinable public func ImFileWrite(_ data: UnsafeRawPointer!, _ size: ImU64, _ count: ImU64, _ file: ImFileHandle) -> ImU64 {
+ return igImFileWrite(data,size,count,file)
+}
+
+@inlinable public func ImFloor(_ f: Float) -> Float {
+ return igImFloorFloat(f)
+}
+
+@inlinable public func ImFloor(_ pOut: UnsafeMutablePointer