@ -85,7 +85,7 @@ Dear ImGui allows you to **create elaborate tools** as well as very short-lived
### How it works
### How it works
Check out the Wiki's [About the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#About-the-IMGUI-paradigm) section if you want to understand the core principles behind the IMGUI paradigm. An IMGUI tries to minimize superfluous state duplication, state synchronization and state retention from the user's point of view. It is less error prone (less code and less bugs) than traditional retained-mode interfaces, and lends itself to create dynamic user interfaces.
Check out the Wiki's [About the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#about-the-imgui-paradigm) section if you want to understand the core principles behind the IMGUI paradigm. An IMGUI tries to minimize superfluous state duplication, state synchronization and state retention from the user's point of view. It is less error prone (less code and less bugs) than traditional retained-mode interfaces, and lends itself to create dynamic user interfaces.
Dear ImGui outputs vertex buffers and command lists that you can easily render in your application. The number of draw calls and state changes required to render them is fairly small. Because Dear ImGui doesn't know or touch graphics state directly, you can call its functions anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate Dear ImGui with your existing codebase.
Dear ImGui outputs vertex buffers and command lists that you can easily render in your application. The number of draw calls and state changes required to render them is fairly small. Because Dear ImGui doesn't know or touch graphics state directly, you can call its functions anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate Dear ImGui with your existing codebase.
See: [Wiki](https://github.com/ocornut/imgui/wiki) for many links, references, articles.
See: [Wiki](https://github.com/ocornut/imgui/wiki) for many links, references, articles.
See: [Articles about the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#Articles-about-the-IMGUI-paradigm) to read/learn about the Immediate Mode GUI paradigm.
See: [Articles about the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#about-the-imgui-paradigm) to read/learn about the Immediate Mode GUI paradigm.
If you are new to Dear ImGui and have issues with: compiling, linking, adding fonts, wiring inputs, running or displaying Dear ImGui: you can use [Discord server](http://discord.dearimgui.org).
If you are new to Dear ImGui and have issues with: compiling, linking, adding fonts, wiring inputs, running or displaying Dear ImGui: you can use [Discord server](http://discord.dearimgui.org).
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
// - Read 'docs/FONTS.txt' for more instructions and details.
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
LogSliderDeadzone=4.0f;// The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero.
LogSliderDeadzone=4.0f;// The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero.
TabRounding=4.0f;// Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
TabRounding=4.0f;// Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
TabBorderSize=0.0f;// Thickness of border around tabs.
TabBorderSize=0.0f;// Thickness of border around tabs.
TabMinWidthForUnselectedCloseButton =0.0f;// Minimum width for close button to appears on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected.
TabMinWidthForCloseButton =0.0f;// Minimum width for close button to appears on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected.
ColorButtonPosition=ImGuiDir_Right;// Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
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.
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. 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.
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.
IM_ASSERT(ItemsCount==-1&&"Forgot to call End(), or to Step() until false?");
}
// Use case A: Begin() called from constructor with items_height<0, then called again from Step() in StepNo 1
// Use case B: Begin() called from constructor with items_height>0
// Use case B: Begin() called from constructor with items_height>0
// FIXME-LEGACY: Ideally we should remove the Begin/End functions but they are part of the legacy API we still support. This is why some of the code in Step() calling Begin() and reassign some fields, spaghetti style.
// FIXME-LEGACY: Ideally we should remove the Begin/End functions but they are part of the legacy API we still support. This is why some of the code in Step() calling Begin() and reassign some fields, spaghetti style.
// In theory here we should assert that ImGui::GetCursorPosY() == StartPosY + DisplayEnd * ItemsHeight, but it feels saner to just seek at the end and not assert/crash the user.
// In theory here we should assert that ImGui::GetCursorPosY() == StartPosY + DisplayEnd * ItemsHeight, but it feels saner to just seek at the end and not assert/crash the user.
if(StepNo==0)// Step 0: the clipper let you process the first element, regardless of it being visible or not, so we can measure the element height.
// Step 0: Let you process the first element (regardless of it being visible or not, so we can measure the element height)
if(StepNo==0)
{
StartPosY=window->DC.CursorPos.y;
if(ItemsHeight<=0.0f)
{
{
// Submit the first item so we can measure its height (generally it is 0..1)
DisplayStart=0;
DisplayStart=0;
DisplayEnd=1;
DisplayEnd=1;
StartPosY=window->DC.CursorPos.y;
StepNo=1;
StepNo=1;
returntrue;
returntrue;
}
}
if(StepNo==1)// Step 1: the clipper infer height from first element, calculate the actual range of elements to display, and position the cursor before the first element.
// Already has item height (given by user in Begin): skip to calculating step
DisplayStart=DisplayEnd;
StepNo=2;
}
// Step 1: the clipper infer height from first element
IM_ASSERT(items_height>0.0f);// If this triggers, it means Item 0 hasn't moved the cursor vertically
IM_ASSERT(ItemsHeight>0.0f&&"Unable to calculate item height! First item hasn't moved the cursor vertically!");
Begin(ItemsCount-1,items_height);
StepNo=2;
DisplayStart++;
DisplayEnd++;
StepNo=3;
returntrue;
}
}
if(StepNo==2)// Step 2: empty step only required if an explicit items_height was passed to constructor or Begin() and user still call Step(). Does nothing and switch to Step 3.
// Step 2: calculate the actual range of elements to display, and position the cursor before the first element
if(StepNo==3)// 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.
End();
// 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.
ImGuiSliderFlags_ClampOnInput=1<<4,// Clamp value to min/max bounds when input manually with CTRL+Click. By default CTRL+Click allows going out of bounds.
ImGuiSliderFlags_AlwaysClamp=1<<4,// Clamp value to min/max bounds when input manually with CTRL+Click. By default CTRL+Click allows going out of bounds.
ImGuiSliderFlags_Logarithmic=1<<5,// Make the widget logarithmic (linear otherwise). Consider using ImGuiSliderFlags_NoRoundToFormat with this if using a format-string with small amount of digits.
ImGuiSliderFlags_Logarithmic=1<<5,// Make the widget logarithmic (linear otherwise). Consider using ImGuiSliderFlags_NoRoundToFormat with this if using a format-string with small amount of digits.
ImGuiSliderFlags_NoRoundToFormat=1<<6,// Disable rounding underlying value to match precision of the display format string (e.g. %.3f values are rounded to those 3 digits)
ImGuiSliderFlags_NoRoundToFormat=1<<6,// Disable rounding underlying value to match precision of the display format string (e.g. %.3f values are rounded to those 3 digits)
ImGuiSliderFlags_NoInput=1<<7,// Disable CTRL+Click or Enter key allowing to input text directly into the widget
ImGuiSliderFlags_NoInput=1<<7,// Disable CTRL+Click or Enter key allowing to input text directly into the widget
ImGuiSliderFlags_InvalidMask_=0x7000000F// [Internal] We treat using those bits as being potentially a 'float power' argument from the previous API that has got miscast to this enum, and will trigger an assert if needed.
ImGuiSliderFlags_InvalidMask_=0x7000000F// [Internal] We treat using those bits as being potentially a 'float power' argument from the previous API that has got miscast to this enum, and will trigger an assert if needed.
// Obsolete names (will be removed)
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
,ImGuiSliderFlags_ClampOnInput=ImGuiSliderFlags_AlwaysClamp,// [renamed in 1.79]
#endif
};
};
// Identify a mouse button.
// Identify a mouse button.
@ -1549,7 +1554,7 @@ struct ImGuiStyle
floatLogSliderDeadzone;// The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero.
floatLogSliderDeadzone;// The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero.
floatTabRounding;// Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
floatTabRounding;// Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
floatTabBorderSize;// Thickness of border around tabs.
floatTabBorderSize;// Thickness of border around tabs.
floatTabMinWidthForUnselectedCloseButton;// Minimum width for close button to appears on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected.
floatTabMinWidthForCloseButton;// Minimum width for close button to appears on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected.
ImGuiDirColorButtonPosition;// Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
ImGuiDirColorButtonPosition;// Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
ImVec2ButtonTextAlign;// Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered).
ImVec2ButtonTextAlign;// Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered).
ImVec2SelectableTextAlign;// 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.
ImVec2SelectableTextAlign;// 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.
@ -1999,7 +2004,8 @@ 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.
// - 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.
structImGuiListClipper
structImGuiListClipper
{
{
intDisplayStart,DisplayEnd;
intDisplayStart;
intDisplayEnd;
intItemsCount;
intItemsCount;
// [Internal]
// [Internal]
@ -2010,12 +2016,12 @@ struct ImGuiListClipper
// 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_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().
// items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing().
// If you don't specify an items_height, you NEED to call Step(). If you specify items_height you may call the old Begin()/End() api directly, but prefer calling Step().
// If you don't specify an items_height, you NEED to call Step(). If you specify items_height you may call the old Begin()/End() api directly, but prefer calling Step().
ImGuiListClipper(intitems_count=-1,floatitems_height=-1.0f){Begin(items_count,items_height);}// NB: Begin() initialize every fields (as we allow user to call Begin/End multiple times on a same instance if they want).
// We don't support (size < 0.0f) in Selectable() because the ItemSpacing extension would make explicitely right-aligned sizes not visibly match other widgets.
// Assume all items have even height (= 1 line of text). If you need items of different or variable sizes you can create a custom version of ListBox() in your code without using the clipper.
// Assume all items have even height (= 1 line of text). If you need items of different or variable sizes you can create a custom version of ListBox() in your code without using the clipper.
ImGuiContext&g=*GImGui;
ImGuiContext&g=*GImGui;
boolvalue_changed=false;
boolvalue_changed=false;
ImGuiListClipperclipper(items_count,GetTextLineHeightWithSpacing());// We know exactly our line height here so we pass it as a minor optimization, but generally you don't need to.
ImGuiListClipperclipper;
clipper.Begin(items_count,GetTextLineHeightWithSpacing());// We know exactly our line height here so we pass it as a minor optimization, but generally you don't need to.