Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
imgui_demo.cpp File Reference
#include "imgui.h"
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
+ Include dependency graph for imgui_demo.cpp:

Go to the source code of this file.

Classes

struct  anonymous_namespace{imgui_demo.cpp}::MyItem
 
struct  ExampleAppConsole
 
struct  ExampleAppLog
 
struct  MyDocument
 
struct  ExampleAppDocuments
 

Namespaces

namespace  anonymous_namespace{imgui_demo.cpp}
 
namespace  ImGui
 

Macros

#define IM_NEWLINE   "\n"
 
#define IM_PRId64   "lld"
 
#define IM_PRIu64   "llu"
 
#define IM_MIN(A, B)   (((A) < (B)) ? (A) : (B))
 
#define IM_MAX(A, B)   (((A) >= (B)) ? (A) : (B))
 
#define IM_CLAMP(V, MN, MX)   ((V) < (MN) ? (MN) : (V) > (MX) ? (MX) : (V))
 
#define IMGUI_CDECL
 

Enumerations

enum  anonymous_namespace{imgui_demo.cpp}::MyItemColumnID {
  anonymous_namespace{imgui_demo.cpp}::MyItemColumnID_ID , anonymous_namespace{imgui_demo.cpp}::MyItemColumnID_Name , anonymous_namespace{imgui_demo.cpp}::MyItemColumnID_Action , anonymous_namespace{imgui_demo.cpp}::MyItemColumnID_Quantity ,
  anonymous_namespace{imgui_demo.cpp}::MyItemColumnID_Description
}
 

Functions

static void ShowExampleAppDocuments (bool *p_open)
 
static void ShowExampleAppMainMenuBar ()
 
static void ShowExampleAppConsole (bool *p_open)
 
static void ShowExampleAppLog (bool *p_open)
 
static void ShowExampleAppLayout (bool *p_open)
 
static void ShowExampleAppPropertyEditor (bool *p_open)
 
static void ShowExampleAppLongText (bool *p_open)
 
static void ShowExampleAppAutoResize (bool *p_open)
 
static void ShowExampleAppConstrainedResize (bool *p_open)
 
static void ShowExampleAppSimpleOverlay (bool *p_open)
 
static void ShowExampleAppFullscreen (bool *p_open)
 
static void ShowExampleAppWindowTitles (bool *p_open)
 
static void ShowExampleAppCustomRendering (bool *p_open)
 
static void ShowExampleMenuFile ()
 
static void HelpMarker (const char *desc)
 
static void ShowDemoWindowWidgets ()
 
static void ShowDemoWindowLayout ()
 
static void ShowDemoWindowPopups ()
 
static void ShowDemoWindowTables ()
 
static void ShowDemoWindowColumns ()
 
static void ShowDemoWindowMisc ()
 
static void PushStyleCompact ()
 
static void PopStyleCompact ()
 
static void EditTableSizingFlags (ImGuiTableFlags *p_flags)
 
static void EditTableColumnsFlags (ImGuiTableColumnFlags *p_flags)
 
static void ShowTableColumnsStatusFlags (ImGuiTableColumnFlags flags)
 
void ImGui::ShowFontAtlas (ImFontAtlas *atlas)
 
static void ShowFont (ImFont *font)
 
static void ShowPlaceholderObject (const char *prefix, int uid)
 
static void NotifyOfDocumentsClosedElsewhere (ExampleAppDocuments &app)
 

Macro Definition Documentation

◆ IM_CLAMP

#define IM_CLAMP (   V,
  MN,
  MX 
)    ((V) < (MN) ? (MN) : (V) > (MX) ? (MX) : (V))

◆ IM_MAX

#define IM_MAX (   A,
 
)    (((A) >= (B)) ? (A) : (B))

◆ IM_MIN

#define IM_MIN (   A,
 
)    (((A) < (B)) ? (A) : (B))

◆ IM_NEWLINE

#define IM_NEWLINE   "\n"

◆ IM_PRId64

#define IM_PRId64   "lld"

◆ IM_PRIu64

#define IM_PRIu64   "llu"

◆ IMGUI_CDECL

#define IMGUI_CDECL

Function Documentation

◆ EditTableColumnsFlags()

static void EditTableColumnsFlags ( ImGuiTableColumnFlags p_flags)
static
3499{
3502 if (ImGui::CheckboxFlags("_WidthStretch", p_flags, ImGuiTableColumnFlags_WidthStretch))
3504 if (ImGui::CheckboxFlags("_WidthFixed", p_flags, ImGuiTableColumnFlags_WidthFixed))
3511 ImGui::CheckboxFlags("_NoSortAscending", p_flags, ImGuiTableColumnFlags_NoSortAscending);
3512 ImGui::CheckboxFlags("_NoSortDescending", p_flags, ImGuiTableColumnFlags_NoSortDescending);
3514 ImGui::CheckboxFlags("_PreferSortAscending", p_flags, ImGuiTableColumnFlags_PreferSortAscending);
3515 ImGui::CheckboxFlags("_PreferSortDescending", p_flags, ImGuiTableColumnFlags_PreferSortDescending);
3516 ImGui::CheckboxFlags("_IndentEnable", p_flags, ImGuiTableColumnFlags_IndentEnable); ImGui::SameLine(); HelpMarker("Default for column 0");
3517 ImGui::CheckboxFlags("_IndentDisable", p_flags, ImGuiTableColumnFlags_IndentDisable); ImGui::SameLine(); HelpMarker("Default for column >0");
3518}
@ ImGuiTableColumnFlags_WidthFixed
Definition imgui.h:1170
@ ImGuiTableColumnFlags_IndentDisable
Definition imgui.h:1182
@ ImGuiTableColumnFlags_PreferSortDescending
Definition imgui.h:1180
@ ImGuiTableColumnFlags_NoHide
Definition imgui.h:1173
@ ImGuiTableColumnFlags_WidthStretch
Definition imgui.h:1169
@ ImGuiTableColumnFlags_WidthMask_
Definition imgui.h:1191
@ ImGuiTableColumnFlags_NoSort
Definition imgui.h:1175
@ ImGuiTableColumnFlags_IndentEnable
Definition imgui.h:1181
@ ImGuiTableColumnFlags_DefaultHide
Definition imgui.h:1167
@ ImGuiTableColumnFlags_NoReorder
Definition imgui.h:1172
@ ImGuiTableColumnFlags_PreferSortAscending
Definition imgui.h:1179
@ ImGuiTableColumnFlags_NoSortAscending
Definition imgui.h:1176
@ ImGuiTableColumnFlags_NoResize
Definition imgui.h:1171
@ ImGuiTableColumnFlags_NoHeaderWidth
Definition imgui.h:1178
@ ImGuiTableColumnFlags_DefaultSort
Definition imgui.h:1168
@ ImGuiTableColumnFlags_NoSortDescending
Definition imgui.h:1177
@ ImGuiTableColumnFlags_NoClip
Definition imgui.h:1174
static void HelpMarker(const char *desc)
Definition imgui_demo.cpp:191
IMGUI_API void SameLine(float offset_from_start_x=0.0f, float spacing=-1.0f)
Definition imgui.cpp:7455
IMGUI_API bool CheckboxFlags(const char *label, int *flags, int flags_value)
Definition imgui_widgets.cpp:1157

References ImGui::CheckboxFlags(), HelpMarker(), ImGuiTableColumnFlags_DefaultHide, ImGuiTableColumnFlags_DefaultSort, ImGuiTableColumnFlags_IndentDisable, ImGuiTableColumnFlags_IndentEnable, ImGuiTableColumnFlags_NoClip, ImGuiTableColumnFlags_NoHeaderWidth, ImGuiTableColumnFlags_NoHide, ImGuiTableColumnFlags_NoReorder, ImGuiTableColumnFlags_NoResize, ImGuiTableColumnFlags_NoSort, ImGuiTableColumnFlags_NoSortAscending, ImGuiTableColumnFlags_NoSortDescending, ImGuiTableColumnFlags_PreferSortAscending, ImGuiTableColumnFlags_PreferSortDescending, ImGuiTableColumnFlags_WidthFixed, ImGuiTableColumnFlags_WidthMask_, ImGuiTableColumnFlags_WidthStretch, and ImGui::SameLine().

Referenced by ShowDemoWindowTables().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EditTableSizingFlags()

static void EditTableSizingFlags ( ImGuiTableFlags p_flags)
static
3457{
3458 struct EnumDesc { ImGuiTableFlags Value; const char* Name; const char* Tooltip; };
3459 static const EnumDesc policies[] =
3460 {
3461 { ImGuiTableFlags_None, "Default", "Use default sizing policy:\n- ImGuiTableFlags_SizingFixedFit if ScrollX is on or if host window has ImGuiWindowFlags_AlwaysAutoResize.\n- ImGuiTableFlags_SizingStretchSame otherwise." },
3462 { ImGuiTableFlags_SizingFixedFit, "ImGuiTableFlags_SizingFixedFit", "Columns default to _WidthFixed (if resizable) or _WidthAuto (if not resizable), matching contents width." },
3463 { ImGuiTableFlags_SizingFixedSame, "ImGuiTableFlags_SizingFixedSame", "Columns are all the same width, matching the maximum contents width.\nImplicitly disable ImGuiTableFlags_Resizable and enable ImGuiTableFlags_NoKeepColumnsVisible." },
3464 { ImGuiTableFlags_SizingStretchProp, "ImGuiTableFlags_SizingStretchProp", "Columns default to _WidthStretch with weights proportional to their widths." },
3465 { ImGuiTableFlags_SizingStretchSame, "ImGuiTableFlags_SizingStretchSame", "Columns default to _WidthStretch with same weights." }
3466 };
3467 int idx;
3468 for (idx = 0; idx < IM_ARRAYSIZE(policies); idx++)
3469 if (policies[idx].Value == (*p_flags & ImGuiTableFlags_SizingMask_))
3470 break;
3471 const char* preview_text = (idx < IM_ARRAYSIZE(policies)) ? policies[idx].Name + (idx > 0 ? strlen("ImGuiTableFlags") : 0) : "";
3472 if (ImGui::BeginCombo("Sizing Policy", preview_text))
3473 {
3474 for (int n = 0; n < IM_ARRAYSIZE(policies); n++)
3475 if (ImGui::Selectable(policies[n].Name, idx == n))
3476 *p_flags = (*p_flags & ~ImGuiTableFlags_SizingMask_) | policies[n].Value;
3478 }
3480 ImGui::TextDisabled("(?)");
3482 {
3485 for (int m = 0; m < IM_ARRAYSIZE(policies); m++)
3486 {
3488 ImGui::Text("%s:", policies[m].Name);
3490 ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetStyle().IndentSpacing * 0.5f);
3491 ImGui::TextUnformatted(policies[m].Tooltip);
3492 }
3495 }
3496}
int ImGuiTableFlags
Definition imgui.h:196
@ ImGuiTableFlags_SizingFixedSame
Definition imgui.h:1131
@ ImGuiTableFlags_None
Definition imgui.h:1109
@ ImGuiTableFlags_SizingMask_
Definition imgui.h:1153
@ ImGuiTableFlags_SizingStretchSame
Definition imgui.h:1133
@ ImGuiTableFlags_SizingStretchProp
Definition imgui.h:1132
@ ImGuiTableFlags_SizingFixedFit
Definition imgui.h:1130
#define IM_ARRAYSIZE(_ARR)
Definition imgui.h:83
IMGUI_API float GetCursorPosX()
Definition imgui.cpp:7499
IMGUI_API void PopTextWrapPos()
Definition imgui.cpp:6599
IMGUI_API void Separator()
Definition imgui_widgets.cpp:1419
IMGUI_API void Value(const char *prefix, bool b)
Definition imgui_widgets.cpp:6470
IMGUI_API void BeginTooltip()
Definition imgui.cpp:8008
IMGUI_API void EndCombo()
Definition imgui_widgets.cpp:1674
IMGUI_API void PushTextWrapPos(float wrap_local_pos_x=0.0f)
Definition imgui.cpp:6592
IMGUI_API void TextUnformatted(const char *text, const char *text_end=NULL)
Definition imgui_widgets.cpp:255
IMGUI_API void Text(const char *fmt,...) IM_FMTARGS(1)
Definition imgui_widgets.cpp:260
IMGUI_API bool BeginCombo(const char *label, const char *preview_value, ImGuiComboFlags flags=0)
Definition imgui_widgets.cpp:1555
IMGUI_API void TextDisabled(const char *fmt,...) IM_FMTARGS(1)
Definition imgui_widgets.cpp:297
IMGUI_API ImGuiStyle & GetStyle()
Definition imgui.cpp:2423
IMGUI_API float GetFontSize()
Definition imgui.cpp:6937
IMGUI_API void EndTooltip()
Definition imgui.cpp:8045
IMGUI_API bool IsItemHovered(ImGuiHoveredFlags flags=0)
Definition imgui.cpp:3149
IMGUI_API void SetCursorPosX(float local_x)
Definition imgui.cpp:7518
IMGUI_API bool Selectable(const char *label, bool selected=false, ImGuiSelectableFlags flags=0, const ImVec2 &size=ImVec2(0, 0))
Definition imgui_widgets.cpp:6016

References ImGui::BeginCombo(), ImGui::BeginTooltip(), ImGui::EndCombo(), ImGui::EndTooltip(), ImGui::GetCursorPosX(), ImGui::GetFontSize(), ImGui::GetStyle(), IM_ARRAYSIZE, ImGuiTableFlags_None, ImGuiTableFlags_SizingFixedFit, ImGuiTableFlags_SizingFixedSame, ImGuiTableFlags_SizingMask_, ImGuiTableFlags_SizingStretchProp, ImGuiTableFlags_SizingStretchSame, ImGui::IsItemHovered(), ImGui::PopTextWrapPos(), ImGui::PushTextWrapPos(), ImGui::SameLine(), ImGui::Selectable(), ImGui::Separator(), ImGui::SetCursorPosX(), ImGui::Text(), ImGui::TextDisabled(), and ImGui::TextUnformatted().

Referenced by ShowDemoWindowTables().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HelpMarker()

static void HelpMarker ( const char *  desc)
static

References ImGui::BeginTooltip(), ImGui::EndTooltip(), ImGui::GetFontSize(), ImGui::IsItemHovered(), ImGui::PopTextWrapPos(), ImGui::PushTextWrapPos(), ImGui::TextDisabled(), and ImGui::TextUnformatted().

Referenced by EditTableColumnsFlags(), ImGui::ShowDemoWindow(), ShowDemoWindowColumns(), ShowDemoWindowLayout(), ShowDemoWindowMisc(), ShowDemoWindowPopups(), ShowDemoWindowTables(), ShowDemoWindowWidgets(), ShowExampleAppCustomRendering(), ShowExampleAppFullscreen(), ShowExampleAppPropertyEditor(), ShowFont(), ImGui::ShowFontSelector(), and ImGui::ShowStyleEditor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ NotifyOfDocumentsClosedElsewhere()

static void NotifyOfDocumentsClosedElsewhere ( ExampleAppDocuments app)
static
7524{
7525 for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
7526 {
7527 MyDocument* doc = &app.Documents[doc_n];
7528 if (!doc->Open && doc->OpenPrev)
7530 doc->OpenPrev = doc->Open;
7531 }
7532}
IMGUI_API void SetTabItemClosed(const char *tab_or_docked_window_label)
Definition imgui_widgets.cpp:7925
ImVector< MyDocument > Documents
Definition imgui_demo.cpp:7502
int Size
Definition imgui.h:1655
Definition imgui_demo.cpp:7446
bool OpenPrev
Definition imgui_demo.cpp:7449
const char * Name
Definition imgui_demo.cpp:7447
bool Open
Definition imgui_demo.cpp:7448

References ExampleAppDocuments::Documents, MyDocument::Name, MyDocument::Open, MyDocument::OpenPrev, ImGui::SetTabItemClosed(), and ImVector< T >::Size.

Referenced by ShowExampleAppDocuments().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PopStyleCompact()

static void PopStyleCompact ( )
static
3451{
3453}
IMGUI_API void PopStyleVar(int count=1)
Definition imgui.cpp:2565

References ImGui::PopStyleVar().

Referenced by ShowDemoWindowTables().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PushStyleCompact()

static void PushStyleCompact ( )
static
3444{
3446 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(style.FramePadding.x, (float)(int)(style.FramePadding.y * 0.60f)));
3447 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x, (float)(int)(style.ItemSpacing.y * 0.60f)));
3448}
#define style
Definition WipeTowerDialog.cpp:68
@ ImGuiStyleVar_ItemSpacing
Definition imgui.h:1492
@ ImGuiStyleVar_FramePadding
Definition imgui.h:1489
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val)
Definition imgui.cpp:2537
Definition imgui.h:1721
Definition imgui.h:245

References ImGui::GetStyle(), ImGuiStyleVar_FramePadding, ImGuiStyleVar_ItemSpacing, ImGui::PushStyleVar(), and style.

Referenced by ShowDemoWindowTables().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowDemoWindowColumns()

static void ShowDemoWindowColumns ( )
static
5231{
5232 bool open = ImGui::TreeNode("Legacy Columns API");
5234 HelpMarker("Columns() is an old API! Prefer using the more flexible and powerful BeginTable() API!");
5235 if (!open)
5236 return;
5237
5238 // Basic columns
5239 if (ImGui::TreeNode("Basic"))
5240 {
5241 ImGui::Text("Without border:");
5242 ImGui::Columns(3, "mycolumns3", false); // 3-ways, no border
5244 for (int n = 0; n < 14; n++)
5245 {
5246 char label[32];
5247 sprintf(label, "Item %d", n);
5248 if (ImGui::Selectable(label)) {}
5249 //if (ImGui::Button(label, ImVec2(-FLT_MIN,0.0f))) {}
5251 }
5252 ImGui::Columns(1);
5254
5255 ImGui::Text("With border:");
5256 ImGui::Columns(4, "mycolumns"); // 4-ways, with border
5259 ImGui::Text("Name"); ImGui::NextColumn();
5260 ImGui::Text("Path"); ImGui::NextColumn();
5261 ImGui::Text("Hovered"); ImGui::NextColumn();
5263 const char* names[3] = { "One", "Two", "Three" };
5264 const char* paths[3] = { "/path/one", "/path/two", "/path/three" };
5265 static int selected = -1;
5266 for (int i = 0; i < 3; i++)
5267 {
5268 char label[32];
5269 sprintf(label, "%04d", i);
5270 if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns))
5271 selected = i;
5274 ImGui::Text(names[i]); ImGui::NextColumn();
5275 ImGui::Text(paths[i]); ImGui::NextColumn();
5276 ImGui::Text("%d", hovered); ImGui::NextColumn();
5277 }
5278 ImGui::Columns(1);
5281 }
5282
5283 if (ImGui::TreeNode("Borders"))
5284 {
5285 // NB: Future columns API should allow automatic horizontal borders.
5286 static bool h_borders = true;
5287 static bool v_borders = true;
5288 static int columns_count = 4;
5289 const int lines_count = 3;
5291 ImGui::DragInt("##columns_count", &columns_count, 0.1f, 2, 10, "%d columns");
5292 if (columns_count < 2)
5293 columns_count = 2;
5295 ImGui::Checkbox("horizontal", &h_borders);
5297 ImGui::Checkbox("vertical", &v_borders);
5298 ImGui::Columns(columns_count, NULL, v_borders);
5299 for (int i = 0; i < columns_count * lines_count; i++)
5300 {
5301 if (h_borders && ImGui::GetColumnIndex() == 0)
5303 ImGui::Text("%c%c%c", 'a' + i, 'a' + i, 'a' + i);
5304 ImGui::Text("Width %.2f", ImGui::GetColumnWidth());
5305 ImGui::Text("Avail %.2f", ImGui::GetContentRegionAvail().x);
5306 ImGui::Text("Offset %.2f", ImGui::GetColumnOffset());
5307 ImGui::Text("Long text that is likely to clip");
5308 ImGui::Button("Button", ImVec2(-FLT_MIN, 0.0f));
5310 }
5311 ImGui::Columns(1);
5312 if (h_borders)
5315 }
5316
5317 // Create multiple items in a same cell before switching to next column
5318 if (ImGui::TreeNode("Mixed items"))
5319 {
5320 ImGui::Columns(3, "mixed");
5322
5323 ImGui::Text("Hello");
5324 ImGui::Button("Banana");
5326
5327 ImGui::Text("ImGui");
5328 ImGui::Button("Apple");
5329 static float foo = 1.0f;
5330 ImGui::InputFloat("red", &foo, 0.05f, 0, "%.3f");
5331 ImGui::Text("An extra line here.");
5333
5334 ImGui::Text("Sailor");
5335 ImGui::Button("Corniflower");
5336 static float bar = 1.0f;
5337 ImGui::InputFloat("blue", &bar, 0.05f, 0, "%.3f");
5339
5340 if (ImGui::CollapsingHeader("Category A")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
5341 if (ImGui::CollapsingHeader("Category B")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
5342 if (ImGui::CollapsingHeader("Category C")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
5343 ImGui::Columns(1);
5346 }
5347
5348 // Word wrapping
5349 if (ImGui::TreeNode("Word-wrapping"))
5350 {
5351 ImGui::Columns(2, "word-wrapping");
5353 ImGui::TextWrapped("The quick brown fox jumps over the lazy dog.");
5354 ImGui::TextWrapped("Hello Left");
5356 ImGui::TextWrapped("The quick brown fox jumps over the lazy dog.");
5357 ImGui::TextWrapped("Hello Right");
5358 ImGui::Columns(1);
5361 }
5362
5363 if (ImGui::TreeNode("Horizontal Scrolling"))
5364 {
5366 ImVec2 child_size = ImVec2(0, ImGui::GetFontSize() * 20.0f);
5367 ImGui::BeginChild("##ScrollingRegion", child_size, false, ImGuiWindowFlags_HorizontalScrollbar);
5368 ImGui::Columns(10);
5369
5370 // Also demonstrate using clipper for large vertical lists
5371 int ITEMS_COUNT = 2000;
5372 ImGuiListClipper clipper;
5373 clipper.Begin(ITEMS_COUNT);
5374 while (clipper.Step())
5375 {
5376 for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
5377 for (int j = 0; j < 10; j++)
5378 {
5379 ImGui::Text("Line %d Column %d...", i, j);
5381 }
5382 }
5383 ImGui::Columns(1);
5386 }
5387
5388 if (ImGui::TreeNode("Tree"))
5389 {
5390 ImGui::Columns(2, "tree", true);
5391 for (int x = 0; x < 3; x++)
5392 {
5393 bool open1 = ImGui::TreeNode((void*)(intptr_t)x, "Node%d", x);
5395 ImGui::Text("Node contents");
5397 if (open1)
5398 {
5399 for (int y = 0; y < 3; y++)
5400 {
5401 bool open2 = ImGui::TreeNode((void*)(intptr_t)y, "Node%d.%d", x, y);
5403 ImGui::Text("Node contents");
5404 if (open2)
5405 {
5406 ImGui::Text("Even more contents");
5407 if (ImGui::TreeNode("Tree in column"))
5408 {
5409 ImGui::Text("The quick brown fox jumps over the lazy dog");
5411 }
5412 }
5414 if (open2)
5416 }
5418 }
5419 }
5420 ImGui::Columns(1);
5422 }
5423
5425}
@ ImGuiSelectableFlags_SpanAllColumns
Definition imgui.h:1033
@ ImGuiWindowFlags_HorizontalScrollbar
Definition imgui.h:927
const Scalar & y
Definition MathFunctions.h:552
IMGUI_API void Columns(int count=1, const char *id=NULL, bool border=true)
Definition imgui_tables.cpp:4008
IMGUI_API void SetNextItemWidth(float item_width)
Definition imgui.cpp:7555
IMGUI_API bool InputFloat(const char *label, float *v, float step=0.0f, float step_fast=0.0f, const char *format="%.3f", ImGuiInputTextFlags flags=0)
Definition imgui_widgets.cpp:3448
IMGUI_API bool DragInt(const char *label, int *v, float v_speed=1.0f, int v_min=0, int v_max=0, const char *format="%d", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:2479
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
Definition imgui_widgets.cpp:715
IMGUI_API float GetColumnWidth(int column_index=-1)
Definition imgui_tables.cpp:3691
IMGUI_API ImVec2 GetContentRegionAvail()
Definition imgui.cpp:7687
IMGUI_API void TreePop()
Definition imgui_widgets.cpp:5918
IMGUI_API bool TreeNode(const char *label)
Definition imgui_widgets.cpp:5593
IMGUI_API bool Checkbox(const char *label, bool *v)
Definition imgui_widgets.cpp:1071
IMGUI_API bool BeginChild(const char *str_id, const ImVec2 &size=ImVec2(0, 0), bool border=false, ImGuiWindowFlags flags=0)
Definition imgui.cpp:5019
IMGUI_API float GetColumnOffset(int column_index=-1)
Definition imgui_tables.cpp:3662
IMGUI_API void NextColumn()
Definition imgui_tables.cpp:3877
IMGUI_API void SetNextWindowContentSize(const ImVec2 &size)
Definition imgui.cpp:6890
IMGUI_API bool CollapsingHeader(const char *label, ImGuiTreeNodeFlags flags=0)
Definition imgui_widgets.cpp:5960
IMGUI_API int GetColumnIndex()
Definition imgui_tables.cpp:3621
IMGUI_API void TextWrapped(const char *fmt,...) IM_FMTARGS(1)
Definition imgui_widgets.cpp:316
IMGUI_API void EndChild()
Definition imgui.cpp:5031
TCoord< P > x(const P &p)
Definition geometry_traits.hpp:297
Definition imgui.h:2138
IMGUI_API void Begin(int items_count, float items_height=-1.0f)
Definition imgui.cpp:2286
int DisplayStart
Definition imgui.h:2139
int DisplayEnd
Definition imgui.h:2140
IMGUI_API bool Step()
Definition imgui.cpp:2316

References ImGuiListClipper::Begin(), ImGui::BeginChild(), ImGui::Button(), ImGui::Checkbox(), ImGui::CollapsingHeader(), ImGui::Columns(), ImGuiListClipper::DisplayEnd, ImGuiListClipper::DisplayStart, ImGui::DragInt(), ImGui::EndChild(), ImGui::GetColumnIndex(), ImGui::GetColumnOffset(), ImGui::GetColumnWidth(), ImGui::GetContentRegionAvail(), ImGui::GetFontSize(), HelpMarker(), ImGuiSelectableFlags_SpanAllColumns, ImGuiWindowFlags_HorizontalScrollbar, ImGui::InputFloat(), ImGui::IsItemHovered(), ImGui::NextColumn(), ImGui::SameLine(), ImGui::Selectable(), ImGui::Separator(), ImGui::SetNextItemWidth(), ImGui::SetNextWindowContentSize(), ImGuiListClipper::Step(), ImGui::Text(), ImGui::TextWrapped(), ImGui::TreeNode(), and ImGui::TreePop().

Referenced by ShowDemoWindowTables().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowDemoWindowLayout()

static void ShowDemoWindowLayout ( )
static
2328{
2329 if (!ImGui::CollapsingHeader("Layout & Scrolling"))
2330 return;
2331
2332 if (ImGui::TreeNode("Child windows"))
2333 {
2334 HelpMarker("Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window.");
2335 static bool disable_mouse_wheel = false;
2336 static bool disable_menu = false;
2337 ImGui::Checkbox("Disable Mouse Wheel", &disable_mouse_wheel);
2338 ImGui::Checkbox("Disable Menu", &disable_menu);
2339
2340 // Child 1: no border, enable horizontal scrollbar
2341 {
2343 if (disable_mouse_wheel)
2344 window_flags |= ImGuiWindowFlags_NoScrollWithMouse;
2345 ImGui::BeginChild("ChildL", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f, 260), false, window_flags);
2346 for (int i = 0; i < 100; i++)
2347 ImGui::Text("%04d: scrollable region", i);
2349 }
2350
2352
2353 // Child 2: rounded border
2354 {
2356 if (disable_mouse_wheel)
2357 window_flags |= ImGuiWindowFlags_NoScrollWithMouse;
2358 if (!disable_menu)
2359 window_flags |= ImGuiWindowFlags_MenuBar;
2361 ImGui::BeginChild("ChildR", ImVec2(0, 260), true, window_flags);
2362 if (!disable_menu && ImGui::BeginMenuBar())
2363 {
2364 if (ImGui::BeginMenu("Menu"))
2365 {
2368 }
2370 }
2372 {
2373 for (int i = 0; i < 100; i++)
2374 {
2375 char buf[32];
2376 sprintf(buf, "%03d", i);
2378 ImGui::Button(buf, ImVec2(-FLT_MIN, 0.0f));
2379 }
2381 }
2384 }
2385
2387
2388 // Demonstrate a few extra things
2389 // - Changing ImGuiCol_ChildBg (which is transparent black in default styles)
2390 // - Using SetCursorPos() to position child window (the child window is an item from the POV of parent window)
2391 // You can also call SetNextWindowPos() to position the child window. The parent window will effectively
2392 // layout from this position.
2393 // - Using ImGui::GetItemRectMin/Max() to query the "item" state (because the child window is an item from
2394 // the POV of the parent window). See 'Demo->Querying Status (Active/Focused/Hovered etc.)' for details.
2395 {
2396 static int offset_x = 0;
2398 ImGui::DragInt("Offset X", &offset_x, 1.0f, -1000, 1000);
2399
2400 ImGui::SetCursorPosX(ImGui::GetCursorPosX() + (float)offset_x);
2402 ImGui::BeginChild("Red", ImVec2(200, 100), true, ImGuiWindowFlags_None);
2403 for (int n = 0; n < 50; n++)
2404 ImGui::Text("Some test %d", n);
2406 bool child_is_hovered = ImGui::IsItemHovered();
2407 ImVec2 child_rect_min = ImGui::GetItemRectMin();
2408 ImVec2 child_rect_max = ImGui::GetItemRectMax();
2410 ImGui::Text("Hovered: %d", child_is_hovered);
2411 ImGui::Text("Rect of child window is: (%.0f,%.0f) (%.0f,%.0f)", child_rect_min.x, child_rect_min.y, child_rect_max.x, child_rect_max.y);
2412 }
2413
2415 }
2416
2417 if (ImGui::TreeNode("Widgets Width"))
2418 {
2419 static float f = 0.0f;
2420 static bool show_indented_items = true;
2421 ImGui::Checkbox("Show indented items", &show_indented_items);
2422
2423 // Use SetNextItemWidth() to set the width of a single upcoming item.
2424 // Use PushItemWidth()/PopItemWidth() to set the width of a group of items.
2425 // In real code use you'll probably want to choose width values that are proportional to your font size
2426 // e.g. Using '20.0f * GetFontSize()' as width instead of '200.0f', etc.
2427
2428 ImGui::Text("SetNextItemWidth/PushItemWidth(100)");
2429 ImGui::SameLine(); HelpMarker("Fixed width.");
2431 ImGui::DragFloat("float##1b", &f);
2432 if (show_indented_items)
2433 {
2434 ImGui::Indent();
2435 ImGui::DragFloat("float (indented)##1b", &f);
2437 }
2439
2440 ImGui::Text("SetNextItemWidth/PushItemWidth(-100)");
2441 ImGui::SameLine(); HelpMarker("Align to right edge minus 100");
2443 ImGui::DragFloat("float##2a", &f);
2444 if (show_indented_items)
2445 {
2446 ImGui::Indent();
2447 ImGui::DragFloat("float (indented)##2b", &f);
2449 }
2451
2452 ImGui::Text("SetNextItemWidth/PushItemWidth(GetContentRegionAvail().x * 0.5f)");
2453 ImGui::SameLine(); HelpMarker("Half of available width.\n(~ right-cursor_pos)\n(works within a column set)");
2455 ImGui::DragFloat("float##3a", &f);
2456 if (show_indented_items)
2457 {
2458 ImGui::Indent();
2459 ImGui::DragFloat("float (indented)##3b", &f);
2461 }
2463
2464 ImGui::Text("SetNextItemWidth/PushItemWidth(-GetContentRegionAvail().x * 0.5f)");
2465 ImGui::SameLine(); HelpMarker("Align to right edge minus half");
2467 ImGui::DragFloat("float##4a", &f);
2468 if (show_indented_items)
2469 {
2470 ImGui::Indent();
2471 ImGui::DragFloat("float (indented)##4b", &f);
2473 }
2475
2476 // Demonstrate using PushItemWidth to surround three items.
2477 // Calling SetNextItemWidth() before each of them would have the same effect.
2478 ImGui::Text("SetNextItemWidth/PushItemWidth(-FLT_MIN)");
2479 ImGui::SameLine(); HelpMarker("Align to right edge");
2480 ImGui::PushItemWidth(-FLT_MIN);
2481 ImGui::DragFloat("##float5a", &f);
2482 if (show_indented_items)
2483 {
2484 ImGui::Indent();
2485 ImGui::DragFloat("float (indented)##5b", &f);
2487 }
2489
2491 }
2492
2493 if (ImGui::TreeNode("Basic Horizontal Layout"))
2494 {
2495 ImGui::TextWrapped("(Use ImGui::SameLine() to keep adding items to the right of the preceding item)");
2496
2497 // Text
2498 ImGui::Text("Two items: Hello"); ImGui::SameLine();
2499 ImGui::TextColored(ImVec4(1,1,0,1), "Sailor");
2500
2501 // Adjust spacing
2502 ImGui::Text("More spacing: Hello"); ImGui::SameLine(0, 20);
2503 ImGui::TextColored(ImVec4(1,1,0,1), "Sailor");
2504
2505 // Button
2507 ImGui::Text("Normal buttons"); ImGui::SameLine();
2508 ImGui::Button("Banana"); ImGui::SameLine();
2509 ImGui::Button("Apple"); ImGui::SameLine();
2510 ImGui::Button("Corniflower");
2511
2512 // Button
2513 ImGui::Text("Small buttons"); ImGui::SameLine();
2514 ImGui::SmallButton("Like this one"); ImGui::SameLine();
2515 ImGui::Text("can fit within a text block.");
2516
2517 // Aligned to arbitrary position. Easy/cheap column.
2518 ImGui::Text("Aligned");
2519 ImGui::SameLine(150); ImGui::Text("x=150");
2520 ImGui::SameLine(300); ImGui::Text("x=300");
2521 ImGui::Text("Aligned");
2522 ImGui::SameLine(150); ImGui::SmallButton("x=150");
2523 ImGui::SameLine(300); ImGui::SmallButton("x=300");
2524
2525 // Checkbox
2526 static bool c1 = false, c2 = false, c3 = false, c4 = false;
2527 ImGui::Checkbox("My", &c1); ImGui::SameLine();
2528 ImGui::Checkbox("Tailor", &c2); ImGui::SameLine();
2529 ImGui::Checkbox("Is", &c3); ImGui::SameLine();
2530 ImGui::Checkbox("Rich", &c4);
2531
2532 // Various
2533 static float f0 = 1.0f, f1 = 2.0f, f2 = 3.0f;
2535 const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD" };
2536 static int item = -1;
2537 ImGui::Combo("Combo", &item, items, IM_ARRAYSIZE(items)); ImGui::SameLine();
2538 ImGui::SliderFloat("X", &f0, 0.0f, 5.0f); ImGui::SameLine();
2539 ImGui::SliderFloat("Y", &f1, 0.0f, 5.0f); ImGui::SameLine();
2540 ImGui::SliderFloat("Z", &f2, 0.0f, 5.0f);
2542
2544 ImGui::Text("Lists:");
2545 static int selection[4] = { 0, 1, 2, 3 };
2546 for (int i = 0; i < 4; i++)
2547 {
2548 if (i > 0) ImGui::SameLine();
2549 ImGui::PushID(i);
2550 ImGui::ListBox("", &selection[i], items, IM_ARRAYSIZE(items));
2551 ImGui::PopID();
2552 //if (ImGui::IsItemHovered()) ImGui::SetTooltip("ListBox %d hovered", i);
2553 }
2555
2556 // Dummy
2557 ImVec2 button_sz(40, 40);
2558 ImGui::Button("A", button_sz); ImGui::SameLine();
2559 ImGui::Dummy(button_sz); ImGui::SameLine();
2560 ImGui::Button("B", button_sz);
2561
2562 // Manually wrapping
2563 // (we should eventually provide this as an automatic layout feature, but for now you can do it manually)
2564 ImGui::Text("Manually wrapping:");
2566 int buttons_count = 20;
2567 float window_visible_x2 = ImGui::GetWindowPos().x + ImGui::GetWindowContentRegionMax().x;
2568 for (int n = 0; n < buttons_count; n++)
2569 {
2570 ImGui::PushID(n);
2571 ImGui::Button("Box", button_sz);
2572 float last_button_x2 = ImGui::GetItemRectMax().x;
2573 float next_button_x2 = last_button_x2 + style.ItemSpacing.x + button_sz.x; // Expected position if next button was on same line
2574 if (n + 1 < buttons_count && next_button_x2 < window_visible_x2)
2576 ImGui::PopID();
2577 }
2578
2580 }
2581
2582 if (ImGui::TreeNode("Groups"))
2583 {
2584 HelpMarker(
2585 "BeginGroup() basically locks the horizontal position for new line. "
2586 "EndGroup() bundles the whole group so that you can use \"item\" functions such as "
2587 "IsItemHovered()/IsItemActive() or SameLine() etc. on the whole group.");
2589 {
2591 ImGui::Button("AAA");
2593 ImGui::Button("BBB");
2596 ImGui::Button("CCC");
2597 ImGui::Button("DDD");
2600 ImGui::Button("EEE");
2603 ImGui::SetTooltip("First group hovered");
2604 }
2605 // Capture the group size and create widgets using the same size
2607 const float values[5] = { 0.5f, 0.20f, 0.80f, 0.60f, 0.25f };
2608 ImGui::PlotHistogram("##values", values, IM_ARRAYSIZE(values), 0, NULL, 0.0f, 1.0f, size);
2609
2610 ImGui::Button("ACTION", ImVec2((size.x - ImGui::GetStyle().ItemSpacing.x) * 0.5f, size.y));
2612 ImGui::Button("REACTION", ImVec2((size.x - ImGui::GetStyle().ItemSpacing.x) * 0.5f, size.y));
2615
2616 ImGui::Button("LEVERAGE\nBUZZWORD", size);
2618
2619 if (ImGui::BeginListBox("List", size))
2620 {
2621 ImGui::Selectable("Selected", true);
2622 ImGui::Selectable("Not Selected", false);
2624 }
2625
2627 }
2628
2629 if (ImGui::TreeNode("Text Baseline Alignment"))
2630 {
2631 {
2632 ImGui::BulletText("Text baseline:");
2634 "This is testing the vertical alignment that gets applied on text to keep it aligned with widgets. "
2635 "Lines only composed of text or \"small\" widgets use less vertical space than lines with framed widgets.");
2636 ImGui::Indent();
2637
2638 ImGui::Text("KO Blahblah"); ImGui::SameLine();
2639 ImGui::Button("Some framed item"); ImGui::SameLine();
2640 HelpMarker("Baseline of button will look misaligned with text..");
2641
2642 // If your line starts with text, call AlignTextToFramePadding() to align text to upcoming widgets.
2643 // (because we don't know what's coming after the Text() statement, we need to move the text baseline
2644 // down by FramePadding.y ahead of time)
2646 ImGui::Text("OK Blahblah"); ImGui::SameLine();
2647 ImGui::Button("Some framed item"); ImGui::SameLine();
2648 HelpMarker("We call AlignTextToFramePadding() to vertically align the text baseline by +FramePadding.y");
2649
2650 // SmallButton() uses the same vertical padding as Text
2651 ImGui::Button("TEST##1"); ImGui::SameLine();
2652 ImGui::Text("TEST"); ImGui::SameLine();
2653 ImGui::SmallButton("TEST##2");
2654
2655 // If your line starts with text, call AlignTextToFramePadding() to align text to upcoming widgets.
2657 ImGui::Text("Text aligned to framed item"); ImGui::SameLine();
2658 ImGui::Button("Item##1"); ImGui::SameLine();
2659 ImGui::Text("Item"); ImGui::SameLine();
2660 ImGui::SmallButton("Item##2"); ImGui::SameLine();
2661 ImGui::Button("Item##3");
2662
2664 }
2665
2667
2668 {
2669 ImGui::BulletText("Multi-line text:");
2670 ImGui::Indent();
2671 ImGui::Text("One\nTwo\nThree"); ImGui::SameLine();
2672 ImGui::Text("Hello\nWorld"); ImGui::SameLine();
2673 ImGui::Text("Banana");
2674
2675 ImGui::Text("Banana"); ImGui::SameLine();
2676 ImGui::Text("Hello\nWorld"); ImGui::SameLine();
2677 ImGui::Text("One\nTwo\nThree");
2678
2679 ImGui::Button("HOP##1"); ImGui::SameLine();
2680 ImGui::Text("Banana"); ImGui::SameLine();
2681 ImGui::Text("Hello\nWorld"); ImGui::SameLine();
2682 ImGui::Text("Banana");
2683
2684 ImGui::Button("HOP##2"); ImGui::SameLine();
2685 ImGui::Text("Hello\nWorld"); ImGui::SameLine();
2686 ImGui::Text("Banana");
2688 }
2689
2691
2692 {
2693 ImGui::BulletText("Misc items:");
2694 ImGui::Indent();
2695
2696 // SmallButton() sets FramePadding to zero. Text baseline is aligned to match baseline of previous Button.
2697 ImGui::Button("80x80", ImVec2(80, 80));
2699 ImGui::Button("50x50", ImVec2(50, 50));
2701 ImGui::Button("Button()");
2703 ImGui::SmallButton("SmallButton()");
2704
2705 // Tree
2706 const float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
2707 ImGui::Button("Button##1");
2708 ImGui::SameLine(0.0f, spacing);
2709 if (ImGui::TreeNode("Node##1"))
2710 {
2711 // Placeholder tree data
2712 for (int i = 0; i < 6; i++)
2713 ImGui::BulletText("Item %d..", i);
2715 }
2716
2717 // Vertically align text node a bit lower so it'll be vertically centered with upcoming widget.
2718 // Otherwise you can use SmallButton() (smaller fit).
2720
2721 // Common mistake to avoid: if we want to SameLine after TreeNode we need to do it before we add
2722 // other contents below the node.
2723 bool node_open = ImGui::TreeNode("Node##2");
2724 ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##2");
2725 if (node_open)
2726 {
2727 // Placeholder tree data
2728 for (int i = 0; i < 6; i++)
2729 ImGui::BulletText("Item %d..", i);
2731 }
2732
2733 // Bullet
2734 ImGui::Button("Button##3");
2735 ImGui::SameLine(0.0f, spacing);
2736 ImGui::BulletText("Bullet text");
2737
2739 ImGui::BulletText("Node");
2740 ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##4");
2742 }
2743
2745 }
2746
2747 if (ImGui::TreeNode("Scrolling"))
2748 {
2749 // Vertical scroll functions
2750 HelpMarker("Use SetScrollHereY() or SetScrollFromPosY() to scroll to a given vertical position.");
2751
2752 static int track_item = 50;
2753 static bool enable_track = true;
2754 static bool enable_extra_decorations = false;
2755 static float scroll_to_off_px = 0.0f;
2756 static float scroll_to_pos_px = 200.0f;
2757
2758 ImGui::Checkbox("Decoration", &enable_extra_decorations);
2759
2760 ImGui::Checkbox("Track", &enable_track);
2762 ImGui::SameLine(140); enable_track |= ImGui::DragInt("##item", &track_item, 0.25f, 0, 99, "Item = %d");
2763
2764 bool scroll_to_off = ImGui::Button("Scroll Offset");
2765 ImGui::SameLine(140); scroll_to_off |= ImGui::DragFloat("##off", &scroll_to_off_px, 1.00f, 0, FLT_MAX, "+%.0f px");
2766
2767 bool scroll_to_pos = ImGui::Button("Scroll To Pos");
2768 ImGui::SameLine(140); scroll_to_pos |= ImGui::DragFloat("##pos", &scroll_to_pos_px, 1.00f, -10, FLT_MAX, "X/Y = %.0f px");
2770
2771 if (scroll_to_off || scroll_to_pos)
2772 enable_track = false;
2773
2775 float child_w = (ImGui::GetContentRegionAvail().x - 4 * style.ItemSpacing.x) / 5;
2776 if (child_w < 1.0f)
2777 child_w = 1.0f;
2778 ImGui::PushID("##VerticalScrolling");
2779 for (int i = 0; i < 5; i++)
2780 {
2781 if (i > 0) ImGui::SameLine();
2783 const char* names[] = { "Top", "25%", "Center", "75%", "Bottom" };
2784 ImGui::TextUnformatted(names[i]);
2785
2786 const ImGuiWindowFlags child_flags = enable_extra_decorations ? ImGuiWindowFlags_MenuBar : 0;
2787 const ImGuiID child_id = ImGui::GetID((void*)(intptr_t)i);
2788 const bool child_is_visible = ImGui::BeginChild(child_id, ImVec2(child_w, 200.0f), true, child_flags);
2789 if (ImGui::BeginMenuBar())
2790 {
2793 }
2794 if (scroll_to_off)
2795 ImGui::SetScrollY(scroll_to_off_px);
2796 if (scroll_to_pos)
2797 ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_pos_px, i * 0.25f);
2798 if (child_is_visible) // Avoid calling SetScrollHereY when running with culled items
2799 {
2800 for (int item = 0; item < 100; item++)
2801 {
2802 if (enable_track && item == track_item)
2803 {
2804 ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item);
2805 ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom
2806 }
2807 else
2808 {
2809 ImGui::Text("Item %d", item);
2810 }
2811 }
2812 }
2813 float scroll_y = ImGui::GetScrollY();
2814 float scroll_max_y = ImGui::GetScrollMaxY();
2816 ImGui::Text("%.0f/%.0f", scroll_y, scroll_max_y);
2818 }
2819 ImGui::PopID();
2820
2821 // Horizontal scroll functions
2823 HelpMarker(
2824 "Use SetScrollHereX() or SetScrollFromPosX() to scroll to a given horizontal position.\n\n"
2825 "Because the clipping rectangle of most window hides half worth of WindowPadding on the "
2826 "left/right, using SetScrollFromPosX(+1) will usually result in clipped text whereas the "
2827 "equivalent SetScrollFromPosY(+1) wouldn't.");
2828 ImGui::PushID("##HorizontalScrolling");
2829 for (int i = 0; i < 5; i++)
2830 {
2831 float child_height = ImGui::GetTextLineHeight() + style.ScrollbarSize + style.WindowPadding.y * 2.0f;
2833 ImGuiID child_id = ImGui::GetID((void*)(intptr_t)i);
2834 bool child_is_visible = ImGui::BeginChild(child_id, ImVec2(-100, child_height), true, child_flags);
2835 if (scroll_to_off)
2836 ImGui::SetScrollX(scroll_to_off_px);
2837 if (scroll_to_pos)
2838 ImGui::SetScrollFromPosX(ImGui::GetCursorStartPos().x + scroll_to_pos_px, i * 0.25f);
2839 if (child_is_visible) // Avoid calling SetScrollHereY when running with culled items
2840 {
2841 for (int item = 0; item < 100; item++)
2842 {
2843 if (item > 0)
2845 if (enable_track && item == track_item)
2846 {
2847 ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item);
2848 ImGui::SetScrollHereX(i * 0.25f); // 0.0f:left, 0.5f:center, 1.0f:right
2849 }
2850 else
2851 {
2852 ImGui::Text("Item %d", item);
2853 }
2854 }
2855 }
2856 float scroll_x = ImGui::GetScrollX();
2857 float scroll_max_x = ImGui::GetScrollMaxX();
2860 const char* names[] = { "Left", "25%", "Center", "75%", "Right" };
2861 ImGui::Text("%s\n%.0f/%.0f", names[i], scroll_x, scroll_max_x);
2863 }
2864 ImGui::PopID();
2865
2866 // Miscellaneous Horizontal Scrolling Demo
2867 HelpMarker(
2868 "Horizontal scrolling for a window is enabled via the ImGuiWindowFlags_HorizontalScrollbar flag.\n\n"
2869 "You may want to also explicitly specify content width by using SetNextWindowContentWidth() before Begin().");
2870 static int lines = 7;
2871 ImGui::SliderInt("Lines", &lines, 1, 15);
2874 ImVec2 scrolling_child_size = ImVec2(0, ImGui::GetFrameHeightWithSpacing() * 7 + 30);
2875 ImGui::BeginChild("scrolling", scrolling_child_size, true, ImGuiWindowFlags_HorizontalScrollbar);
2876 for (int line = 0; line < lines; line++)
2877 {
2878 // Display random stuff. For the sake of this trivial demo we are using basic Button() + SameLine()
2879 // If you want to create your own time line for a real application you may be better off manipulating
2880 // the cursor position yourself, aka using SetCursorPos/SetCursorScreenPos to position the widgets
2881 // yourself. You may also want to use the lower-level ImDrawList API.
2882 int num_buttons = 10 + ((line & 1) ? line * 9 : line * 3);
2883 for (int n = 0; n < num_buttons; n++)
2884 {
2885 if (n > 0) ImGui::SameLine();
2886 ImGui::PushID(n + line * 1000);
2887 char num_buf[16];
2888 sprintf(num_buf, "%d", n);
2889 const char* label = (!(n % 15)) ? "FizzBuzz" : (!(n % 3)) ? "Fizz" : (!(n % 5)) ? "Buzz" : num_buf;
2890 float hue = n * 0.05f;
2894 ImGui::Button(label, ImVec2(40.0f + sinf((float)(line + n)) * 20.0f, 0.0f));
2896 ImGui::PopID();
2897 }
2898 }
2899 float scroll_x = ImGui::GetScrollX();
2900 float scroll_max_x = ImGui::GetScrollMaxX();
2903 float scroll_x_delta = 0.0f;
2904 ImGui::SmallButton("<<");
2905 if (ImGui::IsItemActive())
2906 scroll_x_delta = -ImGui::GetIO().DeltaTime * 1000.0f;
2908 ImGui::Text("Scroll from code"); ImGui::SameLine();
2909 ImGui::SmallButton(">>");
2910 if (ImGui::IsItemActive())
2911 scroll_x_delta = +ImGui::GetIO().DeltaTime * 1000.0f;
2913 ImGui::Text("%.0f/%.0f", scroll_x, scroll_max_x);
2914 if (scroll_x_delta != 0.0f)
2915 {
2916 // Demonstrate a trick: you can use Begin to set yourself in the context of another window
2917 // (here we are already out of your child window)
2918 ImGui::BeginChild("scrolling");
2919 ImGui::SetScrollX(ImGui::GetScrollX() + scroll_x_delta);
2921 }
2923
2924 static bool show_horizontal_contents_size_demo_window = false;
2925 ImGui::Checkbox("Show Horizontal contents size demo window", &show_horizontal_contents_size_demo_window);
2926
2927 if (show_horizontal_contents_size_demo_window)
2928 {
2929 static bool show_h_scrollbar = true;
2930 static bool show_button = true;
2931 static bool show_tree_nodes = true;
2932 static bool show_text_wrapped = false;
2933 static bool show_columns = true;
2934 static bool show_tab_bar = true;
2935 static bool show_child = false;
2936 static bool explicit_content_size = false;
2937 static float contents_size_x = 300.0f;
2938 if (explicit_content_size)
2939 ImGui::SetNextWindowContentSize(ImVec2(contents_size_x, 0.0f));
2940 ImGui::Begin("Horizontal contents size demo window", &show_horizontal_contents_size_demo_window, show_h_scrollbar ? ImGuiWindowFlags_HorizontalScrollbar : 0);
2943 HelpMarker("Test of different widgets react and impact the work rectangle growing when horizontal scrolling is enabled.\n\nUse 'Metrics->Tools->Show windows rectangles' to visualize rectangles.");
2944 ImGui::Checkbox("H-scrollbar", &show_h_scrollbar);
2945 ImGui::Checkbox("Button", &show_button); // Will grow contents size (unless explicitly overwritten)
2946 ImGui::Checkbox("Tree nodes", &show_tree_nodes); // Will grow contents size and display highlight over full width
2947 ImGui::Checkbox("Text wrapped", &show_text_wrapped);// Will grow and use contents size
2948 ImGui::Checkbox("Columns", &show_columns); // Will use contents size
2949 ImGui::Checkbox("Tab bar", &show_tab_bar); // Will use contents size
2950 ImGui::Checkbox("Child", &show_child); // Will grow and use contents size
2951 ImGui::Checkbox("Explicit content size", &explicit_content_size);
2953 if (explicit_content_size)
2954 {
2957 ImGui::DragFloat("##csx", &contents_size_x);
2960 ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(p.x + contents_size_x - 10, p.y), ImVec2(p.x + contents_size_x, p.y + 10), IM_COL32_WHITE);
2961 ImGui::Dummy(ImVec2(0, 10));
2962 }
2965 if (show_button)
2966 {
2967 ImGui::Button("this is a 300-wide button", ImVec2(300, 0));
2968 }
2969 if (show_tree_nodes)
2970 {
2971 bool open = true;
2972 if (ImGui::TreeNode("this is a tree node"))
2973 {
2974 if (ImGui::TreeNode("another one of those tree node..."))
2975 {
2976 ImGui::Text("Some tree contents");
2978 }
2980 }
2981 ImGui::CollapsingHeader("CollapsingHeader", &open);
2982 }
2983 if (show_text_wrapped)
2984 {
2985 ImGui::TextWrapped("This text should automatically wrap on the edge of the work rectangle.");
2986 }
2987 if (show_columns)
2988 {
2989 ImGui::Text("Tables:");
2991 {
2992 for (int n = 0; n < 4; n++)
2993 {
2995 ImGui::Text("Width %.2f", ImGui::GetContentRegionAvail().x);
2996 }
2998 }
2999 ImGui::Text("Columns:");
3000 ImGui::Columns(4);
3001 for (int n = 0; n < 4; n++)
3002 {
3003 ImGui::Text("Width %.2f", ImGui::GetColumnWidth());
3005 }
3006 ImGui::Columns(1);
3007 }
3008 if (show_tab_bar && ImGui::BeginTabBar("Hello"))
3009 {
3010 if (ImGui::BeginTabItem("OneOneOne")) { ImGui::EndTabItem(); }
3011 if (ImGui::BeginTabItem("TwoTwoTwo")) { ImGui::EndTabItem(); }
3012 if (ImGui::BeginTabItem("ThreeThreeThree")) { ImGui::EndTabItem(); }
3013 if (ImGui::BeginTabItem("FourFourFour")) { ImGui::EndTabItem(); }
3015 }
3016 if (show_child)
3017 {
3018 ImGui::BeginChild("child", ImVec2(0, 0), true);
3020 }
3021 ImGui::End();
3022 }
3023
3025 }
3026
3027 if (ImGui::TreeNode("Clipping"))
3028 {
3029 static ImVec2 size(100.0f, 100.0f);
3030 static ImVec2 offset(30.0f, 30.0f);
3031 ImGui::DragFloat2("size", (float*)&size, 0.5f, 1.0f, 200.0f, "%.0f");
3032 ImGui::TextWrapped("(Click and drag to scroll)");
3033
3034 for (int n = 0; n < 3; n++)
3035 {
3036 if (n > 0)
3038 ImGui::PushID(n);
3039 ImGui::BeginGroup(); // Lock X position
3040
3041 ImGui::InvisibleButton("##empty", size);
3043 {
3046 }
3047 const ImVec2 p0 = ImGui::GetItemRectMin();
3048 const ImVec2 p1 = ImGui::GetItemRectMax();
3049 const char* text_str = "Line 1 hello\nLine 2 clip me!";
3050 const ImVec2 text_pos = ImVec2(p0.x + offset.x, p0.y + offset.y);
3051 ImDrawList* draw_list = ImGui::GetWindowDrawList();
3052
3053 switch (n)
3054 {
3055 case 0:
3056 HelpMarker(
3057 "Using ImGui::PushClipRect():\n"
3058 "Will alter ImGui hit-testing logic + ImDrawList rendering.\n"
3059 "(use this if you want your clipping rectangle to affect interactions)");
3060 ImGui::PushClipRect(p0, p1, true);
3061 draw_list->AddRectFilled(p0, p1, IM_COL32(90, 90, 120, 255));
3062 draw_list->AddText(text_pos, IM_COL32_WHITE, text_str);
3064 break;
3065 case 1:
3066 HelpMarker(
3067 "Using ImDrawList::PushClipRect():\n"
3068 "Will alter ImDrawList rendering only.\n"
3069 "(use this as a shortcut if you are only using ImDrawList calls)");
3070 draw_list->PushClipRect(p0, p1, true);
3071 draw_list->AddRectFilled(p0, p1, IM_COL32(90, 90, 120, 255));
3072 draw_list->AddText(text_pos, IM_COL32_WHITE, text_str);
3073 draw_list->PopClipRect();
3074 break;
3075 case 2:
3076 HelpMarker(
3077 "Using ImDrawList::AddText() with a fine ClipRect:\n"
3078 "Will alter only this specific ImDrawList::AddText() rendering.\n"
3079 "(this is often used internally to avoid altering the clipping rectangle and minimize draw calls)");
3080 ImVec4 clip_rect(p0.x, p0.y, p1.x, p1.y); // AddText() takes a ImVec4* here so let's convert.
3081 draw_list->AddRectFilled(p0, p1, IM_COL32(90, 90, 120, 255));
3082 draw_list->AddText(ImGui::GetFont(), ImGui::GetFontSize(), text_pos, IM_COL32_WHITE, text_str, NULL, 0.0f, &clip_rect);
3083 break;
3084 }
3086 ImGui::PopID();
3087 }
3088
3090 }
3091}
static double scroll_x
Definition Viewer.cpp:50
static double scroll_y
Definition Viewer.cpp:51
#define IM_COL32_WHITE
Definition imgui.h:2178
int ImGuiWindowFlags
Definition imgui.h:201
#define IM_COL32(R, G, B, A)
Definition imgui.h:2177
unsigned int ImGuiID
Definition imgui.h:207
@ ImGuiStyleVar_ChildRounding
Definition imgui.h:1485
@ ImGuiStyleVar_FrameRounding
Definition imgui.h:1490
@ ImGuiCol_Button
Definition imgui.h:1434
@ ImGuiCol_ButtonHovered
Definition imgui.h:1435
@ ImGuiCol_ButtonActive
Definition imgui.h:1436
@ ImGuiCol_ChildBg
Definition imgui.h:1416
@ ImGuiMouseButton_Left
Definition imgui.h:1586
@ ImGuiWindowFlags_MenuBar
Definition imgui.h:926
@ ImGuiWindowFlags_AlwaysVerticalScrollbar
Definition imgui.h:930
@ ImGuiWindowFlags_NoScrollWithMouse
Definition imgui.h:920
@ ImGuiWindowFlags_None
Definition imgui.h:915
@ ImGuiTableFlags_NoSavedSettings
Definition imgui.h:1114
@ ImGuiTableFlags_Borders
Definition imgui.h:1126
@ ImGuiTableFlags_Resizable
Definition imgui.h:1110
static void ShowExampleMenuFile()
Definition imgui_demo.cpp:6202
IMGUI_API bool BeginTable(const char *str_id, int column, ImGuiTableFlags flags=0, const ImVec2 &outer_size=ImVec2(0.0f, 0.0f), float inner_width=0.0f)
Definition imgui_tables.cpp:309
IMGUI_API void EndGroup()
Definition imgui.cpp:7741
IMGUI_API void SetScrollX(float scroll_x)
Definition imgui.cpp:7926
IMGUI_API bool IsMouseDragging(ImGuiMouseButton button, float lock_threshold=-1.0f)
Definition imgui.cpp:4743
IMGUI_API void PushClipRect(const ImVec2 &clip_rect_min, const ImVec2 &clip_rect_max, bool intersect_with_current_clip_rect)
Definition imgui.cpp:4365
IMGUI_API void EndMenu()
Definition imgui_widgets.cpp:6856
IMGUI_API bool BeginMenu(const char *label, bool enabled=true)
Definition imgui_widgets.cpp:6692
IMGUI_API bool InvisibleButton(const char *str_id, const ImVec2 &size, ImGuiButtonFlags flags=0)
Definition imgui_widgets.cpp:733
IMGUI_API void Spacing()
Definition imgui_widgets.cpp:1312
IMGUI_API void PushID(const char *str_id)
Definition imgui.cpp:7018
IMGUI_API bool IsItemActive()
Definition imgui.cpp:4831
IMGUI_API bool BeginListBox(const char *label, const ImVec2 &size=ImVec2(0, 0))
Definition imgui_widgets.cpp:6180
IMGUI_API void SetTooltip(const char *fmt,...) IM_FMTARGS(1)
Definition imgui.cpp:8058
IMGUI_API ImGuiIO & GetIO()
Definition imgui.cpp:3439
IMGUI_API void SetScrollHereX(float center_x_ratio=0.5f)
Definition imgui.cpp:7979
IMGUI_API ImVec2 GetItemRectSize()
Definition imgui.cpp:4963
IMGUI_API ImGuiID GetID(const char *str_id)
Definition imgui.cpp:7079
IMGUI_API void TextColored(const ImVec4 &col, const char *fmt,...) IM_FMTARGS(2)
Definition imgui_widgets.cpp:279
IMGUI_API float GetScrollY()
Definition imgui.cpp:7894
IMGUI_API ImVec2 GetItemRectMax()
Definition imgui.cpp:4957
IMGUI_API ImVec2 GetWindowPos()
Definition imgui.cpp:6713
IMGUI_API void SetScrollY(float scroll_y)
Definition imgui.cpp:7932
IMGUI_API void BeginGroup()
Definition imgui.cpp:7714
IMGUI_API void EndTabItem()
Definition imgui_widgets.cpp:7674
IMGUI_API ImFont * GetFont()
Definition imgui.cpp:6932
IMGUI_API bool ListBox(const char *label, int *current_item, const char *const items[], int items_count, int height_in_items=-1)
Definition imgui_widgets.cpp:6244
IMGUI_API bool BeginMenuBar()
Definition imgui_widgets.cpp:6551
IMGUI_API void PushItemWidth(float item_width)
Definition imgui.cpp:7563
IMGUI_API bool BeginTabItem(const char *label, bool *p_open=NULL, ImGuiTabItemFlags flags=0)
Definition imgui_widgets.cpp:7650
IMGUI_API void End()
Definition imgui.cpp:6366
IMGUI_API bool SliderInt(const char *label, int *v, int v_min, int v_max, const char *format="%d", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:3068
IMGUI_API bool Begin(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
Definition imgui.cpp:5722
IMGUI_API bool SmallButton(const char *label)
Definition imgui_widgets.cpp:721
IMGUI_API ImVec2 GetItemRectMin()
Definition imgui.cpp:4951
IMGUI_API void SetScrollFromPosY(float local_y, float center_y_ratio=0.5f)
Definition imgui.cpp:7972
IMGUI_API void EndListBox()
Definition imgui_widgets.cpp:6233
IMGUI_API void Indent(float indent_w=0.0f)
Definition imgui.cpp:7538
IMGUI_API float GetScrollX()
Definition imgui.cpp:7888
IMGUI_API void PushStyleColor(ImGuiCol idx, ImU32 col)
Definition imgui.cpp:2462
IMGUI_API void EndTabBar()
Definition imgui_widgets.cpp:7088
IMGUI_API bool SliderFloat(const char *label, float *v, float v_min, float v_max, const char *format="%.3f", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:3038
IMGUI_API float GetWindowContentRegionWidth()
Definition imgui.cpp:7706
IMGUI_API void Dummy(const ImVec2 &size)
Definition imgui_widgets.cpp:1320
IMGUI_API float GetFrameHeightWithSpacing()
Definition imgui.cpp:7657
IMGUI_API ImVec2 GetCursorStartPos()
Definition imgui.cpp:7532
IMGUI_API ImVec2 GetWindowContentRegionMax()
Definition imgui.cpp:7700
IMGUI_API void PopStyleColor(int count=1)
Definition imgui.cpp:2482
IMGUI_API void EndTable()
Definition imgui_tables.cpp:1199
IMGUI_API ImDrawList * GetWindowDrawList()
Definition imgui.cpp:6926
IMGUI_API void EndMenuBar()
Definition imgui_widgets.cpp:6579
IMGUI_API bool Combo(const char *label, int *current_item, const char *const items[], int items_count, int popup_max_height_in_items=-1)
Definition imgui_widgets.cpp:1754
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", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:2426
IMGUI_API float GetTextLineHeight()
Definition imgui.cpp:7639
IMGUI_API float GetScrollMaxY()
Definition imgui.cpp:7906
IMGUI_API bool BeginTabBar(const char *str_id, ImGuiTabBarFlags flags=0)
Definition imgui_widgets.cpp:7015
IMGUI_API void PopID()
Definition imgui.cpp:7072
IMGUI_API void SetScrollHereY(float center_y_ratio=0.5f)
Definition imgui.cpp:7992
IMGUI_API bool TableNextColumn()
Definition imgui_tables.cpp:1890
IMGUI_API void SetScrollFromPosX(float local_x, float center_x_ratio=0.5f)
Definition imgui.cpp:7966
IMGUI_API void PopItemWidth()
Definition imgui.cpp:7587
IMGUI_API void Unindent(float indent_w=0.0f)
Definition imgui.cpp:7546
IMGUI_API ImVec2 GetCursorScreenPos()
Definition imgui.cpp:7478
IMGUI_API void AlignTextToFramePadding()
Definition imgui_widgets.cpp:1347
IMGUI_API void PopClipRect()
Definition imgui.cpp:4372
IMGUI_API float GetScrollMaxX()
Definition imgui.cpp:7900
IMGUI_API void PlotHistogram(const char *label, const float *values, int values_count, int values_offset=0, const char *overlay_text=NULL, float scale_min=FLT_MAX, float scale_max=FLT_MAX, ImVec2 graph_size=ImVec2(0, 0), int stride=sizeof(float))
Definition imgui_widgets.cpp:6452
IMGUI_API void BulletText(const char *fmt,...) IM_FMTARGS(1)
Definition imgui_widgets.cpp:375
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", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:2431
constexpr auto size(const C &c) -> decltype(c.size())
Definition span.hpp:183
void offset(Slic3r::ExPolygon &sh, coord_t distance, const PolygonTag &)
Definition geometries.hpp:132
static ImColor HSV(float h, float s, float v, float a=1.0f)
Definition imgui.h:2200
Definition imgui.h:2348
IMGUI_API void PopClipRect()
Definition imgui_draw.cpp:592
IMGUI_API void AddRectFilled(const ImVec2 &p_min, const ImVec2 &p_max, ImU32 col, float rounding=0.0f, ImDrawFlags flags=0)
Definition imgui_draw.cpp:1388
IMGUI_API void AddText(const ImVec2 &pos, ImU32 col, const char *text_begin, const char *text_end=NULL)
Definition imgui_draw.cpp:1593
IMGUI_API void PushClipRect(ImVec2 clip_rect_min, ImVec2 clip_rect_max, bool intersect_with_current_clip_rect=false)
Definition imgui_draw.cpp:568
float DeltaTime
Definition imgui.h:1783
ImVec2 MouseDelta
Definition imgui.h:1873
ImVec2 ItemInnerSpacing
Definition imgui.h:1737
ImVec2 ItemSpacing
Definition imgui.h:1736
float y
Definition imgui.h:246
float x
Definition imgui.h:246
Definition imgui.h:258

References ImDrawList::AddRectFilled(), ImDrawList::AddText(), ImGui::AlignTextToFramePadding(), ImGui::Begin(), ImGui::BeginChild(), ImGui::BeginGroup(), ImGui::BeginListBox(), ImGui::BeginMenu(), ImGui::BeginMenuBar(), ImGui::BeginTabBar(), ImGui::BeginTabItem(), ImGui::BeginTable(), ImGui::BulletText(), ImGui::Button(), ImGui::Checkbox(), ImGui::CollapsingHeader(), ImGui::Columns(), ImGui::Combo(), ImGuiIO::DeltaTime, ImGui::DragFloat(), ImGui::DragFloat2(), ImGui::DragInt(), ImGui::Dummy(), ImGui::End(), ImGui::EndChild(), ImGui::EndGroup(), ImGui::EndListBox(), ImGui::EndMenu(), ImGui::EndMenuBar(), ImGui::EndTabBar(), ImGui::EndTabItem(), ImGui::EndTable(), ImGui::GetColumnWidth(), ImGui::GetContentRegionAvail(), ImGui::GetCursorPosX(), ImGui::GetCursorScreenPos(), ImGui::GetCursorStartPos(), ImGui::GetFont(), ImGui::GetFontSize(), ImGui::GetFrameHeightWithSpacing(), ImGui::GetID(), ImGui::GetIO(), ImGui::GetItemRectMax(), ImGui::GetItemRectMin(), ImGui::GetItemRectSize(), ImGui::GetScrollMaxX(), ImGui::GetScrollMaxY(), ImGui::GetScrollX(), ImGui::GetScrollY(), ImGui::GetStyle(), ImGui::GetTextLineHeight(), ImGui::GetWindowContentRegionMax(), ImGui::GetWindowContentRegionWidth(), ImGui::GetWindowDrawList(), ImGui::GetWindowPos(), HelpMarker(), ImColor::HSV(), IM_ARRAYSIZE, IM_COL32, IM_COL32_WHITE, ImGuiCol_Button, ImGuiCol_ButtonActive, ImGuiCol_ButtonHovered, ImGuiCol_ChildBg, ImGuiMouseButton_Left, ImGuiStyleVar_ChildRounding, ImGuiStyleVar_FramePadding, ImGuiStyleVar_FrameRounding, ImGuiStyleVar_ItemSpacing, ImGuiTableFlags_Borders, ImGuiTableFlags_NoSavedSettings, ImGuiTableFlags_Resizable, ImGuiWindowFlags_AlwaysVerticalScrollbar, ImGuiWindowFlags_HorizontalScrollbar, ImGuiWindowFlags_MenuBar, ImGuiWindowFlags_None, ImGuiWindowFlags_NoScrollWithMouse, ImGui::Indent(), ImGui::InvisibleButton(), ImGui::IsItemActive(), ImGui::IsItemHovered(), ImGui::IsMouseDragging(), ImGuiStyle::ItemInnerSpacing, ImGuiStyle::ItemSpacing, ImGui::ListBox(), ImGuiIO::MouseDelta, ImGui::NextColumn(), ImGui::PlotHistogram(), ImGui::PopClipRect(), ImDrawList::PopClipRect(), ImGui::PopID(), ImGui::PopItemWidth(), ImGui::PopStyleColor(), ImGui::PopStyleVar(), ImGui::PushClipRect(), ImDrawList::PushClipRect(), ImGui::PushID(), ImGui::PushItemWidth(), ImGui::PushStyleColor(), ImGui::PushStyleVar(), ImGui::SameLine(), scroll_x, scroll_y, ImGui::Selectable(), ImGui::Separator(), ImGui::SetCursorPosX(), ImGui::SetNextItemWidth(), ImGui::SetNextWindowContentSize(), ImGui::SetScrollFromPosX(), ImGui::SetScrollFromPosY(), ImGui::SetScrollHereX(), ImGui::SetScrollHereY(), ImGui::SetScrollX(), ImGui::SetScrollY(), ImGui::SetTooltip(), ShowExampleMenuFile(), ImGui::SliderFloat(), ImGui::SliderInt(), ImGui::SmallButton(), ImGui::Spacing(), style, ImGui::TableNextColumn(), ImGui::Text(), ImGui::TextColored(), ImGui::TextUnformatted(), ImGui::TextWrapped(), ImGui::TreeNode(), ImGui::TreePop(), ImGui::Unindent(), ImVec2::x, and ImVec2::y.

Referenced by ImGui::ShowDemoWindow().

+ Here is the caller graph for this function:

◆ ShowDemoWindowMisc()

static void ShowDemoWindowMisc ( )
static
5428{
5429 if (ImGui::CollapsingHeader("Filtering"))
5430 {
5431 // Helper class to easy setup a text filter.
5432 // You may want to implement a more feature-full filtering scheme in your own application.
5433 static ImGuiTextFilter filter;
5434 ImGui::Text("Filter usage:\n"
5435 " \"\" display all lines\n"
5436 " \"xxx\" display lines containing \"xxx\"\n"
5437 " \"xxx,yyy\" display lines containing \"xxx\" or \"yyy\"\n"
5438 " \"-xxx\" hide lines containing \"xxx\"");
5439 filter.Draw();
5440 const char* lines[] = { "aaa1.c", "bbb1.c", "ccc1.c", "aaa2.cpp", "bbb2.cpp", "ccc2.cpp", "abc.h", "hello, world" };
5441 for (int i = 0; i < IM_ARRAYSIZE(lines); i++)
5442 if (filter.PassFilter(lines[i]))
5443 ImGui::BulletText("%s", lines[i]);
5444 }
5445
5446 if (ImGui::CollapsingHeader("Inputs, Navigation & Focus"))
5447 {
5448 ImGuiIO& io = ImGui::GetIO();
5449
5450 // Display ImGuiIO output flags
5451 ImGui::Text("WantCaptureMouse: %d", io.WantCaptureMouse);
5452 ImGui::Text("WantCaptureKeyboard: %d", io.WantCaptureKeyboard);
5453 ImGui::Text("WantTextInput: %d", io.WantTextInput);
5454 ImGui::Text("WantSetMousePos: %d", io.WantSetMousePos);
5455 ImGui::Text("NavActive: %d, NavVisible: %d", io.NavActive, io.NavVisible);
5456
5457 // Display Mouse state
5458 if (ImGui::TreeNode("Mouse State"))
5459 {
5461 ImGui::Text("Mouse pos: (%g, %g)", io.MousePos.x, io.MousePos.y);
5462 else
5463 ImGui::Text("Mouse pos: <INVALID>");
5464 ImGui::Text("Mouse delta: (%g, %g)", io.MouseDelta.x, io.MouseDelta.y);
5465 ImGui::Text("Mouse down:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseDown(i)) { ImGui::SameLine(); ImGui::Text("b%d (%.02f secs)", i, io.MouseDownDuration[i]); }
5466 ImGui::Text("Mouse clicked:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseClicked(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); }
5467 ImGui::Text("Mouse dblclick:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseDoubleClicked(i)){ ImGui::SameLine(); ImGui::Text("b%d", i); }
5468 ImGui::Text("Mouse released:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseReleased(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); }
5469 ImGui::Text("Mouse wheel: %.1f", io.MouseWheel);
5470 ImGui::Text("Pen Pressure: %.1f", io.PenPressure); // Note: currently unused
5472 }
5473
5474 // Display Keyboard/Mouse state
5475 if (ImGui::TreeNode("Keyboard & Navigation State"))
5476 {
5477 ImGui::Text("Keys down:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyDown(i)) { ImGui::SameLine(); ImGui::Text("%d (0x%X) (%.02f secs)", i, i, io.KeysDownDuration[i]); }
5478 ImGui::Text("Keys pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyPressed(i)) { ImGui::SameLine(); ImGui::Text("%d (0x%X)", i, i); }
5479 ImGui::Text("Keys release:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyReleased(i)) { ImGui::SameLine(); ImGui::Text("%d (0x%X)", i, i); }
5480 ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : "");
5481 ImGui::Text("Chars queue:"); for (int i = 0; i < io.InputQueueCharacters.Size; i++) { ImWchar c = io.InputQueueCharacters[i]; ImGui::SameLine(); ImGui::Text("\'%c\' (0x%04X)", (c > ' ' && c <= 255) ? (char)c : '?', c); } // FIXME: We should convert 'c' to UTF-8 here but the functions are not public.
5482
5483 ImGui::Text("NavInputs down:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputs[i] > 0.0f) { ImGui::SameLine(); ImGui::Text("[%d] %.2f (%.02f secs)", i, io.NavInputs[i], io.NavInputsDownDuration[i]); }
5484 ImGui::Text("NavInputs pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputsDownDuration[i] == 0.0f) { ImGui::SameLine(); ImGui::Text("[%d]", i); }
5485
5486 ImGui::Button("Hovering me sets the\nkeyboard capture flag");
5490 ImGui::Button("Holding me clears the\nthe keyboard capture flag");
5491 if (ImGui::IsItemActive())
5494 }
5495
5496 if (ImGui::TreeNode("Tabbing"))
5497 {
5498 ImGui::Text("Use TAB/SHIFT+TAB to cycle through keyboard editable fields.");
5499 static char buf[32] = "hello";
5500 ImGui::InputText("1", buf, IM_ARRAYSIZE(buf));
5501 ImGui::InputText("2", buf, IM_ARRAYSIZE(buf));
5502 ImGui::InputText("3", buf, IM_ARRAYSIZE(buf));
5504 ImGui::InputText("4 (tab skip)", buf, IM_ARRAYSIZE(buf));
5505 ImGui::SameLine(); HelpMarker("Item won't be cycled through when using TAB or Shift+Tab.");
5507 ImGui::InputText("5", buf, IM_ARRAYSIZE(buf));
5509 }
5510
5511 if (ImGui::TreeNode("Focus from code"))
5512 {
5513 bool focus_1 = ImGui::Button("Focus on 1"); ImGui::SameLine();
5514 bool focus_2 = ImGui::Button("Focus on 2"); ImGui::SameLine();
5515 bool focus_3 = ImGui::Button("Focus on 3");
5516 int has_focus = 0;
5517 static char buf[128] = "click on a button to set focus";
5518
5519 if (focus_1) ImGui::SetKeyboardFocusHere();
5520 ImGui::InputText("1", buf, IM_ARRAYSIZE(buf));
5521 if (ImGui::IsItemActive()) has_focus = 1;
5522
5523 if (focus_2) ImGui::SetKeyboardFocusHere();
5524 ImGui::InputText("2", buf, IM_ARRAYSIZE(buf));
5525 if (ImGui::IsItemActive()) has_focus = 2;
5526
5528 if (focus_3) ImGui::SetKeyboardFocusHere();
5529 ImGui::InputText("3 (tab skip)", buf, IM_ARRAYSIZE(buf));
5530 if (ImGui::IsItemActive()) has_focus = 3;
5531 ImGui::SameLine(); HelpMarker("Item won't be cycled through when using TAB or Shift+Tab.");
5533
5534 if (has_focus)
5535 ImGui::Text("Item with focus: %d", has_focus);
5536 else
5537 ImGui::Text("Item with focus: <none>");
5538
5539 // Use >= 0 parameter to SetKeyboardFocusHere() to focus an upcoming item
5540 static float f3[3] = { 0.0f, 0.0f, 0.0f };
5541 int focus_ahead = -1;
5542 if (ImGui::Button("Focus on X")) { focus_ahead = 0; } ImGui::SameLine();
5543 if (ImGui::Button("Focus on Y")) { focus_ahead = 1; } ImGui::SameLine();
5544 if (ImGui::Button("Focus on Z")) { focus_ahead = 2; }
5545 if (focus_ahead != -1) ImGui::SetKeyboardFocusHere(focus_ahead);
5546 ImGui::SliderFloat3("Float3", &f3[0], 0.0f, 1.0f);
5547
5548 ImGui::TextWrapped("NB: Cursor & selection are preserved when refocusing last used item in code.");
5550 }
5551
5552 if (ImGui::TreeNode("Dragging"))
5553 {
5554 ImGui::TextWrapped("You can use ImGui::GetMouseDragDelta(0) to query for the dragged amount on any widget.");
5555 for (int button = 0; button < 3; button++)
5556 {
5557 ImGui::Text("IsMouseDragging(%d):", button);
5558 ImGui::Text(" w/ default threshold: %d,", ImGui::IsMouseDragging(button));
5559 ImGui::Text(" w/ zero threshold: %d,", ImGui::IsMouseDragging(button, 0.0f));
5560 ImGui::Text(" w/ large threshold: %d,", ImGui::IsMouseDragging(button, 20.0f));
5561 }
5562
5563 ImGui::Button("Drag Me");
5564 if (ImGui::IsItemActive())
5565 ImGui::GetForegroundDrawList()->AddLine(io.MouseClickedPos[0], io.MousePos, ImGui::GetColorU32(ImGuiCol_Button), 4.0f); // Draw a line between the button and the mouse cursor
5566
5567 // Drag operations gets "unlocked" when the mouse has moved past a certain threshold
5568 // (the default threshold is stored in io.MouseDragThreshold). You can request a lower or higher
5569 // threshold using the second parameter of IsMouseDragging() and GetMouseDragDelta().
5570 ImVec2 value_raw = ImGui::GetMouseDragDelta(0, 0.0f);
5571 ImVec2 value_with_lock_threshold = ImGui::GetMouseDragDelta(0);
5572 ImVec2 mouse_delta = io.MouseDelta;
5573 ImGui::Text("GetMouseDragDelta(0):");
5574 ImGui::Text(" w/ default threshold: (%.1f, %.1f)", value_with_lock_threshold.x, value_with_lock_threshold.y);
5575 ImGui::Text(" w/ zero threshold: (%.1f, %.1f)", value_raw.x, value_raw.y);
5576 ImGui::Text("io.MouseDelta: (%.1f, %.1f)", mouse_delta.x, mouse_delta.y);
5578 }
5579
5580 if (ImGui::TreeNode("Mouse cursors"))
5581 {
5582 const char* mouse_cursors_names[] = { "Arrow", "TextInput", "ResizeAll", "ResizeNS", "ResizeEW", "ResizeNESW", "ResizeNWSE", "Hand", "NotAllowed" };
5583 IM_ASSERT(IM_ARRAYSIZE(mouse_cursors_names) == ImGuiMouseCursor_COUNT);
5584
5586 ImGui::Text("Current mouse cursor = %d: %s", current, mouse_cursors_names[current]);
5587 ImGui::Text("Hover to see mouse cursors:");
5589 "Your application can render a different mouse cursor based on what ImGui::GetMouseCursor() returns. "
5590 "If software cursor rendering (io.MouseDrawCursor) is set ImGui will draw the right cursor for you, "
5591 "otherwise your backend needs to handle it.");
5592 for (int i = 0; i < ImGuiMouseCursor_COUNT; i++)
5593 {
5594 char label[32];
5595 sprintf(label, "Mouse cursor %d: %s", i, mouse_cursors_names[i]);
5596 ImGui::Bullet(); ImGui::Selectable(label, false);
5599 }
5601 }
5602 }
5603}
ImWchar16 ImWchar
Definition imgui.h:220
@ ImGuiMouseCursor_COUNT
Definition imgui.h:1606
int ImGuiMouseCursor
Definition imgui.h:174
#define IM_ASSERT(_EXPR)
Definition imgui.h:81
IMGUI_API void PopAllowKeyboardFocus()
Definition imgui.cpp:6577
IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul=1.0f)
Definition imgui.cpp:2429
IMGUI_API bool IsMousePosValid(const ImVec2 *mouse_pos=NULL)
Definition imgui.cpp:4768
IMGUI_API ImVec2 GetMouseDragDelta(ImGuiMouseButton button=0, float lock_threshold=-1.0f)
Definition imgui.cpp:4790
IMGUI_API bool IsMouseDoubleClicked(ImGuiMouseButton button)
Definition imgui.cpp:4725
IMGUI_API bool IsMouseClicked(ImGuiMouseButton button, bool repeat=false)
Definition imgui.cpp:4700
IMGUI_API void CaptureKeyboardFromApp(bool want_capture_keyboard_value=true)
Definition imgui.cpp:4821
IMGUI_API ImGuiMouseCursor GetMouseCursor()
Definition imgui.cpp:4811
IMGUI_API bool IsKeyReleased(int user_key_index)
Definition imgui.cpp:4685
IMGUI_API bool IsKeyDown(int user_key_index)
Definition imgui.cpp:4634
IMGUI_API ImDrawList * GetForegroundDrawList()
Definition imgui.cpp:3503
IMGUI_API bool IsKeyPressed(int user_key_index, bool repeat=true)
Definition imgui.cpp:4671
IMGUI_API bool SliderFloat3(const char *label, float v[3], float v_min, float v_max, const char *format="%.3f", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:3048
IMGUI_API bool InputText(const char *label, char *buf, size_t buf_size, ImGuiInputTextFlags flags=0, ImGuiInputTextCallback callback=NULL, void *user_data=NULL)
Definition imgui_widgets.cpp:3506
IMGUI_API void SetMouseCursor(ImGuiMouseCursor cursor_type)
Definition imgui.cpp:4816
IMGUI_API void PushAllowKeyboardFocus(bool allow_keyboard_focus)
Definition imgui.cpp:6572
IMGUI_API void Bullet()
Definition imgui_widgets.cpp:1276
IMGUI_API bool IsMouseReleased(ImGuiMouseButton button)
Definition imgui.cpp:4718
IMGUI_API void SetKeyboardFocusHere(int offset=0)
Definition imgui.cpp:6979
IMGUI_API bool IsMouseDown(ImGuiMouseButton button)
Definition imgui.cpp:4693
bool button(const IconManager::Icon &activ, const IconManager::Icon &hover, const IconManager::Icon &disable, bool disabled)
Use icon as button with 3 states activ hover and disabled.
Definition IconManager.cpp:195
IMGUI_API void AddLine(const ImVec2 &p1, const ImVec2 &p2, ImU32 col, float thickness=1.0f)
Definition imgui_draw.cpp:1366
Definition imgui.h:1775
bool WantTextInput
Definition imgui.h:1862
bool KeysDown[512]
Definition imgui.h:1845
float NavInputs[ImGuiNavInput_COUNT]
Definition imgui.h:1846
float MouseWheel
Definition imgui.h:1839
ImVec2 MouseClickedPos[5]
Definition imgui.h:1881
bool WantCaptureKeyboard
Definition imgui.h:1861
float NavInputsDownDuration[ImGuiNavInput_COUNT]
Definition imgui.h:1894
ImVector< ImWchar > InputQueueCharacters
Definition imgui.h:1898
bool KeyCtrl
Definition imgui.h:1841
float KeysDownDuration[512]
Definition imgui.h:1892
bool WantSetMousePos
Definition imgui.h:1863
bool MouseDown[5]
Definition imgui.h:1838
bool NavVisible
Definition imgui.h:1866
bool NavActive
Definition imgui.h:1865
float MouseDownDuration[5]
Definition imgui.h:1888
ImVec2 MousePos
Definition imgui.h:1837
float PenPressure
Definition imgui.h:1896
bool WantCaptureMouse
Definition imgui.h:1860
Definition imgui.h:2024
IMGUI_API bool PassFilter(const char *text, const char *text_end=NULL) const
Definition imgui.cpp:2087
IMGUI_API bool Draw(const char *label="Filter (inc,-exc)", float width=0.0f)
Definition imgui.cpp:2038

References ImDrawList::AddLine(), ImGui::Bullet(), ImGui::BulletText(), ImGui::Button(), ImGui::CaptureKeyboardFromApp(), ImGui::CollapsingHeader(), ImGuiTextFilter::Draw(), ImGui::GetColorU32(), ImGui::GetForegroundDrawList(), ImGui::GetIO(), ImGui::GetMouseCursor(), ImGui::GetMouseDragDelta(), HelpMarker(), IM_ARRAYSIZE, IM_ASSERT, ImGuiCol_Button, ImGuiMouseCursor_COUNT, ImGuiIO::InputQueueCharacters, ImGui::InputText(), ImGui::IsItemActive(), ImGui::IsItemHovered(), ImGui::IsKeyDown(), ImGui::IsKeyPressed(), ImGui::IsKeyReleased(), ImGui::IsMouseClicked(), ImGui::IsMouseDoubleClicked(), ImGui::IsMouseDown(), ImGui::IsMouseDragging(), ImGui::IsMousePosValid(), ImGui::IsMouseReleased(), ImGuiIO::KeyAlt, ImGuiIO::KeyCtrl, ImGuiIO::KeysDown, ImGuiIO::KeysDownDuration, ImGuiIO::KeyShift, ImGuiIO::KeySuper, ImGuiIO::MouseClickedPos, ImGuiIO::MouseDelta, ImGuiIO::MouseDown, ImGuiIO::MouseDownDuration, ImGuiIO::MousePos, ImGuiIO::MouseWheel, ImGuiIO::NavActive, ImGuiIO::NavInputs, ImGuiIO::NavInputsDownDuration, ImGuiIO::NavVisible, ImGuiTextFilter::PassFilter(), ImGuiIO::PenPressure, ImGui::PopAllowKeyboardFocus(), ImGui::PushAllowKeyboardFocus(), ImGui::SameLine(), ImGui::Selectable(), ImGui::SetKeyboardFocusHere(), ImGui::SetMouseCursor(), ImVector< T >::Size, ImGui::SliderFloat3(), ImGui::Text(), ImGui::TextWrapped(), ImGui::TreeNode(), ImGui::TreePop(), ImGuiIO::WantCaptureKeyboard, ImGuiIO::WantCaptureMouse, ImGuiIO::WantSetMousePos, ImGuiIO::WantTextInput, ImVec2::x, and ImVec2::y.

Referenced by ImGui::ShowDemoWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowDemoWindowPopups()

static void ShowDemoWindowPopups ( )
static
3094{
3095 if (!ImGui::CollapsingHeader("Popups & Modal windows"))
3096 return;
3097
3098 // The properties of popups windows are:
3099 // - They block normal mouse hovering detection outside them. (*)
3100 // - Unless modal, they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
3101 // - Their visibility state (~bool) is held internally by Dear ImGui instead of being held by the programmer as
3102 // we are used to with regular Begin() calls. User can manipulate the visibility state by calling OpenPopup().
3103 // (*) One can use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) to bypass it and detect hovering even
3104 // when normally blocked by a popup.
3105 // Those three properties are connected. The library needs to hold their visibility state BECAUSE it can close
3106 // popups at any time.
3107
3108 // Typical use for regular windows:
3109 // bool my_tool_is_active = false; if (ImGui::Button("Open")) my_tool_is_active = true; [...] if (my_tool_is_active) Begin("My Tool", &my_tool_is_active) { [...] } End();
3110 // Typical use for popups:
3111 // if (ImGui::Button("Open")) ImGui::OpenPopup("MyPopup"); if (ImGui::BeginPopup("MyPopup") { [...] EndPopup(); }
3112
3113 // With popups we have to go through a library call (here OpenPopup) to manipulate the visibility state.
3114 // This may be a bit confusing at first but it should quickly make sense. Follow on the examples below.
3115
3116 if (ImGui::TreeNode("Popups"))
3117 {
3119 "When a popup is active, it inhibits interacting with windows that are behind the popup. "
3120 "Clicking outside the popup closes it.");
3121
3122 static int selected_fish = -1;
3123 const char* names[] = { "Bream", "Haddock", "Mackerel", "Pollock", "Tilefish" };
3124 static bool toggles[] = { true, false, false, false, false };
3125
3126 // Simple selection popup (if you want to show the current selection inside the Button itself,
3127 // you may want to build a string using the "###" operator to preserve a constant ID with a variable label)
3128 if (ImGui::Button("Select.."))
3129 ImGui::OpenPopup("my_select_popup");
3131 ImGui::TextUnformatted(selected_fish == -1 ? "<None>" : names[selected_fish]);
3132 if (ImGui::BeginPopup("my_select_popup"))
3133 {
3134 ImGui::Text("Aquarium");
3136 for (int i = 0; i < IM_ARRAYSIZE(names); i++)
3137 if (ImGui::Selectable(names[i]))
3138 selected_fish = i;
3140 }
3141
3142 // Showing a menu with toggles
3143 if (ImGui::Button("Toggle.."))
3144 ImGui::OpenPopup("my_toggle_popup");
3145 if (ImGui::BeginPopup("my_toggle_popup"))
3146 {
3147 for (int i = 0; i < IM_ARRAYSIZE(names); i++)
3148 ImGui::MenuItem(names[i], "", &toggles[i]);
3149 if (ImGui::BeginMenu("Sub-menu"))
3150 {
3151 ImGui::MenuItem("Click me");
3153 }
3154
3156 ImGui::Text("Tooltip here");
3158 ImGui::SetTooltip("I am a tooltip over a popup");
3159
3160 if (ImGui::Button("Stacked Popup"))
3161 ImGui::OpenPopup("another popup");
3162 if (ImGui::BeginPopup("another popup"))
3163 {
3164 for (int i = 0; i < IM_ARRAYSIZE(names); i++)
3165 ImGui::MenuItem(names[i], "", &toggles[i]);
3166 if (ImGui::BeginMenu("Sub-menu"))
3167 {
3168 ImGui::MenuItem("Click me");
3169 if (ImGui::Button("Stacked Popup"))
3170 ImGui::OpenPopup("another popup");
3171 if (ImGui::BeginPopup("another popup"))
3172 {
3173 ImGui::Text("I am the last one here.");
3175 }
3177 }
3179 }
3181 }
3182
3183 // Call the more complete ShowExampleMenuFile which we use in various places of this demo
3184 if (ImGui::Button("File Menu.."))
3185 ImGui::OpenPopup("my_file_popup");
3186 if (ImGui::BeginPopup("my_file_popup"))
3187 {
3190 }
3191
3193 }
3194
3195 if (ImGui::TreeNode("Context menus"))
3196 {
3197 HelpMarker("\"Context\" functions are simple helpers to associate a Popup to a given Item or Window identifier.");
3198
3199 // BeginPopupContextItem() is a helper to provide common/simple popup behavior of essentially doing:
3200 // if (id == 0)
3201 // id = GetItemID(); // Use last item id
3202 // if (IsItemHovered() && IsMouseReleased(ImGuiMouseButton_Right))
3203 // OpenPopup(id);
3204 // return BeginPopup(id);
3205 // For advanced advanced uses you may want to replicate and customize this code.
3206 // See more details in BeginPopupContextItem().
3207
3208 // Example 1
3209 // When used after an item that has an ID (e.g. Button), we can skip providing an ID to BeginPopupContextItem(),
3210 // and BeginPopupContextItem() will use the last item ID as the popup ID.
3211 {
3212 const char* names[5] = { "Label1", "Label2", "Label3", "Label4", "Label5" };
3213 for (int n = 0; n < 5; n++)
3214 {
3215 ImGui::Selectable(names[n]);
3216 if (ImGui::BeginPopupContextItem()) // <-- use last item id as popup id
3217 {
3218 ImGui::Text("This a popup for \"%s\"!", names[n]);
3219 if (ImGui::Button("Close"))
3222 }
3224 ImGui::SetTooltip("Right-click to open popup");
3225 }
3226 }
3227
3228 // Example 2
3229 // Popup on a Text() element which doesn't have an identifier: we need to provide an identifier to BeginPopupContextItem().
3230 // Using an explicit identifier is also convenient if you want to activate the popups from different locations.
3231 {
3232 HelpMarker("Text() elements don't have stable identifiers so we need to provide one.");
3233 static float value = 0.5f;
3234 ImGui::Text("Value = %.3f <-- (1) right-click this value", value);
3235 if (ImGui::BeginPopupContextItem("my popup"))
3236 {
3237 if (ImGui::Selectable("Set to zero")) value = 0.0f;
3238 if (ImGui::Selectable("Set to PI")) value = 3.1415f;
3239 ImGui::SetNextItemWidth(-FLT_MIN);
3240 ImGui::DragFloat("##Value", &value, 0.1f, 0.0f, 0.0f);
3242 }
3243
3244 // We can also use OpenPopupOnItemClick() to toggle the visibility of a given popup.
3245 // Here we make it that right-clicking this other text element opens the same popup as above.
3246 // The popup itself will be submitted by the code above.
3247 ImGui::Text("(2) Or right-click this text");
3249
3250 // Back to square one: manually open the same popup.
3251 if (ImGui::Button("(3) Or click this button"))
3252 ImGui::OpenPopup("my popup");
3253 }
3254
3255 // Example 3
3256 // When using BeginPopupContextItem() with an implicit identifier (NULL == use last item ID),
3257 // we need to make sure your item identifier is stable.
3258 // In this example we showcase altering the item label while preserving its identifier, using the ### operator (see FAQ).
3259 {
3260 HelpMarker("Showcase using a popup ID linked to item ID, with the item having a changing label + stable ID using the ### operator.");
3261 static char name[32] = "Label1";
3262 char buf[64];
3263 sprintf(buf, "Button: %s###Button", name); // ### operator override ID ignoring the preceding label
3264 ImGui::Button(buf);
3266 {
3267 ImGui::Text("Edit name:");
3268 ImGui::InputText("##edit", name, IM_ARRAYSIZE(name));
3269 if (ImGui::Button("Close"))
3272 }
3273 ImGui::SameLine(); ImGui::Text("(<-- right-click here)");
3274 }
3275
3277 }
3278
3279 if (ImGui::TreeNode("Modals"))
3280 {
3281 ImGui::TextWrapped("Modal windows are like popups but the user cannot close them by clicking outside.");
3282
3283 if (ImGui::Button("Delete.."))
3284 ImGui::OpenPopup("Delete?");
3285
3286 // Always center this window when appearing
3289
3291 {
3292 ImGui::Text("All those beautiful files will be deleted.\nThis operation cannot be undone!\n\n");
3294
3295 //static int unused_i = 0;
3296 //ImGui::Combo("Combo", &unused_i, "Delete\0Delete harder\0");
3297
3298 static bool dont_ask_me_next_time = false;
3300 ImGui::Checkbox("Don't ask me next time", &dont_ask_me_next_time);
3302
3303 if (ImGui::Button("OK", ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); }
3306 if (ImGui::Button("Cancel", ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); }
3308 }
3309
3310 if (ImGui::Button("Stacked modals.."))
3311 ImGui::OpenPopup("Stacked 1");
3312 if (ImGui::BeginPopupModal("Stacked 1", NULL, ImGuiWindowFlags_MenuBar))
3313 {
3314 if (ImGui::BeginMenuBar())
3315 {
3316 if (ImGui::BeginMenu("File"))
3317 {
3318 if (ImGui::MenuItem("Some menu item")) {}
3320 }
3322 }
3323 ImGui::Text("Hello from Stacked The First\nUsing style.Colors[ImGuiCol_ModalWindowDimBg] behind it.");
3324
3325 // Testing behavior of widgets stacking their own regular popups over the modal.
3326 static int item = 1;
3327 static float color[4] = { 0.4f, 0.7f, 0.0f, 0.5f };
3328 ImGui::Combo("Combo", &item, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0");
3329 ImGui::ColorEdit4("color", color);
3330
3331 if (ImGui::Button("Add another modal.."))
3332 ImGui::OpenPopup("Stacked 2");
3333
3334 // Also demonstrate passing a bool* to BeginPopupModal(), this will create a regular close button which
3335 // will close the popup. Note that the visibility state of popups is owned by imgui, so the input value
3336 // of the bool actually doesn't matter here.
3337 bool unused_open = true;
3338 if (ImGui::BeginPopupModal("Stacked 2", &unused_open))
3339 {
3340 ImGui::Text("Hello from Stacked The Second!");
3341 if (ImGui::Button("Close"))
3344 }
3345
3346 if (ImGui::Button("Close"))
3349 }
3350
3352 }
3353
3354 if (ImGui::TreeNode("Menus inside a regular window"))
3355 {
3356 ImGui::TextWrapped("Below we are testing adding menu items to a regular window. It's rather unusual but should work!");
3358
3359 // Note: As a quirk in this very specific example, we want to differentiate the parent of this menu from the
3360 // parent of the various popup menus above. To do so we are encloding the items in a PushID()/PopID() block
3361 // to make them two different menusets. If we don't, opening any popup above and hovering our menu here would
3362 // open it. This is because once a menu is active, we allow to switch to a sibling menu by just hovering on it,
3363 // which is the desired behavior for regular menus.
3364 ImGui::PushID("foo");
3365 ImGui::MenuItem("Menu item", "CTRL+M");
3366 if (ImGui::BeginMenu("Menu inside a regular window"))
3367 {
3370 }
3371 ImGui::PopID();
3374 }
3375}
@ ImGuiPopupFlags_MouseButtonRight
Definition imgui.h:1017
@ ImGuiWindowFlags_AlwaysAutoResize
Definition imgui.h:922
@ ImGuiCond_Appearing
Definition imgui.h:1618
IMGUI_API bool BeginPopup(const char *str_id, ImGuiWindowFlags flags=0)
Definition imgui.cpp:8311
IMGUI_API void SetItemDefaultFocus()
Definition imgui.cpp:6989
IMGUI_API void OpenPopupOnItemClick(const char *str_id=NULL, ImGuiPopupFlags popup_flags=1)
Definition imgui.cpp:8378
IMGUI_API bool BeginPopupContextItem(const char *str_id=NULL, ImGuiPopupFlags popup_flags=1)
Definition imgui.cpp:8406
IMGUI_API bool BeginPopupModal(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
Definition imgui.cpp:8325
IMGUI_API ImGuiViewport * GetMainViewport()
Definition imgui.cpp:10630
IMGUI_API bool ColorEdit4(const char *label, float col[4], ImGuiColorEditFlags flags=0, const char *current_label=NULL, const char *original_label=NULL)
Definition imgui_widgets.cpp:4692
IMGUI_API void OpenPopup(const char *str_id, ImGuiPopupFlags popup_flags=0)
Definition imgui.cpp:8121
IMGUI_API bool MenuItem(const char *label, const char *shortcut=NULL, bool selected=false, bool enabled=true)
Definition imgui_widgets.cpp:6872
IMGUI_API void EndPopup()
Definition imgui.cpp:8357
IMGUI_API void CloseCurrentPopup()
Definition imgui.cpp:8257
IMGUI_API void SetNextWindowPos(const ImVec2 &pos, ImGuiCond cond=0, const ImVec2 &pivot=ImVec2(0, 0))
Definition imgui.cpp:6860
ImVec2 GetCenter() const
Definition imgui.h:2771

References ImGui::BeginMenu(), ImGui::BeginMenuBar(), ImGui::BeginPopup(), ImGui::BeginPopupContextItem(), ImGui::BeginPopupModal(), ImGui::Button(), ImGui::Checkbox(), ImGui::CloseCurrentPopup(), ImGui::CollapsingHeader(), ImGui::ColorEdit4(), ImGui::Combo(), ImGui::DragFloat(), ImGui::EndMenu(), ImGui::EndMenuBar(), ImGui::EndPopup(), ImGuiViewport::GetCenter(), ImGui::GetMainViewport(), HelpMarker(), IM_ARRAYSIZE, ImGuiCond_Appearing, ImGuiPopupFlags_MouseButtonRight, ImGuiStyleVar_FramePadding, ImGuiWindowFlags_AlwaysAutoResize, ImGuiWindowFlags_MenuBar, ImGui::InputText(), ImGui::IsItemHovered(), ImGui::MenuItem(), ImGui::OpenPopup(), ImGui::OpenPopupOnItemClick(), ImGui::PopID(), ImGui::PopStyleVar(), ImGui::PushID(), ImGui::PushStyleVar(), ImGui::SameLine(), ImGui::Selectable(), ImGui::Separator(), ImGui::SetItemDefaultFocus(), ImGui::SetNextItemWidth(), ImGui::SetNextWindowPos(), ImGui::SetTooltip(), ShowExampleMenuFile(), ImGui::Text(), ImGui::TextUnformatted(), ImGui::TextWrapped(), ImGui::TreeNode(), and ImGui::TreePop().

Referenced by ImGui::ShowDemoWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowDemoWindowTables()

static void ShowDemoWindowTables ( )
static
3529{
3530 //ImGui::SetNextItemOpen(true, ImGuiCond_Once);
3531 if (!ImGui::CollapsingHeader("Tables & Columns"))
3532 return;
3533
3534 // Using those as a base value to create width/height that are factor of the size of our font
3535 const float TEXT_BASE_WIDTH = ImGui::CalcTextSize("A").x;
3536 const float TEXT_BASE_HEIGHT = ImGui::GetTextLineHeightWithSpacing();
3537
3538 ImGui::PushID("Tables");
3539
3540 int open_action = -1;
3541 if (ImGui::Button("Open all"))
3542 open_action = 1;
3544 if (ImGui::Button("Close all"))
3545 open_action = 0;
3547
3548 // Options
3549 static bool disable_indent = false;
3550 ImGui::Checkbox("Disable tree indentation", &disable_indent);
3552 HelpMarker("Disable the indenting of tree nodes so demo tables can use the full window width.");
3554 if (disable_indent)
3556
3557 // About Styling of tables
3558 // Most settings are configured on a per-table basis via the flags passed to BeginTable() and TableSetupColumns APIs.
3559 // There are however a few settings that a shared and part of the ImGuiStyle structure:
3560 // style.CellPadding // Padding within each cell
3561 // style.Colors[ImGuiCol_TableHeaderBg] // Table header background
3562 // style.Colors[ImGuiCol_TableBorderStrong] // Table outer and header borders
3563 // style.Colors[ImGuiCol_TableBorderLight] // Table inner borders
3564 // style.Colors[ImGuiCol_TableRowBg] // Table row background when ImGuiTableFlags_RowBg is enabled (even rows)
3565 // style.Colors[ImGuiCol_TableRowBgAlt] // Table row background when ImGuiTableFlags_RowBg is enabled (odds rows)
3566
3567 // Demos
3568 if (open_action != -1)
3569 ImGui::SetNextItemOpen(open_action != 0);
3570 if (ImGui::TreeNode("Basic"))
3571 {
3572 // Here we will showcase three different ways to output a table.
3573 // They are very simple variations of a same thing!
3574
3575 // [Method 1] Using TableNextRow() to create a new row, and TableSetColumnIndex() to select the column.
3576 // In many situations, this is the most flexible and easy to use pattern.
3577 HelpMarker("Using TableNextRow() + calling TableSetColumnIndex() _before_ each cell, in a loop.");
3578 if (ImGui::BeginTable("table1", 3))
3579 {
3580 for (int row = 0; row < 4; row++)
3581 {
3583 for (int column = 0; column < 3; column++)
3584 {
3586 ImGui::Text("Row %d Column %d", row, column);
3587 }
3588 }
3590 }
3591
3592 // [Method 2] Using TableNextColumn() called multiple times, instead of using a for loop + TableSetColumnIndex().
3593 // This is generally more convenient when you have code manually submitting the contents of each columns.
3594 HelpMarker("Using TableNextRow() + calling TableNextColumn() _before_ each cell, manually.");
3595 if (ImGui::BeginTable("table2", 3))
3596 {
3597 for (int row = 0; row < 4; row++)
3598 {
3601 ImGui::Text("Row %d", row);
3603 ImGui::Text("Some contents");
3605 ImGui::Text("123.456");
3606 }
3608 }
3609
3610 // [Method 3] We call TableNextColumn() _before_ each cell. We never call TableNextRow(),
3611 // as TableNextColumn() will automatically wrap around and create new roes as needed.
3612 // This is generally more convenient when your cells all contains the same type of data.
3613 HelpMarker(
3614 "Only using TableNextColumn(), which tends to be convenient for tables where every cells contains the same type of contents.\n"
3615 "This is also more similar to the old NextColumn() function of the Columns API, and provided to facilitate the Columns->Tables API transition.");
3616 if (ImGui::BeginTable("table3", 3))
3617 {
3618 for (int item = 0; item < 14; item++)
3619 {
3621 ImGui::Text("Item %d", item);
3622 }
3624 }
3625
3627 }
3628
3629 if (open_action != -1)
3630 ImGui::SetNextItemOpen(open_action != 0);
3631 if (ImGui::TreeNode("Borders, background"))
3632 {
3633 // Expose a few Borders related flags interactively
3634 enum ContentsType { CT_Text, CT_FillButton };
3636 static bool display_headers = false;
3637 static int contents_type = CT_Text;
3638
3640 ImGui::CheckboxFlags("ImGuiTableFlags_RowBg", &flags, ImGuiTableFlags_RowBg);
3641 ImGui::CheckboxFlags("ImGuiTableFlags_Borders", &flags, ImGuiTableFlags_Borders);
3642 ImGui::SameLine(); HelpMarker("ImGuiTableFlags_Borders\n = ImGuiTableFlags_BordersInnerV\n | ImGuiTableFlags_BordersOuterV\n | ImGuiTableFlags_BordersInnerV\n | ImGuiTableFlags_BordersOuterH");
3643 ImGui::Indent();
3644
3645 ImGui::CheckboxFlags("ImGuiTableFlags_BordersH", &flags, ImGuiTableFlags_BordersH);
3646 ImGui::Indent();
3647 ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterH", &flags, ImGuiTableFlags_BordersOuterH);
3648 ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerH", &flags, ImGuiTableFlags_BordersInnerH);
3650
3651 ImGui::CheckboxFlags("ImGuiTableFlags_BordersV", &flags, ImGuiTableFlags_BordersV);
3652 ImGui::Indent();
3653 ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags, ImGuiTableFlags_BordersOuterV);
3654 ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags, ImGuiTableFlags_BordersInnerV);
3656
3657 ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuter", &flags, ImGuiTableFlags_BordersOuter);
3658 ImGui::CheckboxFlags("ImGuiTableFlags_BordersInner", &flags, ImGuiTableFlags_BordersInner);
3660
3661 ImGui::AlignTextToFramePadding(); ImGui::Text("Cell contents:");
3662 ImGui::SameLine(); ImGui::RadioButton("Text", &contents_type, CT_Text);
3663 ImGui::SameLine(); ImGui::RadioButton("FillButton", &contents_type, CT_FillButton);
3664 ImGui::Checkbox("Display headers", &display_headers);
3665 ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBody", &flags, ImGuiTableFlags_NoBordersInBody); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body (borders will always appears in Headers");
3667
3668 if (ImGui::BeginTable("table1", 3, flags))
3669 {
3670 // Display headers so we can inspect their interaction with borders.
3671 // (Headers are not the main purpose of this section of the demo, so we are not elaborating on them too much. See other sections for details)
3672 if (display_headers)
3673 {
3676 ImGui::TableSetupColumn("Three");
3678 }
3679
3680 for (int row = 0; row < 5; row++)
3681 {
3683 for (int column = 0; column < 3; column++)
3684 {
3686 char buf[32];
3687 sprintf(buf, "Hello %d,%d", column, row);
3688 if (contents_type == CT_Text)
3690 else if (contents_type)
3691 ImGui::Button(buf, ImVec2(-FLT_MIN, 0.0f));
3692 }
3693 }
3695 }
3697 }
3698
3699 if (open_action != -1)
3700 ImGui::SetNextItemOpen(open_action != 0);
3701 if (ImGui::TreeNode("Resizable, stretch"))
3702 {
3703 // By default, if we don't enable ScrollX the sizing policy for each columns is "Stretch"
3704 // Each columns maintain a sizing weight, and they will occupy all available width.
3707 ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable);
3708 ImGui::CheckboxFlags("ImGuiTableFlags_BordersV", &flags, ImGuiTableFlags_BordersV);
3709 ImGui::SameLine(); HelpMarker("Using the _Resizable flag automatically enables the _BordersInnerV flag as well, this is why the resize borders are still showing when unchecking this.");
3711
3712 if (ImGui::BeginTable("table1", 3, flags))
3713 {
3714 for (int row = 0; row < 5; row++)
3715 {
3717 for (int column = 0; column < 3; column++)
3718 {
3720 ImGui::Text("Hello %d,%d", column, row);
3721 }
3722 }
3724 }
3726 }
3727
3728 if (open_action != -1)
3729 ImGui::SetNextItemOpen(open_action != 0);
3730 if (ImGui::TreeNode("Resizable, fixed"))
3731 {
3732 // Here we use ImGuiTableFlags_SizingFixedFit (even though _ScrollX is not set)
3733 // So columns will adopt the "Fixed" policy and will maintain a fixed width regardless of the whole available width (unless table is small)
3734 // If there is not enough available width to fit all columns, they will however be resized down.
3735 // FIXME-TABLE: Providing a stretch-on-init would make sense especially for tables which don't have saved settings
3736 HelpMarker(
3737 "Using _Resizable + _SizingFixedFit flags.\n"
3738 "Fixed-width columns generally makes more sense if you want to use horizontal scrolling.\n\n"
3739 "Double-click a column border to auto-fit the column to its contents.");
3742 ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags, ImGuiTableFlags_NoHostExtendX);
3744
3745 if (ImGui::BeginTable("table1", 3, flags))
3746 {
3747 for (int row = 0; row < 5; row++)
3748 {
3750 for (int column = 0; column < 3; column++)
3751 {
3753 ImGui::Text("Hello %d,%d", column, row);
3754 }
3755 }
3757 }
3759 }
3760
3761 if (open_action != -1)
3762 ImGui::SetNextItemOpen(open_action != 0);
3763 if (ImGui::TreeNode("Resizable, mixed"))
3764 {
3765 HelpMarker(
3766 "Using TableSetupColumn() to alter resizing policy on a per-column basis.\n\n"
3767 "When combining Fixed and Stretch columns, generally you only want one, maybe two trailing columns to use _WidthStretch.");
3769
3770 if (ImGui::BeginTable("table1", 3, flags))
3771 {
3776 for (int row = 0; row < 5; row++)
3777 {
3779 for (int column = 0; column < 3; column++)
3780 {
3782 ImGui::Text("%s %d,%d", (column == 2) ? "Stretch" : "Fixed", column, row);
3783 }
3784 }
3786 }
3787 if (ImGui::BeginTable("table2", 6, flags))
3788 {
3796 for (int row = 0; row < 5; row++)
3797 {
3799 for (int column = 0; column < 6; column++)
3800 {
3802 ImGui::Text("%s %d,%d", (column >= 3) ? "Stretch" : "Fixed", column, row);
3803 }
3804 }
3806 }
3808 }
3809
3810 if (open_action != -1)
3811 ImGui::SetNextItemOpen(open_action != 0);
3812 if (ImGui::TreeNode("Reorderable, hideable, with headers"))
3813 {
3814 HelpMarker(
3815 "Click and drag column headers to reorder columns.\n\n"
3816 "Right-click on a header to open a context menu.");
3819 ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable);
3820 ImGui::CheckboxFlags("ImGuiTableFlags_Reorderable", &flags, ImGuiTableFlags_Reorderable);
3821 ImGui::CheckboxFlags("ImGuiTableFlags_Hideable", &flags, ImGuiTableFlags_Hideable);
3822 ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBody", &flags, ImGuiTableFlags_NoBordersInBody);
3823 ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", &flags, ImGuiTableFlags_NoBordersInBodyUntilResize); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers)");
3825
3826 if (ImGui::BeginTable("table1", 3, flags))
3827 {
3828 // Submit columns name with TableSetupColumn() and call TableHeadersRow() to create a row with a header in each column.
3829 // (Later we will show how TableSetupColumn() has other uses, optional flags, sizing weight etc.)
3832 ImGui::TableSetupColumn("Three");
3834 for (int row = 0; row < 6; row++)
3835 {
3837 for (int column = 0; column < 3; column++)
3838 {
3840 ImGui::Text("Hello %d,%d", column, row);
3841 }
3842 }
3844 }
3845
3846 // Use outer_size.x == 0.0f instead of default to make the table as tight as possible (only valid when no scrolling and no stretch column)
3847 if (ImGui::BeginTable("table2", 3, flags | ImGuiTableFlags_SizingFixedFit, ImVec2(0.0f, 0.0f)))
3848 {
3851 ImGui::TableSetupColumn("Three");
3853 for (int row = 0; row < 6; row++)
3854 {
3856 for (int column = 0; column < 3; column++)
3857 {
3859 ImGui::Text("Fixed %d,%d", column, row);
3860 }
3861 }
3863 }
3865 }
3866
3867 if (open_action != -1)
3868 ImGui::SetNextItemOpen(open_action != 0);
3869 if (ImGui::TreeNode("Padding"))
3870 {
3871 // First example: showcase use of padding flags and effect of BorderOuterV/BorderInnerV on X padding.
3872 // We don't expose BorderOuterH/BorderInnerH here because they have no effect on X padding.
3873 HelpMarker(
3874 "We often want outer padding activated when any using features which makes the edges of a column visible:\n"
3875 "e.g.:\n"
3876 "- BorderOuterV\n"
3877 "- any form of row selection\n"
3878 "Because of this, activating BorderOuterV sets the default to PadOuterX. Using PadOuterX or NoPadOuterX you can override the default.\n\n"
3879 "Actual padding values are using style.CellPadding.\n\n"
3880 "In this demo we don't show horizontal borders to emphasis how they don't affect default horizontal padding.");
3881
3884 ImGui::CheckboxFlags("ImGuiTableFlags_PadOuterX", &flags1, ImGuiTableFlags_PadOuterX);
3885 ImGui::SameLine(); HelpMarker("Enable outer-most padding (default if ImGuiTableFlags_BordersOuterV is set)");
3886 ImGui::CheckboxFlags("ImGuiTableFlags_NoPadOuterX", &flags1, ImGuiTableFlags_NoPadOuterX);
3887 ImGui::SameLine(); HelpMarker("Disable outer-most padding (default if ImGuiTableFlags_BordersOuterV is not set)");
3888 ImGui::CheckboxFlags("ImGuiTableFlags_NoPadInnerX", &flags1, ImGuiTableFlags_NoPadInnerX);
3889 ImGui::SameLine(); HelpMarker("Disable inner padding between columns (double inner padding if BordersOuterV is on, single inner padding if BordersOuterV is off)");
3890 ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags1, ImGuiTableFlags_BordersOuterV);
3891 ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags1, ImGuiTableFlags_BordersInnerV);
3892 static bool show_headers = false;
3893 ImGui::Checkbox("show_headers", &show_headers);
3895
3896 if (ImGui::BeginTable("table_padding", 3, flags1))
3897 {
3898 if (show_headers)
3899 {
3902 ImGui::TableSetupColumn("Three");
3904 }
3905
3906 for (int row = 0; row < 5; row++)
3907 {
3909 for (int column = 0; column < 3; column++)
3910 {
3912 if (row == 0)
3913 {
3914 ImGui::Text("Avail %.2f", ImGui::GetContentRegionAvail().x);
3915 }
3916 else
3917 {
3918 char buf[32];
3919 sprintf(buf, "Hello %d,%d", column, row);
3920 ImGui::Button(buf, ImVec2(-FLT_MIN, 0.0f));
3921 }
3922 //if (ImGui::TableGetColumnFlags() & ImGuiTableColumnFlags_IsHovered)
3923 // ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, IM_COL32(0, 100, 0, 255));
3924 }
3925 }
3927 }
3928
3929 // Second example: set style.CellPadding to (0.0) or a custom value.
3930 // FIXME-TABLE: Vertical border effectively not displayed the same way as horizontal one...
3931 HelpMarker("Setting style.CellPadding to (0,0) or a custom value.");
3933 static ImVec2 cell_padding(0.0f, 0.0f);
3934 static bool show_widget_frame_bg = true;
3935
3937 ImGui::CheckboxFlags("ImGuiTableFlags_Borders", &flags2, ImGuiTableFlags_Borders);
3938 ImGui::CheckboxFlags("ImGuiTableFlags_BordersH", &flags2, ImGuiTableFlags_BordersH);
3939 ImGui::CheckboxFlags("ImGuiTableFlags_BordersV", &flags2, ImGuiTableFlags_BordersV);
3940 ImGui::CheckboxFlags("ImGuiTableFlags_BordersInner", &flags2, ImGuiTableFlags_BordersInner);
3941 ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuter", &flags2, ImGuiTableFlags_BordersOuter);
3942 ImGui::CheckboxFlags("ImGuiTableFlags_RowBg", &flags2, ImGuiTableFlags_RowBg);
3943 ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags2, ImGuiTableFlags_Resizable);
3944 ImGui::Checkbox("show_widget_frame_bg", &show_widget_frame_bg);
3945 ImGui::SliderFloat2("CellPadding", &cell_padding.x, 0.0f, 10.0f, "%.0f");
3947
3949 if (ImGui::BeginTable("table_padding_2", 3, flags2))
3950 {
3951 static char text_bufs[3 * 5][16]; // Mini text storage for 3x5 cells
3952 static bool init = true;
3953 if (!show_widget_frame_bg)
3955 for (int cell = 0; cell < 3 * 5; cell++)
3956 {
3958 if (init)
3959 strcpy(text_bufs[cell], "edit me");
3960 ImGui::SetNextItemWidth(-FLT_MIN);
3961 ImGui::PushID(cell);
3962 ImGui::InputText("##cell", text_bufs[cell], IM_ARRAYSIZE(text_bufs[cell]));
3963 ImGui::PopID();
3964 }
3965 if (!show_widget_frame_bg)
3967 init = false;
3969 }
3971
3973 }
3974
3975 if (open_action != -1)
3976 ImGui::SetNextItemOpen(open_action != 0);
3977 if (ImGui::TreeNode("Sizing policies"))
3978 {
3981 ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags1, ImGuiTableFlags_Resizable);
3982 ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags1, ImGuiTableFlags_NoHostExtendX);
3984
3986 for (int table_n = 0; table_n < 4; table_n++)
3987 {
3988 ImGui::PushID(table_n);
3989 ImGui::SetNextItemWidth(TEXT_BASE_WIDTH * 30);
3990 EditTableSizingFlags(&sizing_policy_flags[table_n]);
3991
3992 // To make it easier to understand the different sizing policy,
3993 // For each policy: we display one table where the columns have equal contents width, and one where the columns have different contents width.
3994 if (ImGui::BeginTable("table1", 3, sizing_policy_flags[table_n] | flags1))
3995 {
3996 for (int row = 0; row < 3; row++)
3997 {
3999 ImGui::TableNextColumn(); ImGui::Text("Oh dear");
4000 ImGui::TableNextColumn(); ImGui::Text("Oh dear");
4001 ImGui::TableNextColumn(); ImGui::Text("Oh dear");
4002 }
4004 }
4005 if (ImGui::BeginTable("table2", 3, sizing_policy_flags[table_n] | flags1))
4006 {
4007 for (int row = 0; row < 3; row++)
4008 {
4011 ImGui::TableNextColumn(); ImGui::Text("BBBBBBBB");
4012 ImGui::TableNextColumn(); ImGui::Text("CCCCCCCCCCCC");
4013 }
4015 }
4016 ImGui::PopID();
4017 }
4018
4020 ImGui::TextUnformatted("Advanced");
4022 HelpMarker("This section allows you to interact and see the effect of various sizing policies depending on whether Scroll is enabled and the contents of your columns.");
4023
4024 enum ContentsType { CT_ShowWidth, CT_ShortText, CT_LongText, CT_Button, CT_FillButton, CT_InputText };
4026 static int contents_type = CT_ShowWidth;
4027 static int column_count = 3;
4028
4030 ImGui::PushID("Advanced");
4031 ImGui::PushItemWidth(TEXT_BASE_WIDTH * 30);
4032 EditTableSizingFlags(&flags);
4033 ImGui::Combo("Contents", &contents_type, "Show width\0Short Text\0Long Text\0Button\0Fill Button\0InputText\0");
4034 if (contents_type == CT_FillButton)
4035 {
4037 HelpMarker("Be mindful that using right-alignment (e.g. size.x = -FLT_MIN) creates a feedback loop where contents width can feed into auto-column width can feed into contents width.");
4038 }
4039 ImGui::DragInt("Columns", &column_count, 0.1f, 1, 64, "%d", ImGuiSliderFlags_AlwaysClamp);
4040 ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable);
4041 ImGui::CheckboxFlags("ImGuiTableFlags_PreciseWidths", &flags, ImGuiTableFlags_PreciseWidths);
4042 ImGui::SameLine(); HelpMarker("Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth.");
4043 ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags, ImGuiTableFlags_ScrollX);
4044 ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY);
4045 ImGui::CheckboxFlags("ImGuiTableFlags_NoClip", &flags, ImGuiTableFlags_NoClip);
4047 ImGui::PopID();
4049
4050 if (ImGui::BeginTable("table2", column_count, flags, ImVec2(0.0f, TEXT_BASE_HEIGHT * 7)))
4051 {
4052 for (int cell = 0; cell < 10 * column_count; cell++)
4053 {
4055 int column = ImGui::TableGetColumnIndex();
4057
4058 ImGui::PushID(cell);
4059 char label[32];
4060 static char text_buf[32] = "";
4061 sprintf(label, "Hello %d,%d", column, row);
4062 switch (contents_type)
4063 {
4064 case CT_ShortText: ImGui::TextUnformatted(label); break;
4065 case CT_LongText: ImGui::Text("Some %s text %d,%d\nOver two lines..", column == 0 ? "long" : "longeeer", column, row); break;
4066 case CT_ShowWidth: ImGui::Text("W: %.1f", ImGui::GetContentRegionAvail().x); break;
4067 case CT_Button: ImGui::Button(label); break;
4068 case CT_FillButton: ImGui::Button(label, ImVec2(-FLT_MIN, 0.0f)); break;
4069 case CT_InputText: ImGui::SetNextItemWidth(-FLT_MIN); ImGui::InputText("##", text_buf, IM_ARRAYSIZE(text_buf)); break;
4070 }
4071 ImGui::PopID();
4072 }
4074 }
4076 }
4077
4078 if (open_action != -1)
4079 ImGui::SetNextItemOpen(open_action != 0);
4080 if (ImGui::TreeNode("Vertical scrolling, with clipping"))
4081 {
4082 HelpMarker("Here we activate ScrollY, which will create a child window container to allow hosting scrollable contents.\n\nWe also demonstrate using ImGuiListClipper to virtualize the submission of many items.");
4084
4086 ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY);
4088
4089 // When using ScrollX or ScrollY we need to specify a size for our table container!
4090 // Otherwise by default the table will fit all available space, like a BeginChild() call.
4091 ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 8);
4092 if (ImGui::BeginTable("table_scrolly", 3, flags, outer_size))
4093 {
4094 ImGui::TableSetupScrollFreeze(0, 1); // Make top row always visible
4099
4100 // Demonstrate using clipper for large vertical lists
4101 ImGuiListClipper clipper;
4102 clipper.Begin(1000);
4103 while (clipper.Step())
4104 {
4105 for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; row++)
4106 {
4108 for (int column = 0; column < 3; column++)
4109 {
4111 ImGui::Text("Hello %d,%d", column, row);
4112 }
4113 }
4114 }
4116 }
4118 }
4119
4120 if (open_action != -1)
4121 ImGui::SetNextItemOpen(open_action != 0);
4122 if (ImGui::TreeNode("Horizontal scrolling"))
4123 {
4124 HelpMarker(
4125 "When ScrollX is enabled, the default sizing policy becomes ImGuiTableFlags_SizingFixedFit, "
4126 "as automatically stretching columns doesn't make much sense with horizontal scrolling.\n\n"
4127 "Also note that as of the current version, you will almost always want to enable ScrollY along with ScrollX,"
4128 "because the container window won't automatically extend vertically to fix contents (this may be improved in future versions).");
4130 static int freeze_cols = 1;
4131 static int freeze_rows = 1;
4132
4134 ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable);
4135 ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags, ImGuiTableFlags_ScrollX);
4136 ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY);
4138 ImGui::DragInt("freeze_cols", &freeze_cols, 0.2f, 0, 9, NULL, ImGuiSliderFlags_NoInput);
4140 ImGui::DragInt("freeze_rows", &freeze_rows, 0.2f, 0, 9, NULL, ImGuiSliderFlags_NoInput);
4142
4143 // When using ScrollX or ScrollY we need to specify a size for our table container!
4144 // Otherwise by default the table will fit all available space, like a BeginChild() call.
4145 ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 8);
4146 if (ImGui::BeginTable("table_scrollx", 7, flags, outer_size))
4147 {
4148 ImGui::TableSetupScrollFreeze(freeze_cols, freeze_rows);
4149 ImGui::TableSetupColumn("Line #", ImGuiTableColumnFlags_NoHide); // Make the first column not hideable to match our use of TableSetupScrollFreeze()
4152 ImGui::TableSetupColumn("Three");
4157 for (int row = 0; row < 20; row++)
4158 {
4160 for (int column = 0; column < 7; column++)
4161 {
4162 // Both TableNextColumn() and TableSetColumnIndex() return true when a column is visible or performing width measurement.
4163 // Because here we know that:
4164 // - A) all our columns are contributing the same to row height
4165 // - B) column 0 is always visible,
4166 // We only always submit this one column and can skip others.
4167 // More advanced per-column clipping behaviors may benefit from polling the status flags via TableGetColumnFlags().
4168 if (!ImGui::TableSetColumnIndex(column) && column > 0)
4169 continue;
4170 if (column == 0)
4171 ImGui::Text("Line %d", row);
4172 else
4173 ImGui::Text("Hello world %d,%d", column, row);
4174 }
4175 }
4177 }
4178
4180 ImGui::TextUnformatted("Stretch + ScrollX");
4182 HelpMarker(
4183 "Showcase using Stretch columns + ScrollX together: "
4184 "this is rather unusual and only makes sense when specifying an 'inner_width' for the table!\n"
4185 "Without an explicit value, inner_width is == outer_size.x and therefore using Stretch columns + ScrollX together doesn't make sense.");
4187 static float inner_width = 1000.0f;
4189 ImGui::PushID("flags3");
4190 ImGui::PushItemWidth(TEXT_BASE_WIDTH * 30);
4191 ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags2, ImGuiTableFlags_ScrollX);
4192 ImGui::DragFloat("inner_width", &inner_width, 1.0f, 0.0f, FLT_MAX, "%.1f");
4194 ImGui::PopID();
4196 if (ImGui::BeginTable("table2", 7, flags2, outer_size, inner_width))
4197 {
4198 for (int cell = 0; cell < 20 * 7; cell++)
4199 {
4202 }
4204 }
4206 }
4207
4208 if (open_action != -1)
4209 ImGui::SetNextItemOpen(open_action != 0);
4210 if (ImGui::TreeNode("Columns flags"))
4211 {
4212 // Create a first table just to show all the options/flags we want to make visible in our example!
4213 const int column_count = 3;
4214 const char* column_names[column_count] = { "One", "Two", "Three" };
4216 static ImGuiTableColumnFlags column_flags_out[column_count] = { 0, 0, 0 }; // Output from TableGetColumnFlags()
4217
4218 if (ImGui::BeginTable("table_columns_flags_checkboxes", column_count, ImGuiTableFlags_None))
4219 {
4221 for (int column = 0; column < column_count; column++)
4222 {
4224 ImGui::PushID(column);
4225 ImGui::AlignTextToFramePadding(); // FIXME-TABLE: Workaround for wrong text baseline propagation
4226 ImGui::Text("'%s'", column_names[column]);
4228 ImGui::Text("Input flags:");
4229 EditTableColumnsFlags(&column_flags[column]);
4231 ImGui::Text("Output flags:");
4232 ShowTableColumnsStatusFlags(column_flags_out[column]);
4233 ImGui::PopID();
4234 }
4237 }
4238
4239 // Create the real table we care about for the example!
4240 // We use a scrolling table to be able to showcase the difference between the _IsEnabled and _IsVisible flags above, otherwise in
4241 // a non-scrolling table columns are always visible (unless using ImGuiTableFlags_NoKeepColumnsVisible + resizing the parent window down)
4242 const ImGuiTableFlags flags
4246 ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 9);
4247 if (ImGui::BeginTable("table_columns_flags", column_count, flags, outer_size))
4248 {
4249 for (int column = 0; column < column_count; column++)
4250 ImGui::TableSetupColumn(column_names[column], column_flags[column]);
4252 for (int column = 0; column < column_count; column++)
4253 column_flags_out[column] = ImGui::TableGetColumnFlags(column);
4254 float indent_step = (float)((int)TEXT_BASE_WIDTH / 2);
4255 for (int row = 0; row < 8; row++)
4256 {
4257 ImGui::Indent(indent_step); // Add some indentation to demonstrate usage of per-column IndentEnable/IndentDisable flags.
4259 for (int column = 0; column < column_count; column++)
4260 {
4262 ImGui::Text("%s %s", (column == 0) ? "Indented" : "Hello", ImGui::TableGetColumnName(column));
4263 }
4264 }
4265 ImGui::Unindent(indent_step * 8.0f);
4266
4268 }
4270 }
4271
4272 if (open_action != -1)
4273 ImGui::SetNextItemOpen(open_action != 0);
4274 if (ImGui::TreeNode("Columns widths"))
4275 {
4276 HelpMarker("Using TableSetupColumn() to setup default width.");
4277
4280 ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags1, ImGuiTableFlags_Resizable);
4281 ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", &flags1, ImGuiTableFlags_NoBordersInBodyUntilResize);
4283 if (ImGui::BeginTable("table1", 3, flags1))
4284 {
4285 // We could also set ImGuiTableFlags_SizingFixedFit on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed.
4286 ImGui::TableSetupColumn("one", ImGuiTableColumnFlags_WidthFixed, 100.0f); // Default to 100.0f
4287 ImGui::TableSetupColumn("two", ImGuiTableColumnFlags_WidthFixed, 200.0f); // Default to 200.0f
4288 ImGui::TableSetupColumn("three", ImGuiTableColumnFlags_WidthFixed); // Default to auto
4290 for (int row = 0; row < 4; row++)
4291 {
4293 for (int column = 0; column < 3; column++)
4294 {
4296 if (row == 0)
4297 ImGui::Text("(w: %5.1f)", ImGui::GetContentRegionAvail().x);
4298 else
4299 ImGui::Text("Hello %d,%d", column, row);
4300 }
4301 }
4303 }
4304
4305 HelpMarker("Using TableSetupColumn() to setup explicit width.\n\nUnless _NoKeepColumnsVisible is set, fixed columns with set width may still be shrunk down if there's not enough space in the host.");
4306
4307 static ImGuiTableFlags flags2 = ImGuiTableFlags_None;
4309 ImGui::CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", &flags2, ImGuiTableFlags_NoKeepColumnsVisible);
4310 ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags2, ImGuiTableFlags_BordersInnerV);
4311 ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags2, ImGuiTableFlags_BordersOuterV);
4313 if (ImGui::BeginTable("table2", 4, flags2))
4314 {
4315 // We could also set ImGuiTableFlags_SizingFixedFit on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed.
4317 ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 15.0f);
4318 ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 30.0f);
4319 ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 15.0f);
4320 for (int row = 0; row < 5; row++)
4321 {
4323 for (int column = 0; column < 4; column++)
4324 {
4326 if (row == 0)
4327 ImGui::Text("(w: %5.1f)", ImGui::GetContentRegionAvail().x);
4328 else
4329 ImGui::Text("Hello %d,%d", column, row);
4330 }
4331 }
4333 }
4335 }
4336
4337 if (open_action != -1)
4338 ImGui::SetNextItemOpen(open_action != 0);
4339 if (ImGui::TreeNode("Nested tables"))
4340 {
4341 HelpMarker("This demonstrate embedding a table into another table cell.");
4342
4344 {
4348
4350 ImGui::Text("A0 Row 0");
4351 {
4352 float rows_height = TEXT_BASE_HEIGHT * 2;
4354 {
4358
4361 ImGui::Text("B0 Row 0");
4363 ImGui::Text("B1 Row 0");
4366 ImGui::Text("B0 Row 1");
4368 ImGui::Text("B1 Row 1");
4369
4371 }
4372 }
4373 ImGui::TableNextColumn(); ImGui::Text("A1 Row 0");
4374 ImGui::TableNextColumn(); ImGui::Text("A0 Row 1");
4375 ImGui::TableNextColumn(); ImGui::Text("A1 Row 1");
4377 }
4379 }
4380
4381 if (open_action != -1)
4382 ImGui::SetNextItemOpen(open_action != 0);
4383 if (ImGui::TreeNode("Row height"))
4384 {
4385 HelpMarker("You can pass a 'min_row_height' to TableNextRow().\n\nRows are padded with 'style.CellPadding.y' on top and bottom, so effectively the minimum row height will always be >= 'style.CellPadding.y * 2.0f'.\n\nWe cannot honor a _maximum_ row height as that would requires a unique clipping rectangle per row.");
4387 {
4388 for (int row = 0; row < 10; row++)
4389 {
4390 float min_row_height = (float)(int)(TEXT_BASE_HEIGHT * 0.30f * row);
4393 ImGui::Text("min_row_height = %.2f", min_row_height);
4394 }
4396 }
4398 }
4399
4400 if (open_action != -1)
4401 ImGui::SetNextItemOpen(open_action != 0);
4402 if (ImGui::TreeNode("Outer size"))
4403 {
4404 // Showcasing use of ImGuiTableFlags_NoHostExtendX and ImGuiTableFlags_NoHostExtendY
4405 // Important to that note how the two flags have slightly different behaviors!
4406 ImGui::Text("Using NoHostExtendX and NoHostExtendY:");
4409 ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags, ImGuiTableFlags_NoHostExtendX);
4410 ImGui::SameLine(); HelpMarker("Make outer width auto-fit to columns, overriding outer_size.x value.\n\nOnly available when ScrollX/ScrollY are disabled and Stretch columns are not used.");
4411 ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY);
4412 ImGui::SameLine(); HelpMarker("Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit).\n\nOnly available when ScrollX/ScrollY are disabled. Data below the limit will be clipped and not visible.");
4414
4415 ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 5.5f);
4416 if (ImGui::BeginTable("table1", 3, flags, outer_size))
4417 {
4418 for (int row = 0; row < 10; row++)
4419 {
4421 for (int column = 0; column < 3; column++)
4422 {
4424 ImGui::Text("Cell %d,%d", column, row);
4425 }
4426 }
4428 }
4430 ImGui::Text("Hello!");
4431
4433
4434 ImGui::Text("Using explicit size:");
4435 if (ImGui::BeginTable("table2", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f)))
4436 {
4437 for (int row = 0; row < 5; row++)
4438 {
4440 for (int column = 0; column < 3; column++)
4441 {
4443 ImGui::Text("Cell %d,%d", column, row);
4444 }
4445 }
4447 }
4449 if (ImGui::BeginTable("table3", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f)))
4450 {
4451 for (int row = 0; row < 3; row++)
4452 {
4453 ImGui::TableNextRow(0, TEXT_BASE_HEIGHT * 1.5f);
4454 for (int column = 0; column < 3; column++)
4455 {
4457 ImGui::Text("Cell %d,%d", column, row);
4458 }
4459 }
4461 }
4462
4464 }
4465
4466 if (open_action != -1)
4467 ImGui::SetNextItemOpen(open_action != 0);
4468 if (ImGui::TreeNode("Background color"))
4469 {
4471 static int row_bg_type = 1;
4472 static int row_bg_target = 1;
4473 static int cell_bg_type = 1;
4474
4476 ImGui::CheckboxFlags("ImGuiTableFlags_Borders", &flags, ImGuiTableFlags_Borders);
4477 ImGui::CheckboxFlags("ImGuiTableFlags_RowBg", &flags, ImGuiTableFlags_RowBg);
4478 ImGui::SameLine(); HelpMarker("ImGuiTableFlags_RowBg automatically sets RowBg0 to alternative colors pulled from the Style.");
4479 ImGui::Combo("row bg type", (int*)&row_bg_type, "None\0Red\0Gradient\0");
4480 ImGui::Combo("row bg target", (int*)&row_bg_target, "RowBg0\0RowBg1\0"); ImGui::SameLine(); HelpMarker("Target RowBg0 to override the alternating odd/even colors,\nTarget RowBg1 to blend with them.");
4481 ImGui::Combo("cell bg type", (int*)&cell_bg_type, "None\0Blue\0"); ImGui::SameLine(); HelpMarker("We are colorizing cells to B1->C2 here.");
4482 IM_ASSERT(row_bg_type >= 0 && row_bg_type <= 2);
4483 IM_ASSERT(row_bg_target >= 0 && row_bg_target <= 1);
4484 IM_ASSERT(cell_bg_type >= 0 && cell_bg_type <= 1);
4486
4487 if (ImGui::BeginTable("table1", 5, flags))
4488 {
4489 for (int row = 0; row < 6; row++)
4490 {
4492
4493 // Demonstrate setting a row background color with 'ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBgX, ...)'
4494 // We use a transparent color so we can see the one behind in case our target is RowBg1 and RowBg0 was already targeted by the ImGuiTableFlags_RowBg flag.
4495 if (row_bg_type != 0)
4496 {
4497 ImU32 row_bg_color = ImGui::GetColorU32(row_bg_type == 1 ? ImVec4(0.7f, 0.3f, 0.3f, 0.65f) : ImVec4(0.2f + row * 0.1f, 0.2f, 0.2f, 0.65f)); // Flat or Gradient?
4498 ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0 + row_bg_target, row_bg_color);
4499 }
4500
4501 // Fill cells
4502 for (int column = 0; column < 5; column++)
4503 {
4505 ImGui::Text("%c%c", 'A' + row, '0' + column);
4506
4507 // Change background of Cells B1->C2
4508 // Demonstrate setting a cell background color with 'ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ...)'
4509 // (the CellBg color will be blended over the RowBg and ColumnBg colors)
4510 // We can also pass a column number as a third parameter to TableSetBgColor() and do this outside the column loop.
4511 if (row >= 1 && row <= 2 && column >= 1 && column <= 2 && cell_bg_type == 1)
4512 {
4513 ImU32 cell_bg_color = ImGui::GetColorU32(ImVec4(0.3f, 0.3f, 0.7f, 0.65f));
4515 }
4516 }
4517 }
4519 }
4521 }
4522
4523 if (open_action != -1)
4524 ImGui::SetNextItemOpen(open_action != 0);
4525 if (ImGui::TreeNode("Tree view"))
4526 {
4528
4529 if (ImGui::BeginTable("3ways", 3, flags))
4530 {
4531 // The first column will use the default _WidthStretch when ScrollX is Off and _WidthFixed when ScrollX is On
4533 ImGui::TableSetupColumn("Size", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 12.0f);
4534 ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 18.0f);
4536
4537 // Simple storage to output a dummy file-system.
4538 struct MyTreeNode
4539 {
4540 const char* Name;
4541 const char* Type;
4542 int Size;
4543 int ChildIdx;
4544 int ChildCount;
4545 static void DisplayNode(const MyTreeNode* node, const MyTreeNode* all_nodes)
4546 {
4549 const bool is_folder = (node->ChildCount > 0);
4550 if (is_folder)
4551 {
4552 bool open = ImGui::TreeNodeEx(node->Name, ImGuiTreeNodeFlags_SpanFullWidth);
4554 ImGui::TextDisabled("--");
4556 ImGui::TextUnformatted(node->Type);
4557 if (open)
4558 {
4559 for (int child_n = 0; child_n < node->ChildCount; child_n++)
4560 DisplayNode(&all_nodes[node->ChildIdx + child_n], all_nodes);
4562 }
4563 }
4564 else
4565 {
4568 ImGui::Text("%d", node->Size);
4570 ImGui::TextUnformatted(node->Type);
4571 }
4572 }
4573 };
4574 static const MyTreeNode nodes[] =
4575 {
4576 { "Root", "Folder", -1, 1, 3 }, // 0
4577 { "Music", "Folder", -1, 4, 2 }, // 1
4578 { "Textures", "Folder", -1, 6, 3 }, // 2
4579 { "desktop.ini", "System file", 1024, -1,-1 }, // 3
4580 { "File1_a.wav", "Audio file", 123000, -1,-1 }, // 4
4581 { "File1_b.wav", "Audio file", 456000, -1,-1 }, // 5
4582 { "Image001.png", "Image file", 203128, -1,-1 }, // 6
4583 { "Copy of Image001.png", "Image file", 203256, -1,-1 }, // 7
4584 { "Copy of Image001 (Final2).png","Image file", 203512, -1,-1 }, // 8
4585 };
4586
4587 MyTreeNode::DisplayNode(&nodes[0], nodes);
4588
4590 }
4592 }
4593
4594 if (open_action != -1)
4595 ImGui::SetNextItemOpen(open_action != 0);
4596 if (ImGui::TreeNode("Item width"))
4597 {
4598 HelpMarker(
4599 "Showcase using PushItemWidth() and how it is preserved on a per-column basis.\n\n"
4600 "Note that on auto-resizing non-resizable fixed columns, querying the content width for e.g. right-alignment doesn't make sense.");
4601 if (ImGui::BeginTable("table_item_width", 3, ImGuiTableFlags_Borders))
4602 {
4603 ImGui::TableSetupColumn("small");
4605 ImGui::TableSetupColumn("right-align");
4607
4608 for (int row = 0; row < 3; row++)
4609 {
4611 if (row == 0)
4612 {
4613 // Setup ItemWidth once (instead of setting up every time, which is also possible but less efficient)
4615 ImGui::PushItemWidth(TEXT_BASE_WIDTH * 3.0f); // Small
4619 ImGui::PushItemWidth(-FLT_MIN); // Right-aligned
4620 }
4621
4622 // Draw our contents
4623 static float dummy_f = 0.0f;
4626 ImGui::SliderFloat("float0", &dummy_f, 0.0f, 1.0f);
4628 ImGui::SliderFloat("float1", &dummy_f, 0.0f, 1.0f);
4630 ImGui::SliderFloat("float2", &dummy_f, 0.0f, 1.0f);
4631 ImGui::PopID();
4632 }
4634 }
4636 }
4637
4638 // Demonstrate using TableHeader() calls instead of TableHeadersRow()
4639 if (open_action != -1)
4640 ImGui::SetNextItemOpen(open_action != 0);
4641 if (ImGui::TreeNode("Custom headers"))
4642 {
4643 const int COLUMNS_COUNT = 3;
4645 {
4646 ImGui::TableSetupColumn("Apricot");
4647 ImGui::TableSetupColumn("Banana");
4648 ImGui::TableSetupColumn("Cherry");
4649
4650 // Dummy entire-column selection storage
4651 // FIXME: It would be nice to actually demonstrate full-featured selection using those checkbox.
4652 static bool column_selected[3] = {};
4653
4654 // Instead of calling TableHeadersRow() we'll submit custom headers ourselves
4656 for (int column = 0; column < COLUMNS_COUNT; column++)
4657 {
4659 const char* column_name = ImGui::TableGetColumnName(column); // Retrieve name passed to TableSetupColumn()
4660 ImGui::PushID(column);
4662 ImGui::Checkbox("##checkall", &column_selected[column]);
4664 ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
4665 ImGui::TableHeader(column_name);
4666 ImGui::PopID();
4667 }
4668
4669 for (int row = 0; row < 5; row++)
4670 {
4672 for (int column = 0; column < 3; column++)
4673 {
4674 char buf[32];
4675 sprintf(buf, "Cell %d,%d", column, row);
4677 ImGui::Selectable(buf, column_selected[column]);
4678 }
4679 }
4681 }
4683 }
4684
4685 // Demonstrate creating custom context menus inside columns, while playing it nice with context menus provided by TableHeadersRow()/TableHeader()
4686 if (open_action != -1)
4687 ImGui::SetNextItemOpen(open_action != 0);
4688 if (ImGui::TreeNode("Context menus"))
4689 {
4690 HelpMarker("By default, right-clicking over a TableHeadersRow()/TableHeader() line will open the default context-menu.\nUsing ImGuiTableFlags_ContextMenuInBody we also allow right-clicking over columns body.");
4692
4694 ImGui::CheckboxFlags("ImGuiTableFlags_ContextMenuInBody", &flags1, ImGuiTableFlags_ContextMenuInBody);
4696
4697 // Context Menus: first example
4698 // [1.1] Right-click on the TableHeadersRow() line to open the default table context menu.
4699 // [1.2] Right-click in columns also open the default table context menu (if ImGuiTableFlags_ContextMenuInBody is set)
4700 const int COLUMNS_COUNT = 3;
4701 if (ImGui::BeginTable("table_context_menu", COLUMNS_COUNT, flags1))
4702 {
4705 ImGui::TableSetupColumn("Three");
4706
4707 // [1.1]] Right-click on the TableHeadersRow() line to open the default table context menu.
4709
4710 // Submit dummy contents
4711 for (int row = 0; row < 4; row++)
4712 {
4714 for (int column = 0; column < COLUMNS_COUNT; column++)
4715 {
4717 ImGui::Text("Cell %d,%d", column, row);
4718 }
4719 }
4721 }
4722
4723 // Context Menus: second example
4724 // [2.1] Right-click on the TableHeadersRow() line to open the default table context menu.
4725 // [2.2] Right-click on the ".." to open a custom popup
4726 // [2.3] Right-click in columns to open another custom popup
4727 HelpMarker("Demonstrate mixing table context menu (over header), item context button (over button) and custom per-colum context menu (over column body).");
4729 if (ImGui::BeginTable("table_context_menu_2", COLUMNS_COUNT, flags2))
4730 {
4733 ImGui::TableSetupColumn("Three");
4734
4735 // [2.1] Right-click on the TableHeadersRow() line to open the default table context menu.
4737 for (int row = 0; row < 4; row++)
4738 {
4740 for (int column = 0; column < COLUMNS_COUNT; column++)
4741 {
4742 // Submit dummy contents
4744 ImGui::Text("Cell %d,%d", column, row);
4746
4747 // [2.2] Right-click on the ".." to open a custom popup
4748 ImGui::PushID(row * COLUMNS_COUNT + column);
4749 ImGui::SmallButton("..");
4751 {
4752 ImGui::Text("This is the popup for Button(\"..\") in Cell %d,%d", column, row);
4753 if (ImGui::Button("Close"))
4756 }
4757 ImGui::PopID();
4758 }
4759 }
4760
4761 // [2.3] Right-click anywhere in columns to open another custom popup
4762 // (instead of testing for !IsAnyItemHovered() we could also call OpenPopup() with ImGuiPopupFlags_NoOpenOverExistingPopup
4763 // to manage popup priority as the popups triggers, here "are we hovering a column" are overlapping)
4764 int hovered_column = -1;
4765 for (int column = 0; column < COLUMNS_COUNT + 1; column++)
4766 {
4767 ImGui::PushID(column);
4769 hovered_column = column;
4770 if (hovered_column == column && !ImGui::IsAnyItemHovered() && ImGui::IsMouseReleased(1))
4771 ImGui::OpenPopup("MyPopup");
4772 if (ImGui::BeginPopup("MyPopup"))
4773 {
4774 if (column == COLUMNS_COUNT)
4775 ImGui::Text("This is a custom popup for unused space after the last column.");
4776 else
4777 ImGui::Text("This is a custom popup for Column %d", column);
4778 if (ImGui::Button("Close"))
4781 }
4782 ImGui::PopID();
4783 }
4784
4786 ImGui::Text("Hovered column: %d", hovered_column);
4787 }
4789 }
4790
4791 // Demonstrate creating multiple tables with the same ID
4792 if (open_action != -1)
4793 ImGui::SetNextItemOpen(open_action != 0);
4794 if (ImGui::TreeNode("Synced instances"))
4795 {
4796 HelpMarker("Multiple tables with the same identifier will share their settings, width, visibility, order etc.");
4797 for (int n = 0; n < 3; n++)
4798 {
4799 char buf[32];
4800 sprintf(buf, "Synced Table %d", n);
4803 {
4806 ImGui::TableSetupColumn("Three");
4808 for (int cell = 0; cell < 9; cell++)
4809 {
4811 ImGui::Text("this cell %d", cell);
4812 }
4814 }
4815 }
4817 }
4818
4819 // Demonstrate using Sorting facilities
4820 // This is a simplified version of the "Advanced" example, where we mostly focus on the code necessary to handle sorting.
4821 // Note that the "Advanced" example also showcase manually triggering a sort (e.g. if item quantities have been modified)
4822 static const char* template_items_names[] =
4823 {
4824 "Banana", "Apple", "Cherry", "Watermelon", "Grapefruit", "Strawberry", "Mango",
4825 "Kiwi", "Orange", "Pineapple", "Blueberry", "Plum", "Coconut", "Pear", "Apricot"
4826 };
4827 if (open_action != -1)
4828 ImGui::SetNextItemOpen(open_action != 0);
4829 if (ImGui::TreeNode("Sorting"))
4830 {
4831 // Create item list
4832 static ImVector<MyItem> items;
4833 if (items.Size == 0)
4834 {
4835 items.resize(50, MyItem());
4836 for (int n = 0; n < items.Size; n++)
4837 {
4838 const int template_n = n % IM_ARRAYSIZE(template_items_names);
4839 MyItem& item = items[n];
4840 item.ID = n;
4841 item.Name = template_items_names[template_n];
4842 item.Quantity = (n * n - n) % 20; // Assign default quantities
4843 }
4844 }
4845
4846 // Options
4847 static ImGuiTableFlags flags =
4852 ImGui::CheckboxFlags("ImGuiTableFlags_SortMulti", &flags, ImGuiTableFlags_SortMulti);
4853 ImGui::SameLine(); HelpMarker("When sorting is enabled: hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1).");
4854 ImGui::CheckboxFlags("ImGuiTableFlags_SortTristate", &flags, ImGuiTableFlags_SortTristate);
4855 ImGui::SameLine(); HelpMarker("When sorting is enabled: allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0).");
4857
4858 if (ImGui::BeginTable("table_sorting", 4, flags, ImVec2(0.0f, TEXT_BASE_HEIGHT * 15), 0.0f))
4859 {
4860 // Declare columns
4861 // We use the "user_id" parameter of TableSetupColumn() to specify a user id that will be stored in the sort specifications.
4862 // This is so our sort function can identify a column given our own identifier. We could also identify them based on their index!
4863 // Demonstrate using a mixture of flags among available sort-related flags:
4864 // - ImGuiTableColumnFlags_DefaultSort
4865 // - ImGuiTableColumnFlags_NoSort / ImGuiTableColumnFlags_NoSortAscending / ImGuiTableColumnFlags_NoSortDescending
4866 // - ImGuiTableColumnFlags_PreferSortAscending / ImGuiTableColumnFlags_PreferSortDescending
4871 ImGui::TableSetupScrollFreeze(0, 1); // Make row always visible
4873
4874 // Sort our data if sort specs have been changed!
4875 if (ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs())
4876 if (sorts_specs->SpecsDirty)
4877 {
4878 MyItem::s_current_sort_specs = sorts_specs; // Store in variable accessible by the sort function.
4879 if (items.Size > 1)
4880 qsort(&items[0], (size_t)items.Size, sizeof(items[0]), MyItem::CompareWithSortSpecs);
4882 sorts_specs->SpecsDirty = false;
4883 }
4884
4885 // Demonstrate using clipper for large vertical lists
4886 ImGuiListClipper clipper;
4887 clipper.Begin(items.Size);
4888 while (clipper.Step())
4889 for (int row_n = clipper.DisplayStart; row_n < clipper.DisplayEnd; row_n++)
4890 {
4891 // Display a data item
4892 MyItem* item = &items[row_n];
4893 ImGui::PushID(item->ID);
4896 ImGui::Text("%04d", item->ID);
4898 ImGui::TextUnformatted(item->Name);
4900 ImGui::SmallButton("None");
4902 ImGui::Text("%d", item->Quantity);
4903 ImGui::PopID();
4904 }
4906 }
4908 }
4909
4910 // In this example we'll expose most table flags and settings.
4911 // For specific flags and settings refer to the corresponding section for more detailed explanation.
4912 // This section is mostly useful to experiment with combining certain flags or settings with each others.
4913 //ImGui::SetNextItemOpen(true, ImGuiCond_Once); // [DEBUG]
4914 if (open_action != -1)
4915 ImGui::SetNextItemOpen(open_action != 0);
4916 if (ImGui::TreeNode("Advanced"))
4917 {
4918 static ImGuiTableFlags flags =
4924
4925 enum ContentsType { CT_Text, CT_Button, CT_SmallButton, CT_FillButton, CT_Selectable, CT_SelectableSpanRow };
4926 static int contents_type = CT_SelectableSpanRow;
4927 const char* contents_type_names[] = { "Text", "Button", "SmallButton", "FillButton", "Selectable", "Selectable (span row)" };
4928 static int freeze_cols = 1;
4929 static int freeze_rows = 1;
4930 static int items_count = IM_ARRAYSIZE(template_items_names) * 2;
4931 static ImVec2 outer_size_value = ImVec2(0.0f, TEXT_BASE_HEIGHT * 12);
4932 static float row_min_height = 0.0f; // Auto
4933 static float inner_width_with_scroll = 0.0f; // Auto-extend
4934 static bool outer_size_enabled = true;
4935 static bool show_headers = true;
4936 static bool show_wrapped_text = false;
4937 //static ImGuiTextFilter filter;
4938 //ImGui::SetNextItemOpen(true, ImGuiCond_Once); // FIXME-TABLE: Enabling this results in initial clipped first pass on table which tend to affects column sizing
4939 if (ImGui::TreeNode("Options"))
4940 {
4941 // Make the UI compact because there are so many fields
4943 ImGui::PushItemWidth(TEXT_BASE_WIDTH * 28.0f);
4944
4946 {
4947 ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable);
4948 ImGui::CheckboxFlags("ImGuiTableFlags_Reorderable", &flags, ImGuiTableFlags_Reorderable);
4949 ImGui::CheckboxFlags("ImGuiTableFlags_Hideable", &flags, ImGuiTableFlags_Hideable);
4950 ImGui::CheckboxFlags("ImGuiTableFlags_Sortable", &flags, ImGuiTableFlags_Sortable);
4951 ImGui::CheckboxFlags("ImGuiTableFlags_NoSavedSettings", &flags, ImGuiTableFlags_NoSavedSettings);
4952 ImGui::CheckboxFlags("ImGuiTableFlags_ContextMenuInBody", &flags, ImGuiTableFlags_ContextMenuInBody);
4954 }
4955
4957 {
4958 ImGui::CheckboxFlags("ImGuiTableFlags_RowBg", &flags, ImGuiTableFlags_RowBg);
4959 ImGui::CheckboxFlags("ImGuiTableFlags_BordersV", &flags, ImGuiTableFlags_BordersV);
4960 ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags, ImGuiTableFlags_BordersOuterV);
4961 ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags, ImGuiTableFlags_BordersInnerV);
4962 ImGui::CheckboxFlags("ImGuiTableFlags_BordersH", &flags, ImGuiTableFlags_BordersH);
4963 ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterH", &flags, ImGuiTableFlags_BordersOuterH);
4964 ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerH", &flags, ImGuiTableFlags_BordersInnerH);
4965 ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBody", &flags, ImGuiTableFlags_NoBordersInBody); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body (borders will always appears in Headers");
4966 ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", &flags, ImGuiTableFlags_NoBordersInBodyUntilResize); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers)");
4968 }
4969
4971 {
4972 EditTableSizingFlags(&flags);
4973 ImGui::SameLine(); HelpMarker("In the Advanced demo we override the policy of each column so those table-wide settings have less effect that typical.");
4974 ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags, ImGuiTableFlags_NoHostExtendX);
4975 ImGui::SameLine(); HelpMarker("Make outer width auto-fit to columns, overriding outer_size.x value.\n\nOnly available when ScrollX/ScrollY are disabled and Stretch columns are not used.");
4976 ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY);
4977 ImGui::SameLine(); HelpMarker("Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit).\n\nOnly available when ScrollX/ScrollY are disabled. Data below the limit will be clipped and not visible.");
4978 ImGui::CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", &flags, ImGuiTableFlags_NoKeepColumnsVisible);
4979 ImGui::SameLine(); HelpMarker("Only available if ScrollX is disabled.");
4980 ImGui::CheckboxFlags("ImGuiTableFlags_PreciseWidths", &flags, ImGuiTableFlags_PreciseWidths);
4981 ImGui::SameLine(); HelpMarker("Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth.");
4982 ImGui::CheckboxFlags("ImGuiTableFlags_NoClip", &flags, ImGuiTableFlags_NoClip);
4983 ImGui::SameLine(); HelpMarker("Disable clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow into other columns). Generally incompatible with ScrollFreeze options.");
4985 }
4986
4988 {
4989 ImGui::CheckboxFlags("ImGuiTableFlags_PadOuterX", &flags, ImGuiTableFlags_PadOuterX);
4990 ImGui::CheckboxFlags("ImGuiTableFlags_NoPadOuterX", &flags, ImGuiTableFlags_NoPadOuterX);
4991 ImGui::CheckboxFlags("ImGuiTableFlags_NoPadInnerX", &flags, ImGuiTableFlags_NoPadInnerX);
4993 }
4994
4996 {
4997 ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags, ImGuiTableFlags_ScrollX);
5000 ImGui::DragInt("freeze_cols", &freeze_cols, 0.2f, 0, 9, NULL, ImGuiSliderFlags_NoInput);
5001 ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY);
5004 ImGui::DragInt("freeze_rows", &freeze_rows, 0.2f, 0, 9, NULL, ImGuiSliderFlags_NoInput);
5006 }
5007
5009 {
5010 ImGui::CheckboxFlags("ImGuiTableFlags_SortMulti", &flags, ImGuiTableFlags_SortMulti);
5011 ImGui::SameLine(); HelpMarker("When sorting is enabled: hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1).");
5012 ImGui::CheckboxFlags("ImGuiTableFlags_SortTristate", &flags, ImGuiTableFlags_SortTristate);
5013 ImGui::SameLine(); HelpMarker("When sorting is enabled: allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0).");
5015 }
5016
5018 {
5019 ImGui::Checkbox("show_headers", &show_headers);
5020 ImGui::Checkbox("show_wrapped_text", &show_wrapped_text);
5021
5022 ImGui::DragFloat2("##OuterSize", &outer_size_value.x);
5023 ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
5024 ImGui::Checkbox("outer_size", &outer_size_enabled);
5026 HelpMarker("If scrolling is disabled (ScrollX and ScrollY not set):\n"
5027 "- The table is output directly in the parent window.\n"
5028 "- OuterSize.x < 0.0f will right-align the table.\n"
5029 "- OuterSize.x = 0.0f will narrow fit the table unless there are any Stretch column.\n"
5030 "- OuterSize.y then becomes the minimum size for the table, which will extend vertically if there are more rows (unless NoHostExtendY is set).");
5031
5032 // From a user point of view we will tend to use 'inner_width' differently depending on whether our table is embedding scrolling.
5033 // To facilitate toying with this demo we will actually pass 0.0f to the BeginTable() when ScrollX is disabled.
5034 ImGui::DragFloat("inner_width (when ScrollX active)", &inner_width_with_scroll, 1.0f, 0.0f, FLT_MAX);
5035
5036 ImGui::DragFloat("row_min_height", &row_min_height, 1.0f, 0.0f, FLT_MAX);
5037 ImGui::SameLine(); HelpMarker("Specify height of the Selectable item.");
5038
5039 ImGui::DragInt("items_count", &items_count, 0.1f, 0, 9999);
5040 ImGui::Combo("items_type (first column)", &contents_type, contents_type_names, IM_ARRAYSIZE(contents_type_names));
5041 //filter.Draw("filter");
5043 }
5044
5049 }
5050
5051 // Update item list if we changed the number of items
5052 static ImVector<MyItem> items;
5053 static ImVector<int> selection;
5054 static bool items_need_sort = false;
5055 if (items.Size != items_count)
5056 {
5057 items.resize(items_count, MyItem());
5058 for (int n = 0; n < items_count; n++)
5059 {
5060 const int template_n = n % IM_ARRAYSIZE(template_items_names);
5061 MyItem& item = items[n];
5062 item.ID = n;
5063 item.Name = template_items_names[template_n];
5064 item.Quantity = (template_n == 3) ? 10 : (template_n == 4) ? 20 : 0; // Assign default quantities
5065 }
5066 }
5067
5068 const ImDrawList* parent_draw_list = ImGui::GetWindowDrawList();
5069 const int parent_draw_list_draw_cmd_count = parent_draw_list->CmdBuffer.Size;
5070 ImVec2 table_scroll_cur, table_scroll_max; // For debug display
5071 const ImDrawList* table_draw_list = NULL; // "
5072
5073 // Submit table
5074 const float inner_width_to_use = (flags & ImGuiTableFlags_ScrollX) ? inner_width_with_scroll : 0.0f;
5075 if (ImGui::BeginTable("table_advanced", 6, flags, outer_size_enabled ? outer_size_value : ImVec2(0, 0), inner_width_to_use))
5076 {
5077 // Declare columns
5078 // We use the "user_id" parameter of TableSetupColumn() to specify a user id that will be stored in the sort specifications.
5079 // This is so our sort function can identify a column given our own identifier. We could also identify them based on their index!
5086 ImGui::TableSetupScrollFreeze(freeze_cols, freeze_rows);
5087
5088 // Sort our data if sort specs have been changed!
5090 if (sorts_specs && sorts_specs->SpecsDirty)
5091 items_need_sort = true;
5092 if (sorts_specs && items_need_sort && items.Size > 1)
5093 {
5094 MyItem::s_current_sort_specs = sorts_specs; // Store in variable accessible by the sort function.
5095 qsort(&items[0], (size_t)items.Size, sizeof(items[0]), MyItem::CompareWithSortSpecs);
5097 sorts_specs->SpecsDirty = false;
5098 }
5099 items_need_sort = false;
5100
5101 // Take note of whether we are currently sorting based on the Quantity field,
5102 // we will use this to trigger sorting when we know the data of this column has been modified.
5103 const bool sorts_specs_using_quantity = (ImGui::TableGetColumnFlags(3) & ImGuiTableColumnFlags_IsSorted) != 0;
5104
5105 // Show headers
5106 if (show_headers)
5108
5109 // Show data
5110 // FIXME-TABLE FIXME-NAV: How we can get decent up/down even though we have the buttons here?
5112#if 1
5113 // Demonstrate using clipper for large vertical lists
5114 ImGuiListClipper clipper;
5115 clipper.Begin(items.Size);
5116 while (clipper.Step())
5117 {
5118 for (int row_n = clipper.DisplayStart; row_n < clipper.DisplayEnd; row_n++)
5119#else
5120 // Without clipper
5121 {
5122 for (int row_n = 0; row_n < items.Size; row_n++)
5123#endif
5124 {
5125 MyItem* item = &items[row_n];
5126 //if (!filter.PassFilter(item->Name))
5127 // continue;
5128
5129 const bool item_is_selected = selection.contains(item->ID);
5130 ImGui::PushID(item->ID);
5132
5133 // For the demo purpose we can select among different type of items submitted in the first column
5135 char label[32];
5136 sprintf(label, "%04d", item->ID);
5137 if (contents_type == CT_Text)
5139 else if (contents_type == CT_Button)
5140 ImGui::Button(label);
5141 else if (contents_type == CT_SmallButton)
5142 ImGui::SmallButton(label);
5143 else if (contents_type == CT_FillButton)
5144 ImGui::Button(label, ImVec2(-FLT_MIN, 0.0f));
5145 else if (contents_type == CT_Selectable || contents_type == CT_SelectableSpanRow)
5146 {
5148 if (ImGui::Selectable(label, item_is_selected, selectable_flags, ImVec2(0, row_min_height)))
5149 {
5150 if (ImGui::GetIO().KeyCtrl)
5151 {
5152 if (item_is_selected)
5153 selection.find_erase_unsorted(item->ID);
5154 else
5155 selection.push_back(item->ID);
5156 }
5157 else
5158 {
5159 selection.clear();
5160 selection.push_back(item->ID);
5161 }
5162 }
5163 }
5164
5166 ImGui::TextUnformatted(item->Name);
5167
5168 // Here we demonstrate marking our data set as needing to be sorted again if we modified a quantity,
5169 // and we are currently sorting on the column showing the Quantity.
5170 // To avoid triggering a sort while holding the button, we only trigger it when the button has been released.
5171 // You will probably need a more advanced system in your code if you want to automatically sort when a specific entry changes.
5173 {
5174 if (ImGui::SmallButton("Chop")) { item->Quantity += 1; }
5175 if (sorts_specs_using_quantity && ImGui::IsItemDeactivated()) { items_need_sort = true; }
5177 if (ImGui::SmallButton("Eat")) { item->Quantity -= 1; }
5178 if (sorts_specs_using_quantity && ImGui::IsItemDeactivated()) { items_need_sort = true; }
5179 }
5180
5182 ImGui::Text("%d", item->Quantity);
5183
5185 if (show_wrapped_text)
5186 ImGui::TextWrapped("Lorem ipsum dolor sit amet");
5187 else
5188 ImGui::Text("Lorem ipsum dolor sit amet");
5189
5191 ImGui::Text("1234");
5192
5193 ImGui::PopID();
5194 }
5195 }
5197
5198 // Store some info to display debug details below
5199 table_scroll_cur = ImVec2(ImGui::GetScrollX(), ImGui::GetScrollY());
5200 table_scroll_max = ImVec2(ImGui::GetScrollMaxX(), ImGui::GetScrollMaxY());
5201 table_draw_list = ImGui::GetWindowDrawList();
5203 }
5204 static bool show_debug_details = false;
5205 ImGui::Checkbox("Debug details", &show_debug_details);
5206 if (show_debug_details && table_draw_list)
5207 {
5208 ImGui::SameLine(0.0f, 0.0f);
5209 const int table_draw_list_draw_cmd_count = table_draw_list->CmdBuffer.Size;
5210 if (table_draw_list == parent_draw_list)
5211 ImGui::Text(": DrawCmd: +%d (in same window)",
5212 table_draw_list_draw_cmd_count - parent_draw_list_draw_cmd_count);
5213 else
5214 ImGui::Text(": DrawCmd: +%d (in child window), Scroll: (%.f/%.f) (%.f/%.f)",
5215 table_draw_list_draw_cmd_count - 1, table_scroll_cur.x, table_scroll_max.x, table_scroll_cur.y, table_scroll_max.y);
5216 }
5218 }
5219
5220 ImGui::PopID();
5221
5223
5224 if (disable_indent)
5226}
EIGEN_DEVICE_FUNC RowXpr row(Index i)
This is the const version of row(). *‍/.
Definition BlockMethods.h:859
unsigned int ImU32
Definition imgui.h:229
@ ImGuiTableColumnFlags_IsHovered
Definition imgui.h:1188
@ ImGuiTableColumnFlags_None
Definition imgui.h:1166
@ ImGuiTableColumnFlags_IsSorted
Definition imgui.h:1187
@ ImGuiStyleVar_IndentSpacing
Definition imgui.h:1494
@ ImGuiStyleVar_CellPadding
Definition imgui.h:1495
@ ImGuiSliderFlags_AlwaysClamp
Definition imgui.h:1570
@ ImGuiSliderFlags_NoInput
Definition imgui.h:1573
@ ImGuiTableBgTarget_CellBg
Definition imgui.h:1223
@ ImGuiTableBgTarget_RowBg0
Definition imgui.h:1221
@ ImGuiCol_FrameBg
Definition imgui.h:1420
@ ImGuiTableRowFlags_None
Definition imgui.h:1205
@ ImGuiTableRowFlags_Headers
Definition imgui.h:1206
int ImGuiSelectableFlags
Definition imgui.h:192
@ ImGuiTreeNodeFlags_DefaultOpen
Definition imgui.h:992
@ ImGuiTreeNodeFlags_Leaf
Definition imgui.h:995
@ ImGuiTreeNodeFlags_NoTreePushOnOpen
Definition imgui.h:990
@ ImGuiTreeNodeFlags_SpanFullWidth
Definition imgui.h:999
@ ImGuiTreeNodeFlags_Bullet
Definition imgui.h:996
@ ImGuiSelectableFlags_AllowItemOverlap
Definition imgui.h:1036
@ ImGuiSelectableFlags_None
Definition imgui.h:1031
@ ImGuiTableFlags_SortTristate
Definition imgui.h:1150
@ ImGuiTableFlags_Sortable
Definition imgui.h:1113
@ ImGuiTableFlags_NoBordersInBodyUntilResize
Definition imgui.h:1128
@ ImGuiTableFlags_SortMulti
Definition imgui.h:1149
@ ImGuiTableFlags_NoBordersInBody
Definition imgui.h:1127
@ ImGuiTableFlags_NoClip
Definition imgui.h:1140
@ ImGuiTableFlags_RowBg
Definition imgui.h:1117
@ ImGuiTableFlags_Reorderable
Definition imgui.h:1111
@ ImGuiTableFlags_BordersInnerH
Definition imgui.h:1118
@ ImGuiTableFlags_BordersInner
Definition imgui.h:1124
@ ImGuiTableFlags_BordersH
Definition imgui.h:1122
@ ImGuiTableFlags_NoPadInnerX
Definition imgui.h:1144
@ ImGuiTableFlags_ScrollY
Definition imgui.h:1147
@ ImGuiTableFlags_NoHostExtendX
Definition imgui.h:1135
@ ImGuiTableFlags_PadOuterX
Definition imgui.h:1142
@ ImGuiTableFlags_BordersOuterV
Definition imgui.h:1121
@ ImGuiTableFlags_NoKeepColumnsVisible
Definition imgui.h:1137
@ ImGuiTableFlags_ScrollX
Definition imgui.h:1146
@ ImGuiTableFlags_BordersInnerV
Definition imgui.h:1120
@ ImGuiTableFlags_ContextMenuInBody
Definition imgui.h:1115
@ ImGuiTableFlags_PreciseWidths
Definition imgui.h:1138
@ ImGuiTableFlags_BordersV
Definition imgui.h:1123
@ ImGuiTableFlags_NoPadOuterX
Definition imgui.h:1143
@ ImGuiTableFlags_NoHostExtendY
Definition imgui.h:1136
@ ImGuiTableFlags_Hideable
Definition imgui.h:1112
@ ImGuiTableFlags_BordersOuterH
Definition imgui.h:1119
@ ImGuiTableFlags_BordersOuter
Definition imgui.h:1125
int ImGuiTableColumnFlags
Definition imgui.h:197
static void ShowTableColumnsStatusFlags(ImGuiTableColumnFlags flags)
Definition imgui_demo.cpp:3520
static void EditTableSizingFlags(ImGuiTableFlags *p_flags)
Definition imgui_demo.cpp:3456
static void PushStyleCompact()
Definition imgui_demo.cpp:3443
static void PopStyleCompact()
Definition imgui_demo.cpp:3450
static void EditTableColumnsFlags(ImGuiTableColumnFlags *p_flags)
Definition imgui_demo.cpp:3498
static void ShowDemoWindowColumns()
Definition imgui_demo.cpp:5230
Type
Definition Constants.h:461
Definition imconfig.h:118
IMGUI_API bool IsAnyItemHovered()
Definition imgui.cpp:4899
IMGUI_API int TableGetColumnIndex()
Definition imgui_tables.cpp:1859
IMGUI_API void TableHeadersRow()
Definition imgui_tables.cpp:2795
IMGUI_API void PopButtonRepeat()
Definition imgui.cpp:6587
IMGUI_API int TableGetRowIndex()
Definition imgui_tables.cpp:1647
IMGUI_API bool TreeNodeEx(const char *label, ImGuiTreeNodeFlags flags=0)
Definition imgui_widgets.cpp:5611
IMGUI_API void TableNextRow(ImGuiTableRowFlags row_flags=0, float min_row_height=0.0f)
Definition imgui_tables.cpp:1657
IMGUI_API const char * TableGetColumnName(int column_n=-1)
Definition imgui_tables.cpp:1507
IMGUI_API void TableSetupScrollFreeze(int cols, int rows)
Definition imgui_tables.cpp:1470
IMGUI_API void SetNextItemOpen(bool is_open, ImGuiCond cond=0)
Definition imgui_widgets.cpp:5948
IMGUI_API void TableSetupColumn(const char *label, ImGuiTableColumnFlags flags=0, float init_width_or_weight=0.0f, ImGuiID user_id=0)
Definition imgui_tables.cpp:1402
IMGUI_API void PushButtonRepeat(bool repeat)
Definition imgui.cpp:6582
IMGUI_API bool SliderFloat2(const char *label, float v[2], float v_min, float v_max, const char *format="%.3f", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:3043
IMGUI_API bool RadioButton(const char *label, bool active)
Definition imgui_widgets.cpp:1177
IMGUI_API ImGuiTableColumnFlags TableGetColumnFlags(int column_n=-1)
Definition imgui_tables.cpp:1547
IMGUI_API ImVec2 CalcTextSize(const char *text, const char *text_end=NULL, bool hide_text_after_double_hash=false, float wrap_width=-1.0f)
Definition imgui.cpp:4524
IMGUI_API float GetTextLineHeightWithSpacing()
Definition imgui.cpp:7645
IMGUI_API ImGuiTableSortSpecs * TableGetSortSpecs()
Definition imgui_tables.cpp:2587
IMGUI_API bool IsItemDeactivated()
Definition imgui.cpp:4854
IMGUI_API bool TableSetColumnIndex(int column_n)
Definition imgui_tables.cpp:1869
IMGUI_API void TableHeader(const char *label)
Definition imgui_tables.cpp:2837
IMGUI_API float GetFrameHeight()
Definition imgui.cpp:7651
IMGUI_API void TableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n=-1)
Definition imgui_tables.cpp:1595
std::tuple< TriangleInfos, VertexInfos, EdgeInfos, Errors > init(const indexed_triangle_set &its, ThrowOnCancel &throw_on_cancel, StatusFn &status_fn)
Definition QuadricEdgeCollapse.cpp:441
@ MyItemColumnID_Name
Definition imgui_demo.cpp:3388
@ MyItemColumnID_ID
Definition imgui_demo.cpp:3387
@ MyItemColumnID_Action
Definition imgui_demo.cpp:3389
@ MyItemColumnID_Description
Definition imgui_demo.cpp:3391
@ MyItemColumnID_Quantity
Definition imgui_demo.cpp:3390
ImVector< ImDrawCmd > CmdBuffer
Definition imgui.h:2350
Definition imgui.h:1993
bool SpecsDirty
Definition imgui.h:1996
Definition imgui.h:1654
bool find_erase_unsorted(const T &v)
Definition imgui.h:1707
bool contains(const T &v) const
Definition imgui.h:1703
void push_back(const T &v)
Definition imgui.h:1696
void resize(int new_size)
Definition imgui.h:1690
void clear()
Definition imgui.h:1678
static const ImGuiTableSortSpecs * s_current_sort_specs
Definition imgui_demo.cpp:3407
static int IMGUI_CDECL CompareWithSortSpecs(const void *lhs, const void *rhs)
Definition imgui_demo.cpp:3410

References ImGui::AlignTextToFramePadding(), ImGuiListClipper::Begin(), ImGui::BeginPopup(), ImGui::BeginPopupContextItem(), ImGui::BeginTable(), ImGui::Button(), ImGui::CalcTextSize(), ImGui::Checkbox(), ImGui::CheckboxFlags(), ImVector< T >::clear(), ImGui::CloseCurrentPopup(), ImDrawList::CmdBuffer, ImGui::CollapsingHeader(), ImGui::Combo(), anonymous_namespace{imgui_demo.cpp}::MyItem::CompareWithSortSpecs(), ImVector< T >::contains(), ImGuiListClipper::DisplayEnd, ImGuiListClipper::DisplayStart, ImGui::DragFloat(), ImGui::DragFloat2(), ImGui::DragInt(), EditTableColumnsFlags(), EditTableSizingFlags(), ImGui::EndPopup(), ImGui::EndTable(), ImVector< T >::find_erase_unsorted(), ImGui::GetColorU32(), ImGui::GetContentRegionAvail(), ImGui::GetFrameHeight(), ImGui::GetIO(), ImGui::GetScrollMaxX(), ImGui::GetScrollMaxY(), ImGui::GetScrollX(), ImGui::GetScrollY(), ImGui::GetStyle(), ImGui::GetTextLineHeightWithSpacing(), ImGui::GetWindowDrawList(), HelpMarker(), IM_ARRAYSIZE, IM_ASSERT, ImGuiCol_FrameBg, ImGuiSelectableFlags_AllowItemOverlap, ImGuiSelectableFlags_None, ImGuiSelectableFlags_SpanAllColumns, ImGuiSliderFlags_AlwaysClamp, ImGuiSliderFlags_NoInput, ImGuiStyleVar_CellPadding, ImGuiStyleVar_FramePadding, ImGuiStyleVar_IndentSpacing, ImGuiTableBgTarget_CellBg, ImGuiTableBgTarget_RowBg0, ImGuiTableColumnFlags_DefaultHide, ImGuiTableColumnFlags_DefaultSort, ImGuiTableColumnFlags_IsHovered, ImGuiTableColumnFlags_IsSorted, ImGuiTableColumnFlags_NoHide, ImGuiTableColumnFlags_None, ImGuiTableColumnFlags_NoSort, ImGuiTableColumnFlags_PreferSortDescending, ImGuiTableColumnFlags_WidthFixed, ImGuiTableColumnFlags_WidthStretch, ImGuiTableFlags_Borders, ImGuiTableFlags_BordersH, ImGuiTableFlags_BordersInner, ImGuiTableFlags_BordersInnerH, ImGuiTableFlags_BordersInnerV, ImGuiTableFlags_BordersOuter, ImGuiTableFlags_BordersOuterH, ImGuiTableFlags_BordersOuterV, ImGuiTableFlags_BordersV, ImGuiTableFlags_ContextMenuInBody, ImGuiTableFlags_Hideable, ImGuiTableFlags_NoBordersInBody, ImGuiTableFlags_NoBordersInBodyUntilResize, ImGuiTableFlags_NoClip, ImGuiTableFlags_NoHostExtendX, ImGuiTableFlags_NoHostExtendY, ImGuiTableFlags_NoKeepColumnsVisible, ImGuiTableFlags_None, ImGuiTableFlags_NoPadInnerX, ImGuiTableFlags_NoPadOuterX, ImGuiTableFlags_NoSavedSettings, ImGuiTableFlags_PadOuterX, ImGuiTableFlags_PreciseWidths, ImGuiTableFlags_Reorderable, ImGuiTableFlags_Resizable, ImGuiTableFlags_RowBg, ImGuiTableFlags_ScrollX, ImGuiTableFlags_ScrollY, ImGuiTableFlags_SizingFixedFit, ImGuiTableFlags_SizingFixedSame, ImGuiTableFlags_SizingStretchProp, ImGuiTableFlags_SizingStretchSame, ImGuiTableFlags_Sortable, ImGuiTableFlags_SortMulti, ImGuiTableFlags_SortTristate, ImGuiTableRowFlags_Headers, ImGuiTableRowFlags_None, ImGuiTreeNodeFlags_Bullet, ImGuiTreeNodeFlags_DefaultOpen, ImGuiTreeNodeFlags_Leaf, ImGuiTreeNodeFlags_NoTreePushOnOpen, ImGuiTreeNodeFlags_SpanFullWidth, ImGui::Indent(), ImGui::InputText(), ImGui::IsAnyItemHovered(), ImGui::IsItemDeactivated(), ImGui::IsMouseReleased(), anonymous_namespace{imgui_demo.cpp}::MyItemColumnID_Action, anonymous_namespace{imgui_demo.cpp}::MyItemColumnID_Description, anonymous_namespace{imgui_demo.cpp}::MyItemColumnID_ID, anonymous_namespace{imgui_demo.cpp}::MyItemColumnID_Name, anonymous_namespace{imgui_demo.cpp}::MyItemColumnID_Quantity, ImGui::OpenPopup(), ImGui::PopButtonRepeat(), ImGui::PopID(), ImGui::PopItemWidth(), ImGui::PopStyleColor(), PopStyleCompact(), ImGui::PopStyleVar(), ImVector< T >::push_back(), ImGui::PushButtonRepeat(), ImGui::PushID(), ImGui::PushItemWidth(), ImGui::PushStyleColor(), PushStyleCompact(), ImGui::PushStyleVar(), ImGui::RadioButton(), ImVector< T >::resize(), row(), anonymous_namespace{imgui_demo.cpp}::MyItem::s_current_sort_specs, ImGui::SameLine(), ImGui::Selectable(), ImGui::Separator(), ImGui::SetNextItemOpen(), ImGui::SetNextItemWidth(), ShowDemoWindowColumns(), ShowTableColumnsStatusFlags(), ImVector< T >::Size, ImGui::SliderFloat(), ImGui::SliderFloat2(), ImGui::SmallButton(), ImGui::Spacing(), ImGuiTableSortSpecs::SpecsDirty, ImGuiListClipper::Step(), ImGui::TableGetColumnFlags(), ImGui::TableGetColumnIndex(), ImGui::TableGetColumnName(), ImGui::TableGetRowIndex(), ImGui::TableGetSortSpecs(), ImGui::TableHeader(), ImGui::TableHeadersRow(), ImGui::TableNextColumn(), ImGui::TableNextRow(), ImGui::TableSetBgColor(), ImGui::TableSetColumnIndex(), ImGui::TableSetupColumn(), ImGui::TableSetupScrollFreeze(), ImGui::Text(), ImGui::TextDisabled(), ImGui::TextUnformatted(), ImGui::TextWrapped(), ImGui::TreeNode(), ImGui::TreeNodeEx(), ImGui::TreePop(), ImGui::Unindent(), ImVec2::x, and ImVec2::y.

Referenced by ImGui::ShowDemoWindow().

+ Here is the caller graph for this function:

◆ ShowDemoWindowWidgets()

static void ShowDemoWindowWidgets ( )
static

of the loop. May be a pointer to your own node type, etc.

530{
531 if (!ImGui::CollapsingHeader("Widgets"))
532 return;
533
534 if (ImGui::TreeNode("Basic"))
535 {
536 static int clicked = 0;
537 if (ImGui::Button("Button"))
538 clicked++;
539 if (clicked & 1)
540 {
542 ImGui::Text("Thanks for clicking me!");
543 }
544
545 static bool check = true;
546 ImGui::Checkbox("checkbox", &check);
547
548 static int e = 0;
549 ImGui::RadioButton("radio a", &e, 0); ImGui::SameLine();
550 ImGui::RadioButton("radio b", &e, 1); ImGui::SameLine();
551 ImGui::RadioButton("radio c", &e, 2);
552
553 // Color buttons, demonstrate using PushID() to add unique identifier in the ID stack, and changing style.
554 for (int i = 0; i < 7; i++)
555 {
556 if (i > 0)
558 ImGui::PushID(i);
562 ImGui::Button("Click");
564 ImGui::PopID();
565 }
566
567 // Use AlignTextToFramePadding() to align text baseline to the baseline of framed widgets elements
568 // (otherwise a Text+SameLine+Button sequence will have the text a little too high by default!)
569 // See 'Demo->Layout->Text Baseline Alignment' for details.
571 ImGui::Text("Hold to repeat:");
573
574 // Arrow buttons with Repeater
575 static int counter = 0;
576 float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
578 if (ImGui::ArrowButton("##left", ImGuiDir_Left)) { counter--; }
579 ImGui::SameLine(0.0f, spacing);
580 if (ImGui::ArrowButton("##right", ImGuiDir_Right)) { counter++; }
583 ImGui::Text("%d", counter);
584
585 ImGui::Text("Hover over me");
587 ImGui::SetTooltip("I am a tooltip");
588
590 ImGui::Text("- or me");
592 {
594 ImGui::Text("I am a fancy tooltip");
595 static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f };
596 ImGui::PlotLines("Curve", arr, IM_ARRAYSIZE(arr));
598 }
599
601
602 ImGui::LabelText("label", "Value");
603
604 {
605 // Using the _simplified_ one-liner Combo() api here
606 // See "Combo" section for examples of how to use the more flexible BeginCombo()/EndCombo() api.
607 const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIIIIII", "JJJJ", "KKKKKKK" };
608 static int item_current = 0;
609 ImGui::Combo("combo", &item_current, items, IM_ARRAYSIZE(items));
611 "Using the simplified one-liner Combo API here.\nRefer to the \"Combo\" section below for an explanation of how to use the more flexible and general BeginCombo/EndCombo API.");
612 }
613
614 {
615 // To wire InputText() with std::string or any other custom string type,
616 // see the "Text Input > Resize Callback" section of this demo, and the misc/cpp/imgui_stdlib.h file.
617 static char str0[128] = "Hello, world!";
618 ImGui::InputText("input text", str0, IM_ARRAYSIZE(str0));
620 "USER:\n"
621 "Hold SHIFT or use mouse to select text.\n"
622 "CTRL+Left/Right to word jump.\n"
623 "CTRL+A or double-click to select all.\n"
624 "CTRL+X,CTRL+C,CTRL+V clipboard.\n"
625 "CTRL+Z,CTRL+Y undo/redo.\n"
626 "ESCAPE to revert.\n\n"
627 "PROGRAMMER:\n"
628 "You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputText() "
629 "to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example (this is not demonstrated "
630 "in imgui_demo.cpp).");
631
632 static char str1[128] = "";
633 ImGui::InputTextWithHint("input text (w/ hint)", "enter text here", str1, IM_ARRAYSIZE(str1));
634
635 static int i0 = 123;
636 ImGui::InputInt("input int", &i0);
638 "You can apply arithmetic operators +,*,/ on numerical values.\n"
639 " e.g. [ 100 ], input \'*2\', result becomes [ 200 ]\n"
640 "Use +- to subtract.");
641
642 static float f0 = 0.001f;
643 ImGui::InputFloat("input float", &f0, 0.01f, 1.0f, "%.3f");
644
645 static double d0 = 999999.00000001;
646 ImGui::InputDouble("input double", &d0, 0.01f, 1.0f, "%.8f");
647
648 static float f1 = 1.e10f;
649 ImGui::InputFloat("input scientific", &f1, 0.0f, 0.0f, "%e");
651 "You can input value using the scientific notation,\n"
652 " e.g. \"1e+8\" becomes \"100000000\".");
653
654 static float vec4a[4] = { 0.10f, 0.20f, 0.30f, 0.44f };
655 ImGui::InputFloat3("input float3", vec4a);
656 }
657
658 {
659 static int i1 = 50, i2 = 42;
660 ImGui::DragInt("drag int", &i1, 1);
662 "Click and drag to edit value.\n"
663 "Hold SHIFT/ALT for faster/slower edit.\n"
664 "Double-click or CTRL+click to input value.");
665
666 ImGui::DragInt("drag int 0..100", &i2, 1, 0, 100, "%d%%", ImGuiSliderFlags_AlwaysClamp);
667
668 static float f1 = 1.00f, f2 = 0.0067f;
669 ImGui::DragFloat("drag float", &f1, 0.005f);
670 ImGui::DragFloat("drag small float", &f2, 0.0001f, 0.0f, 0.0f, "%.06f ns");
671 }
672
673 {
674 static int i1 = 0;
675 ImGui::SliderInt("slider int", &i1, -1, 3);
676 ImGui::SameLine(); HelpMarker("CTRL+click to input value.");
677
678 static float f1 = 0.123f, f2 = 0.0f;
679 ImGui::SliderFloat("slider float", &f1, 0.0f, 1.0f, "ratio = %.3f");
680 ImGui::SliderFloat("slider float (log)", &f2, -10.0f, 10.0f, "%.4f", ImGuiSliderFlags_Logarithmic);
681
682 static float angle = 0.0f;
683 ImGui::SliderAngle("slider angle", &angle);
684
685 // Using the format string to display a name instead of an integer.
686 // Here we completely omit '%d' from the format string, so it'll only display a name.
687 // This technique can also be used with DragInt().
688 enum Element { Element_Fire, Element_Earth, Element_Air, Element_Water, Element_COUNT };
689 static int elem = Element_Fire;
690 const char* elems_names[Element_COUNT] = { "Fire", "Earth", "Air", "Water" };
691 const char* elem_name = (elem >= 0 && elem < Element_COUNT) ? elems_names[elem] : "Unknown";
692 ImGui::SliderInt("slider enum", &elem, 0, Element_COUNT - 1, elem_name);
693 ImGui::SameLine(); HelpMarker("Using the format string parameter to display a name instead of the underlying integer.");
694 }
695
696 {
697 static float col1[3] = { 1.0f, 0.0f, 0.2f };
698 static float col2[4] = { 0.4f, 0.7f, 0.0f, 0.5f };
699 ImGui::ColorEdit3("color 1", col1);
701 "Click on the color square to open a color picker.\n"
702 "Click and hold to use drag and drop.\n"
703 "Right-click on the color square to show options.\n"
704 "CTRL+click on individual component to input value.\n");
705
706 ImGui::ColorEdit4("color 2", col2);
707 }
708
709 {
710 // Using the _simplified_ one-liner ListBox() api here
711 // See "List boxes" section for examples of how to use the more flexible BeginListBox()/EndListBox() api.
712 const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" };
713 static int item_current = 1;
714 ImGui::ListBox("listbox", &item_current, items, IM_ARRAYSIZE(items), 4);
716 "Using the simplified one-liner ListBox API here.\nRefer to the \"List boxes\" section below for an explanation of how to use the more flexible and general BeginListBox/EndListBox API.");
717 }
718
720 }
721
722 // Testing ImGuiOnceUponAFrame helper.
723 //static ImGuiOnceUponAFrame once;
724 //for (int i = 0; i < 5; i++)
725 // if (once)
726 // ImGui::Text("This will be displayed only once.");
727
728 if (ImGui::TreeNode("Trees"))
729 {
730 if (ImGui::TreeNode("Basic trees"))
731 {
732 for (int i = 0; i < 5; i++)
733 {
734 // Use SetNextItemOpen() so set the default state of a node to be open. We could
735 // also use TreeNodeEx() with the ImGuiTreeNodeFlags_DefaultOpen flag to achieve the same thing!
736 if (i == 0)
738
739 if (ImGui::TreeNode((void*)(intptr_t)i, "Child %d", i))
740 {
741 ImGui::Text("blah blah");
743 if (ImGui::SmallButton("button")) {}
745 }
746 }
748 }
749
750 if (ImGui::TreeNode("Advanced, with Selectable nodes"))
751 {
753 "This is a more typical looking tree with selectable nodes.\n"
754 "Click to select, CTRL+Click to toggle, click on arrows or double-click to open.");
756 static bool align_label_with_current_x_position = false;
757 static bool test_drag_and_drop = false;
758 ImGui::CheckboxFlags("ImGuiTreeNodeFlags_OpenOnArrow", &base_flags, ImGuiTreeNodeFlags_OpenOnArrow);
759 ImGui::CheckboxFlags("ImGuiTreeNodeFlags_OpenOnDoubleClick", &base_flags, ImGuiTreeNodeFlags_OpenOnDoubleClick);
760 ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanAvailWidth", &base_flags, ImGuiTreeNodeFlags_SpanAvailWidth); ImGui::SameLine(); HelpMarker("Extend hit area to all available width instead of allowing more items to be laid out after the node.");
761 ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanFullWidth", &base_flags, ImGuiTreeNodeFlags_SpanFullWidth);
762 ImGui::Checkbox("Align label with current X position", &align_label_with_current_x_position);
763 ImGui::Checkbox("Test tree node as drag source", &test_drag_and_drop);
764 ImGui::Text("Hello!");
765 if (align_label_with_current_x_position)
767
768 // 'selection_mask' is dumb representation of what may be user-side selection state.
769 // You may retain selection state inside or outside your objects in whatever format you see fit.
770 // 'node_clicked' is temporary storage of what node we have clicked to process selection at the end
772 static int selection_mask = (1 << 2);
773 int node_clicked = -1;
774 for (int i = 0; i < 6; i++)
775 {
776 // Disable the default "open on single-click behavior" + set Selected flag according to our selection.
777 ImGuiTreeNodeFlags node_flags = base_flags;
778 const bool is_selected = (selection_mask & (1 << i)) != 0;
779 if (is_selected)
780 node_flags |= ImGuiTreeNodeFlags_Selected;
781 if (i < 3)
782 {
783 // Items 0..2 are Tree Node
784 bool node_open = ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Node %d", i);
786 node_clicked = i;
787 if (test_drag_and_drop && ImGui::BeginDragDropSource())
788 {
789 ImGui::SetDragDropPayload("_TREENODE", NULL, 0);
790 ImGui::Text("This is a drag and drop source");
792 }
793 if (node_open)
794 {
795 ImGui::BulletText("Blah blah\nBlah Blah");
797 }
798 }
799 else
800 {
801 // Items 3..5 are Tree Leaves
802 // The only reason we use TreeNode at all is to allow selection of the leaf. Otherwise we can
803 // use BulletText() or advance the cursor by GetTreeNodeToLabelSpacing() and call Text().
804 node_flags |= ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen; // ImGuiTreeNodeFlags_Bullet
805 ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Leaf %d", i);
807 node_clicked = i;
808 if (test_drag_and_drop && ImGui::BeginDragDropSource())
809 {
810 ImGui::SetDragDropPayload("_TREENODE", NULL, 0);
811 ImGui::Text("This is a drag and drop source");
813 }
814 }
815 }
816 if (node_clicked != -1)
817 {
818 // Update selection state
819 // (process outside of tree loop to avoid visual inconsistencies during the clicking frame)
820 if (ImGui::GetIO().KeyCtrl)
821 selection_mask ^= (1 << node_clicked); // CTRL+click to toggle
822 else //if (!(selection_mask & (1 << node_clicked))) // Depending on selection behavior you want, may want to preserve selection when clicking on item that is part of the selection
823 selection_mask = (1 << node_clicked); // Click to single-select
824 }
825 if (align_label_with_current_x_position)
828 }
830 }
831
832 if (ImGui::TreeNode("Collapsing Headers"))
833 {
834 static bool closable_group = true;
835 ImGui::Checkbox("Show 2nd header", &closable_group);
837 {
838 ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered());
839 for (int i = 0; i < 5; i++)
840 ImGui::Text("Some content %d", i);
841 }
842 if (ImGui::CollapsingHeader("Header with a close button", &closable_group))
843 {
844 ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered());
845 for (int i = 0; i < 5; i++)
846 ImGui::Text("More content %d", i);
847 }
848 /*
849 if (ImGui::CollapsingHeader("Header with a bullet", ImGuiTreeNodeFlags_Bullet))
850 ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered());
851 */
853 }
854
855 if (ImGui::TreeNode("Bullets"))
856 {
857 ImGui::BulletText("Bullet point 1");
858 ImGui::BulletText("Bullet point 2\nOn multiple lines");
859 if (ImGui::TreeNode("Tree node"))
860 {
861 ImGui::BulletText("Another bullet point");
863 }
864 ImGui::Bullet(); ImGui::Text("Bullet point 3 (two calls)");
867 }
868
869 if (ImGui::TreeNode("Text"))
870 {
871 if (ImGui::TreeNode("Colorful Text"))
872 {
873 // Using shortcut. You can use PushStyleColor()/PopStyleColor() for more flexibility.
874 ImGui::TextColored(ImVec4(1.0f, 0.0f, 1.0f, 1.0f), "Pink");
875 ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Yellow");
876 ImGui::TextDisabled("Disabled");
877 ImGui::SameLine(); HelpMarker("The TextDisabled color is stored in ImGuiStyle.");
879 }
880
881 if (ImGui::TreeNode("Word Wrapping"))
882 {
883 // Using shortcut. You can use PushTextWrapPos()/PopTextWrapPos() for more flexibility.
885 "This text should automatically wrap on the edge of the window. The current implementation "
886 "for text wrapping follows simple rules suitable for English and possibly other languages.");
888
889 static float wrap_width = 200.0f;
890 ImGui::SliderFloat("Wrap width", &wrap_width, -20, 600, "%.0f");
891
893 for (int n = 0; n < 2; n++)
894 {
895 ImGui::Text("Test paragraph %d:", n);
897 ImVec2 marker_min = ImVec2(pos.x + wrap_width, pos.y);
898 ImVec2 marker_max = ImVec2(pos.x + wrap_width + 10, pos.y + ImGui::GetTextLineHeight());
900 if (n == 0)
901 ImGui::Text("The lazy dog is a good dog. This paragraph should fit within %.0f pixels. Testing a 1 character word. The quick brown fox jumps over the lazy dog.", wrap_width);
902 else
903 ImGui::Text("aaaaaaaa bbbbbbbb, c cccccccc,dddddddd. d eeeeeeee ffffffff. gggggggg!hhhhhhhh");
904
905 // Draw actual text bounding box, following by marker of our expected limit (should not overlap!)
906 draw_list->AddRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(255, 255, 0, 255));
907 draw_list->AddRectFilled(marker_min, marker_max, IM_COL32(255, 0, 255, 255));
909 }
910
912 }
913
914 if (ImGui::TreeNode("UTF-8 Text"))
915 {
916 // UTF-8 test with Japanese characters
917 // (Needs a suitable font? Try "Google Noto" or "Arial Unicode". See docs/FONTS.md for details.)
918 // - From C++11 you can use the u8"my text" syntax to encode literal strings as UTF-8
919 // - For earlier compiler, you may be able to encode your sources as UTF-8 (e.g. in Visual Studio, you
920 // can save your source files as 'UTF-8 without signature').
921 // - FOR THIS DEMO FILE ONLY, BECAUSE WE WANT TO SUPPORT OLD COMPILERS, WE ARE *NOT* INCLUDING RAW UTF-8
922 // CHARACTERS IN THIS SOURCE FILE. Instead we are encoding a few strings with hexadecimal constants.
923 // Don't do this in your application! Please use u8"text in any language" in your application!
924 // Note that characters values are preserved even by InputText() if the font cannot be displayed,
925 // so you can safely copy & paste garbled characters into another application.
927 "CJK text will only appears if the font was loaded with the appropriate CJK character ranges. "
928 "Call io.Fonts->AddFontFromFileTTF() manually to load extra character ranges. "
929 "Read docs/FONTS.md for details.");
930 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.
931 ImGui::Text("Kanjis: \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e (nihongo)");
932 static char buf[32] = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e";
933 //static char buf[32] = u8"NIHONGO"; // <- this is how you would write it with C++11, using real kanjis
934 ImGui::InputText("UTF-8 input", buf, IM_ARRAYSIZE(buf));
936 }
938 }
939
940 if (ImGui::TreeNode("Images"))
941 {
942 ImGuiIO& io = ImGui::GetIO();
944 "Below we are displaying the font texture (which is the only texture we have access to in this demo). "
945 "Use the 'ImTextureID' type as storage to pass pointers or identifier to your own texture data. "
946 "Hover the texture for a zoomed view!");
947
948 // Below we are displaying the font texture because it is the only texture we have access to inside the demo!
949 // Remember that ImTextureID is just storage for whatever you want it to be. It is essentially a value that
950 // will be passed to the rendering backend via the ImDrawCmd structure.
951 // If you use one of the default imgui_impl_XXXX.cpp rendering backend, they all have comments at the top
952 // of their respective source file to specify what they expect to be stored in ImTextureID, for example:
953 // - The imgui_impl_dx11.cpp renderer expect a 'ID3D11ShaderResourceView*' pointer
954 // - The imgui_impl_opengl3.cpp renderer expect a GLuint OpenGL texture identifier, etc.
955 // More:
956 // - If you decided that ImTextureID = MyEngineTexture*, then you can pass your MyEngineTexture* pointers
957 // to ImGui::Image(), and gather width/height through your own functions, etc.
958 // - You can use ShowMetricsWindow() to inspect the draw data that are being passed to your renderer,
959 // it will help you debug issues if you are confused about it.
960 // - Consider using the lower-level ImDrawList::AddImage() API, via ImGui::GetWindowDrawList()->AddImage().
961 // - Read https://github.com/ocornut/imgui/blob/master/docs/FAQ.md
962 // - Read https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples
963 ImTextureID my_tex_id = io.Fonts->TexID;
964 float my_tex_w = (float)io.Fonts->TexWidth;
965 float my_tex_h = (float)io.Fonts->TexHeight;
966 {
967 ImGui::Text("%.0fx%.0f", my_tex_w, my_tex_h);
969 ImVec2 uv_min = ImVec2(0.0f, 0.0f); // Top-left
970 ImVec2 uv_max = ImVec2(1.0f, 1.0f); // Lower-right
971 ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint
972 ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f); // 50% opaque white
973 ImGui::Image(my_tex_id, ImVec2(my_tex_w, my_tex_h), uv_min, uv_max, tint_col, border_col);
975 {
977 float region_sz = 32.0f;
978 float region_x = io.MousePos.x - pos.x - region_sz * 0.5f;
979 float region_y = io.MousePos.y - pos.y - region_sz * 0.5f;
980 float zoom = 4.0f;
981 if (region_x < 0.0f) { region_x = 0.0f; }
982 else if (region_x > my_tex_w - region_sz) { region_x = my_tex_w - region_sz; }
983 if (region_y < 0.0f) { region_y = 0.0f; }
984 else if (region_y > my_tex_h - region_sz) { region_y = my_tex_h - region_sz; }
985 ImGui::Text("Min: (%.2f, %.2f)", region_x, region_y);
986 ImGui::Text("Max: (%.2f, %.2f)", region_x + region_sz, region_y + region_sz);
987 ImVec2 uv0 = ImVec2((region_x) / my_tex_w, (region_y) / my_tex_h);
988 ImVec2 uv1 = ImVec2((region_x + region_sz) / my_tex_w, (region_y + region_sz) / my_tex_h);
989 ImGui::Image(my_tex_id, ImVec2(region_sz * zoom, region_sz * zoom), uv0, uv1, tint_col, border_col);
991 }
992 }
993 ImGui::TextWrapped("And now some textured buttons..");
994 static int pressed_count = 0;
995 for (int i = 0; i < 8; i++)
996 {
997 ImGui::PushID(i);
998 int frame_padding = -1 + i; // -1 == uses default padding (style.FramePadding)
999 ImVec2 size = ImVec2(32.0f, 32.0f); // Size of the image we want to make visible
1000 ImVec2 uv0 = ImVec2(0.0f, 0.0f); // UV coordinates for lower-left
1001 ImVec2 uv1 = ImVec2(32.0f / my_tex_w, 32.0f / my_tex_h);// UV coordinates for (32,32) in our texture
1002 ImVec4 bg_col = ImVec4(0.0f, 0.0f, 0.0f, 1.0f); // Black background
1003 ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint
1004 if (ImGui::ImageButton(my_tex_id, size, uv0, uv1, frame_padding, bg_col, tint_col))
1005 pressed_count += 1;
1006 ImGui::PopID();
1008 }
1010 ImGui::Text("Pressed %d times.", pressed_count);
1012 }
1013
1014 if (ImGui::TreeNode("Combo"))
1015 {
1016 // Expose flags as checkbox for the demo
1017 static ImGuiComboFlags flags = 0;
1018 ImGui::CheckboxFlags("ImGuiComboFlags_PopupAlignLeft", &flags, ImGuiComboFlags_PopupAlignLeft);
1019 ImGui::SameLine(); HelpMarker("Only makes a difference if the popup is larger than the combo");
1020 if (ImGui::CheckboxFlags("ImGuiComboFlags_NoArrowButton", &flags, ImGuiComboFlags_NoArrowButton))
1021 flags &= ~ImGuiComboFlags_NoPreview; // Clear the other flag, as we cannot combine both
1022 if (ImGui::CheckboxFlags("ImGuiComboFlags_NoPreview", &flags, ImGuiComboFlags_NoPreview))
1023 flags &= ~ImGuiComboFlags_NoArrowButton; // Clear the other flag, as we cannot combine both
1024
1025 // Using the generic BeginCombo() API, you have full control over how to display the combo contents.
1026 // (your selection data could be an index, a pointer to the object, an id for the object, a flag intrusively
1027 // stored in the object itself, etc.)
1028 const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO" };
1029 static int item_current_idx = 0; // Here we store our selection data as an index.
1030 const char* combo_label = items[item_current_idx]; // Label to preview before opening the combo (technically it could be anything)
1031 if (ImGui::BeginCombo("combo 1", combo_label, flags))
1032 {
1033 for (int n = 0; n < IM_ARRAYSIZE(items); n++)
1034 {
1035 const bool is_selected = (item_current_idx == n);
1036 if (ImGui::Selectable(items[n], is_selected))
1037 item_current_idx = n;
1038
1039 // Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
1040 if (is_selected)
1042 }
1044 }
1045
1046 // Simplified one-liner Combo() API, using values packed in a single constant string
1047 static int item_current_2 = 0;
1048 ImGui::Combo("combo 2 (one-liner)", &item_current_2, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0");
1049
1050 // Simplified one-liner Combo() using an array of const char*
1051 static int item_current_3 = -1; // If the selection isn't within 0..count, Combo won't display a preview
1052 ImGui::Combo("combo 3 (array)", &item_current_3, items, IM_ARRAYSIZE(items));
1053
1054 // Simplified one-liner Combo() using an accessor function
1055 struct Funcs { static bool ItemGetter(void* data, int n, const char** out_str) { *out_str = ((const char**)data)[n]; return true; } };
1056 static int item_current_4 = 0;
1057 ImGui::Combo("combo 4 (function)", &item_current_4, &Funcs::ItemGetter, items, IM_ARRAYSIZE(items));
1058
1060 }
1061
1062 if (ImGui::TreeNode("List boxes"))
1063 {
1064 // Using the generic BeginListBox() API, you have full control over how to display the combo contents.
1065 // (your selection data could be an index, a pointer to the object, an id for the object, a flag intrusively
1066 // stored in the object itself, etc.)
1067 const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO" };
1068 static int item_current_idx = 0; // Here we store our selection data as an index.
1069 if (ImGui::BeginListBox("listbox 1"))
1070 {
1071 for (int n = 0; n < IM_ARRAYSIZE(items); n++)
1072 {
1073 const bool is_selected = (item_current_idx == n);
1074 if (ImGui::Selectable(items[n], is_selected))
1075 item_current_idx = n;
1076
1077 // Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
1078 if (is_selected)
1080 }
1082 }
1083
1084 // Custom size: use all width, 5 items tall
1085 ImGui::Text("Full-width:");
1086 if (ImGui::BeginListBox("##listbox 2", ImVec2(-FLT_MIN, 5 * ImGui::GetTextLineHeightWithSpacing())))
1087 {
1088 for (int n = 0; n < IM_ARRAYSIZE(items); n++)
1089 {
1090 const bool is_selected = (item_current_idx == n);
1091 if (ImGui::Selectable(items[n], is_selected))
1092 item_current_idx = n;
1093
1094 // Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
1095 if (is_selected)
1097 }
1099 }
1100
1102 }
1103
1104 if (ImGui::TreeNode("Selectables"))
1105 {
1106 // Selectable() has 2 overloads:
1107 // - The one taking "bool selected" as a read-only selection information.
1108 // When Selectable() has been clicked it returns true and you can alter selection state accordingly.
1109 // - The one taking "bool* p_selected" as a read-write selection information (convenient in some cases)
1110 // The earlier is more flexible, as in real application your selection may be stored in many different ways
1111 // and not necessarily inside a bool value (e.g. in flags within objects, as an external list, etc).
1112 if (ImGui::TreeNode("Basic"))
1113 {
1114 static bool selection[5] = { false, true, false, false, false };
1115 ImGui::Selectable("1. I am selectable", &selection[0]);
1116 ImGui::Selectable("2. I am selectable", &selection[1]);
1117 ImGui::Text("3. I am not selectable");
1118 ImGui::Selectable("4. I am selectable", &selection[3]);
1119 if (ImGui::Selectable("5. I am double clickable", selection[4], ImGuiSelectableFlags_AllowDoubleClick))
1121 selection[4] = !selection[4];
1123 }
1124 if (ImGui::TreeNode("Selection State: Single Selection"))
1125 {
1126 static int selected = -1;
1127 for (int n = 0; n < 5; n++)
1128 {
1129 char buf[32];
1130 sprintf(buf, "Object %d", n);
1131 if (ImGui::Selectable(buf, selected == n))
1132 selected = n;
1133 }
1135 }
1136 if (ImGui::TreeNode("Selection State: Multiple Selection"))
1137 {
1138 HelpMarker("Hold CTRL and click to select multiple items.");
1139 static bool selection[5] = { false, false, false, false, false };
1140 for (int n = 0; n < 5; n++)
1141 {
1142 char buf[32];
1143 sprintf(buf, "Object %d", n);
1144 if (ImGui::Selectable(buf, selection[n]))
1145 {
1146 if (!ImGui::GetIO().KeyCtrl) // Clear selection when CTRL is not held
1147 memset(selection, 0, sizeof(selection));
1148 selection[n] ^= 1;
1149 }
1150 }
1152 }
1153 if (ImGui::TreeNode("Rendering more text into the same line"))
1154 {
1155 // Using the Selectable() override that takes "bool* p_selected" parameter,
1156 // this function toggle your bool value automatically.
1157 static bool selected[3] = { false, false, false };
1158 ImGui::Selectable("main.c", &selected[0]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
1159 ImGui::Selectable("Hello.cpp", &selected[1]); ImGui::SameLine(300); ImGui::Text("12,345 bytes");
1160 ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
1162 }
1163 if (ImGui::TreeNode("In columns"))
1164 {
1165 static bool selected[10] = {};
1166
1168 {
1169 for (int i = 0; i < 10; i++)
1170 {
1171 char label[32];
1172 sprintf(label, "Item %d", i);
1174 ImGui::Selectable(label, &selected[i]); // FIXME-TABLE: Selection overlap
1175 }
1177 }
1180 {
1181 for (int i = 0; i < 10; i++)
1182 {
1183 char label[32];
1184 sprintf(label, "Item %d", i);
1189 ImGui::Text("Some other contents");
1191 ImGui::Text("123456");
1192 }
1194 }
1196 }
1197 if (ImGui::TreeNode("Grid"))
1198 {
1199 static char selected[4][4] = { { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } };
1200
1201 // Add in a bit of silly fun...
1202 const float time = (float)ImGui::GetTime();
1203 const bool winning_state = memchr(selected, 0, sizeof(selected)) == NULL; // If all cells are selected...
1204 if (winning_state)
1205 ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, ImVec2(0.5f + 0.5f * cosf(time * 2.0f), 0.5f + 0.5f * sinf(time * 3.0f)));
1206
1207 for (int y = 0; y < 4; y++)
1208 for (int x = 0; x < 4; x++)
1209 {
1210 if (x > 0)
1212 ImGui::PushID(y * 4 + x);
1213 if (ImGui::Selectable("Sailor", selected[y][x] != 0, 0, ImVec2(50, 50)))
1214 {
1215 // Toggle clicked cell + toggle neighbors
1216 selected[y][x] ^= 1;
1217 if (x > 0) { selected[y][x - 1] ^= 1; }
1218 if (x < 3) { selected[y][x + 1] ^= 1; }
1219 if (y > 0) { selected[y - 1][x] ^= 1; }
1220 if (y < 3) { selected[y + 1][x] ^= 1; }
1221 }
1222 ImGui::PopID();
1223 }
1224
1225 if (winning_state)
1228 }
1229 if (ImGui::TreeNode("Alignment"))
1230 {
1231 HelpMarker(
1232 "By default, Selectables uses style.SelectableTextAlign but it can be overridden on a per-item "
1233 "basis using PushStyleVar(). You'll probably want to always keep your default situation to "
1234 "left-align otherwise it becomes difficult to layout multiple items on a same line");
1235 static bool selected[3 * 3] = { true, false, true, false, true, false, true, false, true };
1236 for (int y = 0; y < 3; y++)
1237 {
1238 for (int x = 0; x < 3; x++)
1239 {
1240 ImVec2 alignment = ImVec2((float)x / 2.0f, (float)y / 2.0f);
1241 char name[32];
1242 sprintf(name, "(%.1f,%.1f)", alignment.x, alignment.y);
1243 if (x > 0) ImGui::SameLine();
1245 ImGui::Selectable(name, &selected[3 * y + x], ImGuiSelectableFlags_None, ImVec2(80, 80));
1247 }
1248 }
1250 }
1252 }
1253
1254 // To wire InputText() with std::string or any other custom string type,
1255 // see the "Text Input > Resize Callback" section of this demo, and the misc/cpp/imgui_stdlib.h file.
1256 if (ImGui::TreeNode("Text Input"))
1257 {
1258 if (ImGui::TreeNode("Multi-line Text Input"))
1259 {
1260 // Note: we are using a fixed-sized buffer for simplicity here. See ImGuiInputTextFlags_CallbackResize
1261 // and the code in misc/cpp/imgui_stdlib.h for how to setup InputText() for dynamically resizing strings.
1262 static char text[1024 * 16] =
1263 "/*\n"
1264 " The Pentium F00F bug, shorthand for F0 0F C7 C8,\n"
1265 " the hexadecimal encoding of one offending instruction,\n"
1266 " more formally, the invalid operand with locked CMPXCHG8B\n"
1267 " instruction bug, is a design flaw in the majority of\n"
1268 " Intel Pentium, Pentium MMX, and Pentium OverDrive\n"
1269 " processors (all in the P5 microarchitecture).\n"
1270 "*/\n\n"
1271 "label:\n"
1272 "\tlock cmpxchg8b eax\n";
1273
1275 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 <string> in here)");
1276 ImGui::CheckboxFlags("ImGuiInputTextFlags_ReadOnly", &flags, ImGuiInputTextFlags_ReadOnly);
1277 ImGui::CheckboxFlags("ImGuiInputTextFlags_AllowTabInput", &flags, ImGuiInputTextFlags_AllowTabInput);
1278 ImGui::CheckboxFlags("ImGuiInputTextFlags_CtrlEnterForNewLine", &flags, ImGuiInputTextFlags_CtrlEnterForNewLine);
1279 ImGui::InputTextMultiline("##source", text, IM_ARRAYSIZE(text), ImVec2(-FLT_MIN, ImGui::GetTextLineHeight() * 16), flags);
1281 }
1282
1283 if (ImGui::TreeNode("Filtered Text Input"))
1284 {
1285 struct TextFilters
1286 {
1287 // Return 0 (pass) if the character is 'i' or 'm' or 'g' or 'u' or 'i'
1288 static int FilterImGuiLetters(ImGuiInputTextCallbackData* data)
1289 {
1290 if (data->EventChar < 256 && strchr("imgui", (char)data->EventChar))
1291 return 0;
1292 return 1;
1293 }
1294 };
1295
1296 static char buf1[64] = ""; ImGui::InputText("default", buf1, 64);
1297 static char buf2[64] = ""; ImGui::InputText("decimal", buf2, 64, ImGuiInputTextFlags_CharsDecimal);
1298 static char buf3[64] = ""; ImGui::InputText("hexadecimal", buf3, 64, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase);
1299 static char buf4[64] = ""; ImGui::InputText("uppercase", buf4, 64, ImGuiInputTextFlags_CharsUppercase);
1300 static char buf5[64] = ""; ImGui::InputText("no blank", buf5, 64, ImGuiInputTextFlags_CharsNoBlank);
1301 static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters);
1303 }
1304
1305 if (ImGui::TreeNode("Password Input"))
1306 {
1307 static char password[64] = "password123";
1308 ImGui::InputText("password", password, IM_ARRAYSIZE(password), ImGuiInputTextFlags_Password);
1309 ImGui::SameLine(); HelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n");
1310 ImGui::InputTextWithHint("password (w/ hint)", "<password>", password, IM_ARRAYSIZE(password), ImGuiInputTextFlags_Password);
1311 ImGui::InputText("password (clear)", password, IM_ARRAYSIZE(password));
1313 }
1314
1315 if (ImGui::TreeNode("Completion, History, Edit Callbacks"))
1316 {
1317 struct Funcs
1318 {
1319 static int MyCallback(ImGuiInputTextCallbackData* data)
1320 {
1322 {
1323 data->InsertChars(data->CursorPos, "..");
1324 }
1325 else if (data->EventFlag == ImGuiInputTextFlags_CallbackHistory)
1326 {
1327 if (data->EventKey == ImGuiKey_UpArrow)
1328 {
1329 data->DeleteChars(0, data->BufTextLen);
1330 data->InsertChars(0, "Pressed Up!");
1331 data->SelectAll();
1332 }
1333 else if (data->EventKey == ImGuiKey_DownArrow)
1334 {
1335 data->DeleteChars(0, data->BufTextLen);
1336 data->InsertChars(0, "Pressed Down!");
1337 data->SelectAll();
1338 }
1339 }
1340 else if (data->EventFlag == ImGuiInputTextFlags_CallbackEdit)
1341 {
1342 // Toggle casing of first character
1343 char c = data->Buf[0];
1344 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) data->Buf[0] ^= 32;
1345 data->BufDirty = true;
1346
1347 // Increment a counter
1348 int* p_int = (int*)data->UserData;
1349 *p_int = *p_int + 1;
1350 }
1351 return 0;
1352 }
1353 };
1354 static char buf1[64];
1355 ImGui::InputText("Completion", buf1, 64, ImGuiInputTextFlags_CallbackCompletion, Funcs::MyCallback);
1356 ImGui::SameLine(); HelpMarker("Here we append \"..\" each time Tab is pressed. See 'Examples>Console' for a more meaningful demonstration of using this callback.");
1357
1358 static char buf2[64];
1359 ImGui::InputText("History", buf2, 64, ImGuiInputTextFlags_CallbackHistory, Funcs::MyCallback);
1360 ImGui::SameLine(); HelpMarker("Here we replace and select text each time Up/Down are pressed. See 'Examples>Console' for a more meaningful demonstration of using this callback.");
1361
1362 static char buf3[64];
1363 static int edit_count = 0;
1364 ImGui::InputText("Edit", buf3, 64, ImGuiInputTextFlags_CallbackEdit, Funcs::MyCallback, (void*)&edit_count);
1365 ImGui::SameLine(); HelpMarker("Here we toggle the casing of the first character on every edits + count edits.");
1366 ImGui::SameLine(); ImGui::Text("(%d)", edit_count);
1367
1369 }
1370
1371 if (ImGui::TreeNode("Resize Callback"))
1372 {
1373 // To wire InputText() with std::string or any other custom string type,
1374 // you can use the ImGuiInputTextFlags_CallbackResize flag + create a custom ImGui::InputText() wrapper
1375 // using your preferred type. See misc/cpp/imgui_stdlib.h for an implementation of this using std::string.
1376 HelpMarker(
1377 "Using ImGuiInputTextFlags_CallbackResize to wire your custom string type to InputText().\n\n"
1378 "See misc/cpp/imgui_stdlib.h for an implementation of this for std::string.");
1379 struct Funcs
1380 {
1381 static int MyResizeCallback(ImGuiInputTextCallbackData* data)
1382 {
1383 if (data->EventFlag == ImGuiInputTextFlags_CallbackResize)
1384 {
1385 ImVector<char>* my_str = (ImVector<char>*)data->UserData;
1386 IM_ASSERT(my_str->begin() == data->Buf);
1387 my_str->resize(data->BufSize); // NB: On resizing calls, generally data->BufSize == data->BufTextLen + 1
1388 data->Buf = my_str->begin();
1389 }
1390 return 0;
1391 }
1392
1393 // Note: Because ImGui:: is a namespace you would typically add your own function into the namespace.
1394 // For example, you code may declare a function 'ImGui::InputText(const char* label, MyString* my_str)'
1395 static bool MyInputTextMultiline(const char* label, ImVector<char>* my_str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0)
1396 {
1398 return ImGui::InputTextMultiline(label, my_str->begin(), (size_t)my_str->size(), size, flags | ImGuiInputTextFlags_CallbackResize, Funcs::MyResizeCallback, (void*)my_str);
1399 }
1400 };
1401
1402 // For this demo we are using ImVector as a string container.
1403 // Note that because we need to store a terminating zero character, our size/capacity are 1 more
1404 // than usually reported by a typical string class.
1405 static ImVector<char> my_str;
1406 if (my_str.empty())
1407 my_str.push_back(0);
1408 Funcs::MyInputTextMultiline("##MyStr", &my_str, ImVec2(-FLT_MIN, ImGui::GetTextLineHeight() * 16));
1409 ImGui::Text("Data: %p\nSize: %d\nCapacity: %d", (void*)my_str.begin(), my_str.size(), my_str.capacity());
1411 }
1412
1414 }
1415
1416 // Tabs
1417 if (ImGui::TreeNode("Tabs"))
1418 {
1419 if (ImGui::TreeNode("Basic"))
1420 {
1422 if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
1423 {
1424 if (ImGui::BeginTabItem("Avocado"))
1425 {
1426 ImGui::Text("This is the Avocado tab!\nblah blah blah blah blah");
1428 }
1429 if (ImGui::BeginTabItem("Broccoli"))
1430 {
1431 ImGui::Text("This is the Broccoli tab!\nblah blah blah blah blah");
1433 }
1434 if (ImGui::BeginTabItem("Cucumber"))
1435 {
1436 ImGui::Text("This is the Cucumber tab!\nblah blah blah blah blah");
1438 }
1440 }
1443 }
1444
1445 if (ImGui::TreeNode("Advanced & Close Button"))
1446 {
1447 // Expose a couple of the available flags. In most cases you may just call BeginTabBar() with no flags (0).
1448 static ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_Reorderable;
1449 ImGui::CheckboxFlags("ImGuiTabBarFlags_Reorderable", &tab_bar_flags, ImGuiTabBarFlags_Reorderable);
1450 ImGui::CheckboxFlags("ImGuiTabBarFlags_AutoSelectNewTabs", &tab_bar_flags, ImGuiTabBarFlags_AutoSelectNewTabs);
1451 ImGui::CheckboxFlags("ImGuiTabBarFlags_TabListPopupButton", &tab_bar_flags, ImGuiTabBarFlags_TabListPopupButton);
1452 ImGui::CheckboxFlags("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton", &tab_bar_flags, ImGuiTabBarFlags_NoCloseWithMiddleMouseButton);
1453 if ((tab_bar_flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0)
1455 if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyResizeDown))
1457 if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyScroll))
1459
1460 // Tab Bar
1461 const char* names[4] = { "Artichoke", "Beetroot", "Celery", "Daikon" };
1462 static bool opened[4] = { true, true, true, true }; // Persistent user state
1463 for (int n = 0; n < IM_ARRAYSIZE(opened); n++)
1464 {
1465 if (n > 0) { ImGui::SameLine(); }
1466 ImGui::Checkbox(names[n], &opened[n]);
1467 }
1468
1469 // Passing a bool* to BeginTabItem() is similar to passing one to Begin():
1470 // the underlying bool will be set to false when the tab is closed.
1471 if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
1472 {
1473 for (int n = 0; n < IM_ARRAYSIZE(opened); n++)
1474 if (opened[n] && ImGui::BeginTabItem(names[n], &opened[n], ImGuiTabItemFlags_None))
1475 {
1476 ImGui::Text("This is the %s tab!", names[n]);
1477 if (n & 1)
1478 ImGui::Text("I am an odd tab.");
1480 }
1482 }
1485 }
1486
1487 if (ImGui::TreeNode("TabItemButton & Leading/Trailing flags"))
1488 {
1489 static ImVector<int> active_tabs;
1490 static int next_tab_id = 0;
1491 if (next_tab_id == 0) // Initialize with some default tabs
1492 for (int i = 0; i < 3; i++)
1493 active_tabs.push_back(next_tab_id++);
1494
1495 // TabItemButton() and Leading/Trailing flags are distinct features which we will demo together.
1496 // (It is possible to submit regular tabs with Leading/Trailing flags, or TabItemButton tabs without Leading/Trailing flags...
1497 // but they tend to make more sense together)
1498 static bool show_leading_button = true;
1499 static bool show_trailing_button = true;
1500 ImGui::Checkbox("Show Leading TabItemButton()", &show_leading_button);
1501 ImGui::Checkbox("Show Trailing TabItemButton()", &show_trailing_button);
1502
1503 // Expose some other flags which are useful to showcase how they interact with Leading/Trailing tabs
1505 ImGui::CheckboxFlags("ImGuiTabBarFlags_TabListPopupButton", &tab_bar_flags, ImGuiTabBarFlags_TabListPopupButton);
1506 if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyResizeDown))
1508 if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyScroll))
1510
1511 if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
1512 {
1513 // Demo a Leading TabItemButton(): click the "?" button to open a menu
1514 if (show_leading_button)
1516 ImGui::OpenPopup("MyHelpMenu");
1517 if (ImGui::BeginPopup("MyHelpMenu"))
1518 {
1519 ImGui::Selectable("Hello!");
1521 }
1522
1523 // Demo Trailing Tabs: click the "+" button to add a new tab (in your app you may want to use a font icon instead of the "+")
1524 // Note that we submit it before the regular tabs, but because of the ImGuiTabItemFlags_Trailing flag it will always appear at the end.
1525 if (show_trailing_button)
1527 active_tabs.push_back(next_tab_id++); // Add new tab
1528
1529 // Submit our regular tabs
1530 for (int n = 0; n < active_tabs.Size; )
1531 {
1532 bool open = true;
1533 char name[16];
1534 snprintf(name, IM_ARRAYSIZE(name), "%04d", active_tabs[n]);
1536 {
1537 ImGui::Text("This is the %s tab!", name);
1539 }
1540
1541 if (!open)
1542 active_tabs.erase(active_tabs.Data + n);
1543 else
1544 n++;
1545 }
1546
1548 }
1551 }
1553 }
1554
1555 // Plot/Graph widgets are not very good.
1556 // Consider writing your own, or using a third-party one, see:
1557 // - ImPlot https://github.com/epezent/implot
1558 // - others https://github.com/ocornut/imgui/wiki/Useful-Extensions
1559 if (ImGui::TreeNode("Plots Widgets"))
1560 {
1561 static bool animate = true;
1562 ImGui::Checkbox("Animate", &animate);
1563
1564 static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f };
1565 ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr));
1566
1567 // Fill an array of contiguous float values to plot
1568 // Tip: If your float aren't contiguous but part of a structure, you can pass a pointer to your first float
1569 // and the sizeof() of your structure in the "stride" parameter.
1570 static float values[90] = {};
1571 static int values_offset = 0;
1572 static double refresh_time = 0.0;
1573 if (!animate || refresh_time == 0.0)
1574 refresh_time = ImGui::GetTime();
1575 while (refresh_time < ImGui::GetTime()) // Create data at fixed 60 Hz rate for the demo
1576 {
1577 static float phase = 0.0f;
1578 values[values_offset] = cosf(phase);
1579 values_offset = (values_offset + 1) % IM_ARRAYSIZE(values);
1580 phase += 0.10f * values_offset;
1581 refresh_time += 1.0f / 60.0f;
1582 }
1583
1584 // Plots can display overlay texts
1585 // (in this example, we will display an average value)
1586 {
1587 float average = 0.0f;
1588 for (int n = 0; n < IM_ARRAYSIZE(values); n++)
1589 average += values[n];
1590 average /= (float)IM_ARRAYSIZE(values);
1591 char overlay[32];
1592 sprintf(overlay, "avg %f", average);
1593 ImGui::PlotLines("Lines", values, IM_ARRAYSIZE(values), values_offset, overlay, -1.0f, 1.0f, ImVec2(0, 80.0f));
1594 }
1595 ImGui::PlotHistogram("Histogram", arr, IM_ARRAYSIZE(arr), 0, NULL, 0.0f, 1.0f, ImVec2(0, 80.0f));
1596
1597 // Use functions to generate output
1598 // FIXME: This is rather awkward because current plot API only pass in indices.
1599 // We probably want an API passing floats and user provide sample rate/count.
1600 struct Funcs
1601 {
1602 static float Sin(void*, int i) { return sinf(i * 0.1f); }
1603 static float Saw(void*, int i) { return (i & 1) ? 1.0f : -1.0f; }
1604 };
1605 static int func_type = 0, display_count = 70;
1608 ImGui::Combo("func", &func_type, "Sin\0Saw\0");
1610 ImGui::SliderInt("Sample count", &display_count, 1, 400);
1611 float (*func)(void*, int) = (func_type == 0) ? Funcs::Sin : Funcs::Saw;
1612 ImGui::PlotLines("Lines", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0, 80));
1613 ImGui::PlotHistogram("Histogram", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0, 80));
1615
1616 // Animate a simple progress bar
1617 static float progress = 0.0f, progress_dir = 1.0f;
1618 if (animate)
1619 {
1620 progress += progress_dir * 0.4f * ImGui::GetIO().DeltaTime;
1621 if (progress >= +1.1f) { progress = +1.1f; progress_dir *= -1.0f; }
1622 if (progress <= -0.1f) { progress = -0.1f; progress_dir *= -1.0f; }
1623 }
1624
1625 // Typically we would use ImVec2(-1.0f,0.0f) or ImVec2(-FLT_MIN,0.0f) to use all available width,
1626 // or ImVec2(width,0.0f) for a specified width. ImVec2(0.0f,0.0f) uses ItemWidth.
1627 ImGui::ProgressBar(progress, ImVec2(0.0f, 0.0f));
1628 ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
1629 ImGui::Text("Progress Bar");
1630
1631 float progress_saturated = IM_CLAMP(progress, 0.0f, 1.0f);
1632 char buf[32];
1633 sprintf(buf, "%d/%d", (int)(progress_saturated * 1753), 1753);
1634 ImGui::ProgressBar(progress, ImVec2(0.f, 0.f), buf);
1636 }
1637
1638 if (ImGui::TreeNode("Color/Picker Widgets"))
1639 {
1640 static ImVec4 color = ImVec4(114.0f / 255.0f, 144.0f / 255.0f, 154.0f / 255.0f, 200.0f / 255.0f);
1641
1642 static bool alpha_preview = true;
1643 static bool alpha_half_preview = false;
1644 static bool drag_and_drop = true;
1645 static bool options_menu = true;
1646 static bool hdr = false;
1647 ImGui::Checkbox("With Alpha Preview", &alpha_preview);
1648 ImGui::Checkbox("With Half Alpha Preview", &alpha_half_preview);
1649 ImGui::Checkbox("With Drag and Drop", &drag_and_drop);
1650 ImGui::Checkbox("With Options Menu", &options_menu); ImGui::SameLine(); HelpMarker("Right-click on the individual color widget to show options.");
1651 ImGui::Checkbox("With HDR", &hdr); ImGui::SameLine(); HelpMarker("Currently all this does is to lift the 0..1 limits on dragging widgets.");
1652 ImGuiColorEditFlags misc_flags = (hdr ? ImGuiColorEditFlags_HDR : 0) | (drag_and_drop ? 0 : ImGuiColorEditFlags_NoDragDrop) | (alpha_half_preview ? ImGuiColorEditFlags_AlphaPreviewHalf : (alpha_preview ? ImGuiColorEditFlags_AlphaPreview : 0)) | (options_menu ? 0 : ImGuiColorEditFlags_NoOptions);
1653
1654 ImGui::Text("Color widget:");
1656 "Click on the color square to open a color picker.\n"
1657 "CTRL+click on individual component to input value.\n");
1658 ImGui::ColorEdit3("MyColor##1", (float*)&color, misc_flags);
1659
1660 ImGui::Text("Color widget HSV with Alpha:");
1661 ImGui::ColorEdit4("MyColor##2", (float*)&color, ImGuiColorEditFlags_DisplayHSV | misc_flags);
1662
1663 ImGui::Text("Color widget with Float Display:");
1664 ImGui::ColorEdit4("MyColor##2f", (float*)&color, ImGuiColorEditFlags_Float | misc_flags);
1665
1666 ImGui::Text("Color button with Picker:");
1668 "With the ImGuiColorEditFlags_NoInputs flag you can hide all the slider/text inputs.\n"
1669 "With the ImGuiColorEditFlags_NoLabel flag you can pass a non-empty label which will only "
1670 "be used for the tooltip and picker popup.");
1671 ImGui::ColorEdit4("MyColor##3", (float*)&color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | misc_flags);
1672
1673 ImGui::Text("Color button with Custom Picker Popup:");
1674
1675 // Generate a default palette. The palette will persist and can be edited.
1676 static bool saved_palette_init = true;
1677 static ImVec4 saved_palette[32] = {};
1678 if (saved_palette_init)
1679 {
1680 for (int n = 0; n < IM_ARRAYSIZE(saved_palette); n++)
1681 {
1682 ImGui::ColorConvertHSVtoRGB(n / 31.0f, 0.8f, 0.8f,
1683 saved_palette[n].x, saved_palette[n].y, saved_palette[n].z);
1684 saved_palette[n].w = 1.0f; // Alpha
1685 }
1686 saved_palette_init = false;
1687 }
1688
1689 static ImVec4 backup_color;
1690 bool open_popup = ImGui::ColorButton("MyColor##3b", color, misc_flags);
1691 ImGui::SameLine(0, ImGui::GetStyle().ItemInnerSpacing.x);
1692 open_popup |= ImGui::Button("Palette");
1693 if (open_popup)
1694 {
1695 ImGui::OpenPopup("mypicker");
1696 backup_color = color;
1697 }
1698 if (ImGui::BeginPopup("mypicker"))
1699 {
1700 ImGui::Text("MY CUSTOM COLOR PICKER WITH AN AMAZING PALETTE!");
1704
1705 ImGui::BeginGroup(); // Lock X position
1706 ImGui::Text("Current");
1708 ImGui::Text("Previous");
1710 color = backup_color;
1712 ImGui::Text("Palette");
1713 for (int n = 0; n < IM_ARRAYSIZE(saved_palette); n++)
1714 {
1715 ImGui::PushID(n);
1716 if ((n % 8) != 0)
1717 ImGui::SameLine(0.0f, ImGui::GetStyle().ItemSpacing.y);
1718
1720 if (ImGui::ColorButton("##palette", saved_palette[n], palette_button_flags, ImVec2(20, 20)))
1721 color = ImVec4(saved_palette[n].x, saved_palette[n].y, saved_palette[n].z, color.w); // Preserve alpha!
1722
1723 // Allow user to drop colors into each palette entry. Note that ColorButton() is already a
1724 // drag source by default, unless specifying the ImGuiColorEditFlags_NoDragDrop flag.
1726 {
1728 memcpy((float*)&saved_palette[n], payload->Data, sizeof(float) * 3);
1730 memcpy((float*)&saved_palette[n], payload->Data, sizeof(float) * 4);
1732 }
1733
1734 ImGui::PopID();
1735 }
1738 }
1739
1740 ImGui::Text("Color button only:");
1741 static bool no_border = false;
1742 ImGui::Checkbox("ImGuiColorEditFlags_NoBorder", &no_border);
1743 ImGui::ColorButton("MyColor##3c", *(ImVec4*)&color, misc_flags | (no_border ? ImGuiColorEditFlags_NoBorder : 0), ImVec2(80, 80));
1744
1745 ImGui::Text("Color picker:");
1746 static bool alpha = true;
1747 static bool alpha_bar = true;
1748 static bool side_preview = true;
1749 static bool ref_color = false;
1750 static ImVec4 ref_color_v(1.0f, 0.0f, 1.0f, 0.5f);
1751 static int display_mode = 0;
1752 static int picker_mode = 0;
1753 ImGui::Checkbox("With Alpha", &alpha);
1754 ImGui::Checkbox("With Alpha Bar", &alpha_bar);
1755 ImGui::Checkbox("With Side Preview", &side_preview);
1756 if (side_preview)
1757 {
1759 ImGui::Checkbox("With Ref Color", &ref_color);
1760 if (ref_color)
1761 {
1763 ImGui::ColorEdit4("##RefColor", &ref_color_v.x, ImGuiColorEditFlags_NoInputs | misc_flags);
1764 }
1765 }
1766 ImGui::Combo("Display Mode", &display_mode, "Auto/Current\0None\0RGB Only\0HSV Only\0Hex Only\0");
1768 "ColorEdit defaults to displaying RGB inputs if you don't specify a display mode, "
1769 "but the user can change it with a right-click.\n\nColorPicker defaults to displaying RGB+HSV+Hex "
1770 "if you don't specify a display mode.\n\nYou can change the defaults using SetColorEditOptions().");
1771 ImGui::Combo("Picker Mode", &picker_mode, "Auto/Current\0Hue bar + SV rect\0Hue wheel + SV triangle\0");
1772 ImGui::SameLine(); HelpMarker("User can right-click the picker to change mode.");
1773 ImGuiColorEditFlags flags = misc_flags;
1774 if (!alpha) flags |= ImGuiColorEditFlags_NoAlpha; // This is by default if you call ColorPicker3() instead of ColorPicker4()
1775 if (alpha_bar) flags |= ImGuiColorEditFlags_AlphaBar;
1776 if (!side_preview) flags |= ImGuiColorEditFlags_NoSidePreview;
1777 if (picker_mode == 1) flags |= ImGuiColorEditFlags_PickerHueBar;
1778 if (picker_mode == 2) flags |= ImGuiColorEditFlags_PickerHueWheel;
1779 if (display_mode == 1) flags |= ImGuiColorEditFlags_NoInputs; // Disable all RGB/HSV/Hex displays
1780 if (display_mode == 2) flags |= ImGuiColorEditFlags_DisplayRGB; // Override display mode
1781 if (display_mode == 3) flags |= ImGuiColorEditFlags_DisplayHSV;
1782 if (display_mode == 4) flags |= ImGuiColorEditFlags_DisplayHex;
1783 ImGui::ColorPicker4("MyColor##4", (float*)&color, flags, ref_color ? &ref_color_v.x : NULL);
1784
1785 ImGui::Text("Set defaults in code:");
1787 "SetColorEditOptions() is designed to allow you to set boot-time default.\n"
1788 "We don't have Push/Pop functions because you can force options on a per-widget basis if needed,"
1789 "and the user can change non-forced ones with the options menu.\nWe don't have a getter to avoid"
1790 "encouraging you to persistently save values that aren't forward-compatible.");
1791 if (ImGui::Button("Default: Uint8 + HSV + Hue Bar"))
1793 if (ImGui::Button("Default: Float + HDR + Hue Wheel"))
1795
1796 // HSV encoded support (to avoid RGB<>HSV round trips and singularities when S==0 or V==0)
1797 static ImVec4 color_hsv(0.23f, 1.0f, 1.0f, 1.0f); // Stored as HSV!
1799 ImGui::Text("HSV encoded colors");
1801 "By default, colors are given to ColorEdit and ColorPicker in RGB, but ImGuiColorEditFlags_InputHSV"
1802 "allows you to store colors as HSV and pass them to ColorEdit and ColorPicker as HSV. This comes with the"
1803 "added benefit that you can manipulate hue values with the picker even when saturation or value are zero.");
1804 ImGui::Text("Color widget with InputHSV:");
1807 ImGui::DragFloat4("Raw HSV values", (float*)&color_hsv, 0.01f, 0.0f, 1.0f);
1808
1810 }
1811
1812 if (ImGui::TreeNode("Drag/Slider Flags"))
1813 {
1814 // Demonstrate using advanced flags for DragXXX and SliderXXX functions. Note that the flags are the same!
1816 ImGui::CheckboxFlags("ImGuiSliderFlags_AlwaysClamp", &flags, ImGuiSliderFlags_AlwaysClamp);
1817 ImGui::SameLine(); HelpMarker("Always clamp value to min/max bounds (if any) when input manually with CTRL+Click.");
1818 ImGui::CheckboxFlags("ImGuiSliderFlags_Logarithmic", &flags, ImGuiSliderFlags_Logarithmic);
1819 ImGui::SameLine(); HelpMarker("Enable logarithmic editing (more precision for small values).");
1820 ImGui::CheckboxFlags("ImGuiSliderFlags_NoRoundToFormat", &flags, ImGuiSliderFlags_NoRoundToFormat);
1821 ImGui::SameLine(); HelpMarker("Disable rounding underlying value to match precision of the format string (e.g. %.3f values are rounded to those 3 digits).");
1822 ImGui::CheckboxFlags("ImGuiSliderFlags_NoInput", &flags, ImGuiSliderFlags_NoInput);
1823 ImGui::SameLine(); HelpMarker("Disable CTRL+Click or Enter key allowing to input text directly into the widget.");
1824
1825 // Drags
1826 static float drag_f = 0.5f;
1827 static int drag_i = 50;
1828 ImGui::Text("Underlying float value: %f", drag_f);
1829 ImGui::DragFloat("DragFloat (0 -> 1)", &drag_f, 0.005f, 0.0f, 1.0f, "%.3f", flags);
1830 ImGui::DragFloat("DragFloat (0 -> +inf)", &drag_f, 0.005f, 0.0f, FLT_MAX, "%.3f", flags);
1831 ImGui::DragFloat("DragFloat (-inf -> 1)", &drag_f, 0.005f, -FLT_MAX, 1.0f, "%.3f", flags);
1832 ImGui::DragFloat("DragFloat (-inf -> +inf)", &drag_f, 0.005f, -FLT_MAX, +FLT_MAX, "%.3f", flags);
1833 ImGui::DragInt("DragInt (0 -> 100)", &drag_i, 0.5f, 0, 100, "%d", flags);
1834
1835 // Sliders
1836 static float slider_f = 0.5f;
1837 static int slider_i = 50;
1838 ImGui::Text("Underlying float value: %f", slider_f);
1839 ImGui::SliderFloat("SliderFloat (0 -> 1)", &slider_f, 0.0f, 1.0f, "%.3f", flags);
1840 ImGui::SliderInt("SliderInt (0 -> 100)", &slider_i, 0, 100, "%d", flags);
1841
1843 }
1844
1845 if (ImGui::TreeNode("Range Widgets"))
1846 {
1847 static float begin = 10, end = 90;
1848 static int begin_i = 100, end_i = 1000;
1849 ImGui::DragFloatRange2("range float", &begin, &end, 0.25f, 0.0f, 100.0f, "Min: %.1f %%", "Max: %.1f %%", ImGuiSliderFlags_AlwaysClamp);
1850 ImGui::DragIntRange2("range int", &begin_i, &end_i, 5, 0, 1000, "Min: %d units", "Max: %d units");
1851 ImGui::DragIntRange2("range int (no bounds)", &begin_i, &end_i, 5, 0, 0, "Min: %d units", "Max: %d units");
1853 }
1854
1855 if (ImGui::TreeNode("Data Types"))
1856 {
1857 // DragScalar/InputScalar/SliderScalar functions allow various data types
1858 // - signed/unsigned
1859 // - 8/16/32/64-bits
1860 // - integer/float/double
1861 // To avoid polluting the public API with all possible combinations, we use the ImGuiDataType enum
1862 // to pass the type, and passing all arguments by pointer.
1863 // This is the reason the test code below creates local variables to hold "zero" "one" etc. for each types.
1864 // In practice, if you frequently use a given type that is not covered by the normal API entry points,
1865 // you can wrap it yourself inside a 1 line function which can take typed argument as value instead of void*,
1866 // and then pass their address to the generic function. For example:
1867 // bool MySliderU64(const char *label, u64* value, u64 min = 0, u64 max = 0, const char* format = "%lld")
1868 // {
1869 // return SliderScalar(label, ImGuiDataType_U64, value, &min, &max, format);
1870 // }
1871
1872 // Setup limits (as helper variables so we can take their address, as explained above)
1873 // Note: SliderScalar() functions have a maximum usable range of half the natural type maximum, hence the /2.
1874 #ifndef LLONG_MIN
1875 ImS64 LLONG_MIN = -9223372036854775807LL - 1;
1876 ImS64 LLONG_MAX = 9223372036854775807LL;
1877 ImU64 ULLONG_MAX = (2ULL * 9223372036854775807LL + 1);
1878 #endif
1879 const char s8_zero = 0, s8_one = 1, s8_fifty = 50, s8_min = -128, s8_max = 127;
1880 const ImU8 u8_zero = 0, u8_one = 1, u8_fifty = 50, u8_min = 0, u8_max = 255;
1881 const short s16_zero = 0, s16_one = 1, s16_fifty = 50, s16_min = -32768, s16_max = 32767;
1882 const ImU16 u16_zero = 0, u16_one = 1, u16_fifty = 50, u16_min = 0, u16_max = 65535;
1883 const ImS32 s32_zero = 0, s32_one = 1, s32_fifty = 50, s32_min = INT_MIN/2, s32_max = INT_MAX/2, s32_hi_a = INT_MAX/2 - 100, s32_hi_b = INT_MAX/2;
1884 const ImU32 u32_zero = 0, u32_one = 1, u32_fifty = 50, u32_min = 0, u32_max = UINT_MAX/2, u32_hi_a = UINT_MAX/2 - 100, u32_hi_b = UINT_MAX/2;
1885 const ImS64 s64_zero = 0, s64_one = 1, s64_fifty = 50, s64_min = LLONG_MIN/2, s64_max = LLONG_MAX/2, s64_hi_a = LLONG_MAX/2 - 100, s64_hi_b = LLONG_MAX/2;
1886 const ImU64 u64_zero = 0, u64_one = 1, u64_fifty = 50, u64_min = 0, u64_max = ULLONG_MAX/2, u64_hi_a = ULLONG_MAX/2 - 100, u64_hi_b = ULLONG_MAX/2;
1887 const float f32_zero = 0.f, f32_one = 1.f, f32_lo_a = -10000000000.0f, f32_hi_a = +10000000000.0f;
1888 const double f64_zero = 0., f64_one = 1., f64_lo_a = -1000000000000000.0, f64_hi_a = +1000000000000000.0;
1889
1890 // State
1891 static char s8_v = 127;
1892 static ImU8 u8_v = 255;
1893 static short s16_v = 32767;
1894 static ImU16 u16_v = 65535;
1895 static ImS32 s32_v = -1;
1896 static ImU32 u32_v = (ImU32)-1;
1897 static ImS64 s64_v = -1;
1898 static ImU64 u64_v = (ImU64)-1;
1899 static float f32_v = 0.123f;
1900 static double f64_v = 90000.01234567890123456789;
1901
1902 const float drag_speed = 0.2f;
1903 static bool drag_clamp = false;
1904 ImGui::Text("Drags:");
1905 ImGui::Checkbox("Clamp integers to 0..50", &drag_clamp);
1907 "As with every widgets in dear imgui, we never modify values unless there is a user interaction.\n"
1908 "You can override the clamping limits by using CTRL+Click to input a value.");
1909 ImGui::DragScalar("drag s8", ImGuiDataType_S8, &s8_v, drag_speed, drag_clamp ? &s8_zero : NULL, drag_clamp ? &s8_fifty : NULL);
1910 ImGui::DragScalar("drag u8", ImGuiDataType_U8, &u8_v, drag_speed, drag_clamp ? &u8_zero : NULL, drag_clamp ? &u8_fifty : NULL, "%u ms");
1911 ImGui::DragScalar("drag s16", ImGuiDataType_S16, &s16_v, drag_speed, drag_clamp ? &s16_zero : NULL, drag_clamp ? &s16_fifty : NULL);
1912 ImGui::DragScalar("drag u16", ImGuiDataType_U16, &u16_v, drag_speed, drag_clamp ? &u16_zero : NULL, drag_clamp ? &u16_fifty : NULL, "%u ms");
1913 ImGui::DragScalar("drag s32", ImGuiDataType_S32, &s32_v, drag_speed, drag_clamp ? &s32_zero : NULL, drag_clamp ? &s32_fifty : NULL);
1914 ImGui::DragScalar("drag u32", ImGuiDataType_U32, &u32_v, drag_speed, drag_clamp ? &u32_zero : NULL, drag_clamp ? &u32_fifty : NULL, "%u ms");
1915 ImGui::DragScalar("drag s64", ImGuiDataType_S64, &s64_v, drag_speed, drag_clamp ? &s64_zero : NULL, drag_clamp ? &s64_fifty : NULL);
1916 ImGui::DragScalar("drag u64", ImGuiDataType_U64, &u64_v, drag_speed, drag_clamp ? &u64_zero : NULL, drag_clamp ? &u64_fifty : NULL);
1917 ImGui::DragScalar("drag float", ImGuiDataType_Float, &f32_v, 0.005f, &f32_zero, &f32_one, "%f");
1918 ImGui::DragScalar("drag float log", ImGuiDataType_Float, &f32_v, 0.005f, &f32_zero, &f32_one, "%f", ImGuiSliderFlags_Logarithmic);
1919 ImGui::DragScalar("drag double", ImGuiDataType_Double, &f64_v, 0.0005f, &f64_zero, NULL, "%.10f grams");
1920 ImGui::DragScalar("drag double log",ImGuiDataType_Double, &f64_v, 0.0005f, &f64_zero, &f64_one, "0 < %.10f < 1", ImGuiSliderFlags_Logarithmic);
1921
1922 ImGui::Text("Sliders");
1923 ImGui::SliderScalar("slider s8 full", ImGuiDataType_S8, &s8_v, &s8_min, &s8_max, "%d");
1924 ImGui::SliderScalar("slider u8 full", ImGuiDataType_U8, &u8_v, &u8_min, &u8_max, "%u");
1925 ImGui::SliderScalar("slider s16 full", ImGuiDataType_S16, &s16_v, &s16_min, &s16_max, "%d");
1926 ImGui::SliderScalar("slider u16 full", ImGuiDataType_U16, &u16_v, &u16_min, &u16_max, "%u");
1927 ImGui::SliderScalar("slider s32 low", ImGuiDataType_S32, &s32_v, &s32_zero, &s32_fifty,"%d");
1928 ImGui::SliderScalar("slider s32 high", ImGuiDataType_S32, &s32_v, &s32_hi_a, &s32_hi_b, "%d");
1929 ImGui::SliderScalar("slider s32 full", ImGuiDataType_S32, &s32_v, &s32_min, &s32_max, "%d");
1930 ImGui::SliderScalar("slider u32 low", ImGuiDataType_U32, &u32_v, &u32_zero, &u32_fifty,"%u");
1931 ImGui::SliderScalar("slider u32 high", ImGuiDataType_U32, &u32_v, &u32_hi_a, &u32_hi_b, "%u");
1932 ImGui::SliderScalar("slider u32 full", ImGuiDataType_U32, &u32_v, &u32_min, &u32_max, "%u");
1933 ImGui::SliderScalar("slider s64 low", ImGuiDataType_S64, &s64_v, &s64_zero, &s64_fifty,"%" IM_PRId64);
1934 ImGui::SliderScalar("slider s64 high", ImGuiDataType_S64, &s64_v, &s64_hi_a, &s64_hi_b, "%" IM_PRId64);
1935 ImGui::SliderScalar("slider s64 full", ImGuiDataType_S64, &s64_v, &s64_min, &s64_max, "%" IM_PRId64);
1936 ImGui::SliderScalar("slider u64 low", ImGuiDataType_U64, &u64_v, &u64_zero, &u64_fifty,"%" IM_PRIu64 " ms");
1937 ImGui::SliderScalar("slider u64 high", ImGuiDataType_U64, &u64_v, &u64_hi_a, &u64_hi_b, "%" IM_PRIu64 " ms");
1938 ImGui::SliderScalar("slider u64 full", ImGuiDataType_U64, &u64_v, &u64_min, &u64_max, "%" IM_PRIu64 " ms");
1939 ImGui::SliderScalar("slider float low", ImGuiDataType_Float, &f32_v, &f32_zero, &f32_one);
1940 ImGui::SliderScalar("slider float low log", ImGuiDataType_Float, &f32_v, &f32_zero, &f32_one, "%.10f", ImGuiSliderFlags_Logarithmic);
1941 ImGui::SliderScalar("slider float high", ImGuiDataType_Float, &f32_v, &f32_lo_a, &f32_hi_a, "%e");
1942 ImGui::SliderScalar("slider double low", ImGuiDataType_Double, &f64_v, &f64_zero, &f64_one, "%.10f grams");
1943 ImGui::SliderScalar("slider double low log",ImGuiDataType_Double, &f64_v, &f64_zero, &f64_one, "%.10f", ImGuiSliderFlags_Logarithmic);
1944 ImGui::SliderScalar("slider double high", ImGuiDataType_Double, &f64_v, &f64_lo_a, &f64_hi_a, "%e grams");
1945
1946 ImGui::Text("Sliders (reverse)");
1947 ImGui::SliderScalar("slider s8 reverse", ImGuiDataType_S8, &s8_v, &s8_max, &s8_min, "%d");
1948 ImGui::SliderScalar("slider u8 reverse", ImGuiDataType_U8, &u8_v, &u8_max, &u8_min, "%u");
1949 ImGui::SliderScalar("slider s32 reverse", ImGuiDataType_S32, &s32_v, &s32_fifty, &s32_zero, "%d");
1950 ImGui::SliderScalar("slider u32 reverse", ImGuiDataType_U32, &u32_v, &u32_fifty, &u32_zero, "%u");
1951 ImGui::SliderScalar("slider s64 reverse", ImGuiDataType_S64, &s64_v, &s64_fifty, &s64_zero, "%" IM_PRId64);
1952 ImGui::SliderScalar("slider u64 reverse", ImGuiDataType_U64, &u64_v, &u64_fifty, &u64_zero, "%" IM_PRIu64 " ms");
1953
1954 static bool inputs_step = true;
1955 ImGui::Text("Inputs");
1956 ImGui::Checkbox("Show step buttons", &inputs_step);
1957 ImGui::InputScalar("input s8", ImGuiDataType_S8, &s8_v, inputs_step ? &s8_one : NULL, NULL, "%d");
1958 ImGui::InputScalar("input u8", ImGuiDataType_U8, &u8_v, inputs_step ? &u8_one : NULL, NULL, "%u");
1959 ImGui::InputScalar("input s16", ImGuiDataType_S16, &s16_v, inputs_step ? &s16_one : NULL, NULL, "%d");
1960 ImGui::InputScalar("input u16", ImGuiDataType_U16, &u16_v, inputs_step ? &u16_one : NULL, NULL, "%u");
1961 ImGui::InputScalar("input s32", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%d");
1962 ImGui::InputScalar("input s32 hex", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%08X", ImGuiInputTextFlags_CharsHexadecimal);
1963 ImGui::InputScalar("input u32", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%u");
1964 ImGui::InputScalar("input u32 hex", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%08X", ImGuiInputTextFlags_CharsHexadecimal);
1965 ImGui::InputScalar("input s64", ImGuiDataType_S64, &s64_v, inputs_step ? &s64_one : NULL);
1966 ImGui::InputScalar("input u64", ImGuiDataType_U64, &u64_v, inputs_step ? &u64_one : NULL);
1967 ImGui::InputScalar("input float", ImGuiDataType_Float, &f32_v, inputs_step ? &f32_one : NULL);
1968 ImGui::InputScalar("input double", ImGuiDataType_Double, &f64_v, inputs_step ? &f64_one : NULL);
1969
1971 }
1972
1973 if (ImGui::TreeNode("Multi-component Widgets"))
1974 {
1975 static float vec4f[4] = { 0.10f, 0.20f, 0.30f, 0.44f };
1976 static int vec4i[4] = { 1, 5, 100, 255 };
1977
1978 ImGui::InputFloat2("input float2", vec4f);
1979 ImGui::DragFloat2("drag float2", vec4f, 0.01f, 0.0f, 1.0f);
1980 ImGui::SliderFloat2("slider float2", vec4f, 0.0f, 1.0f);
1981 ImGui::InputInt2("input int2", vec4i);
1982 ImGui::DragInt2("drag int2", vec4i, 1, 0, 255);
1983 ImGui::SliderInt2("slider int2", vec4i, 0, 255);
1985
1986 ImGui::InputFloat3("input float3", vec4f);
1987 ImGui::DragFloat3("drag float3", vec4f, 0.01f, 0.0f, 1.0f);
1988 ImGui::SliderFloat3("slider float3", vec4f, 0.0f, 1.0f);
1989 ImGui::InputInt3("input int3", vec4i);
1990 ImGui::DragInt3("drag int3", vec4i, 1, 0, 255);
1991 ImGui::SliderInt3("slider int3", vec4i, 0, 255);
1993
1994 ImGui::InputFloat4("input float4", vec4f);
1995 ImGui::DragFloat4("drag float4", vec4f, 0.01f, 0.0f, 1.0f);
1996 ImGui::SliderFloat4("slider float4", vec4f, 0.0f, 1.0f);
1997 ImGui::InputInt4("input int4", vec4i);
1998 ImGui::DragInt4("drag int4", vec4i, 1, 0, 255);
1999 ImGui::SliderInt4("slider int4", vec4i, 0, 255);
2000
2002 }
2003
2004 if (ImGui::TreeNode("Vertical Sliders"))
2005 {
2006 const float spacing = 4;
2008
2009 static int int_value = 0;
2010 ImGui::VSliderInt("##int", ImVec2(18, 160), &int_value, 0, 5);
2012
2013 static float values[7] = { 0.0f, 0.60f, 0.35f, 0.9f, 0.70f, 0.20f, 0.0f };
2014 ImGui::PushID("set1");
2015 for (int i = 0; i < 7; i++)
2016 {
2017 if (i > 0) ImGui::SameLine();
2018 ImGui::PushID(i);
2023 ImGui::VSliderFloat("##v", ImVec2(18, 160), &values[i], 0.0f, 1.0f, "");
2025 ImGui::SetTooltip("%.3f", values[i]);
2027 ImGui::PopID();
2028 }
2029 ImGui::PopID();
2030
2032 ImGui::PushID("set2");
2033 static float values2[4] = { 0.20f, 0.80f, 0.40f, 0.25f };
2034 const int rows = 3;
2035 const ImVec2 small_slider_size(18, (float)(int)((160.0f - (rows - 1) * spacing) / rows));
2036 for (int nx = 0; nx < 4; nx++)
2037 {
2038 if (nx > 0) ImGui::SameLine();
2040 for (int ny = 0; ny < rows; ny++)
2041 {
2042 ImGui::PushID(nx * rows + ny);
2043 ImGui::VSliderFloat("##v", small_slider_size, &values2[nx], 0.0f, 1.0f, "");
2045 ImGui::SetTooltip("%.3f", values2[nx]);
2046 ImGui::PopID();
2047 }
2049 }
2050 ImGui::PopID();
2051
2053 ImGui::PushID("set3");
2054 for (int i = 0; i < 4; i++)
2055 {
2056 if (i > 0) ImGui::SameLine();
2057 ImGui::PushID(i);
2059 ImGui::VSliderFloat("##v", ImVec2(40, 160), &values[i], 0.0f, 1.0f, "%.2f\nsec");
2061 ImGui::PopID();
2062 }
2063 ImGui::PopID();
2066 }
2067
2068 if (ImGui::TreeNode("Drag and Drop"))
2069 {
2070 if (ImGui::TreeNode("Drag and drop in standard widgets"))
2071 {
2072 // ColorEdit widgets automatically act as drag source and drag target.
2073 // They are using standardized payload strings IMGUI_PAYLOAD_TYPE_COLOR_3F and IMGUI_PAYLOAD_TYPE_COLOR_4F
2074 // to allow your own widgets to use colors in their drag and drop interaction.
2075 // Also see 'Demo->Widgets->Color/Picker Widgets->Palette' demo.
2076 HelpMarker("You can drag from the color squares.");
2077 static float col1[3] = { 1.0f, 0.0f, 0.2f };
2078 static float col2[4] = { 0.4f, 0.7f, 0.0f, 0.5f };
2079 ImGui::ColorEdit3("color 1", col1);
2080 ImGui::ColorEdit4("color 2", col2);
2082 }
2083
2084 if (ImGui::TreeNode("Drag and drop to copy/swap items"))
2085 {
2086 enum Mode
2087 {
2088 Mode_Copy,
2089 Mode_Move,
2090 Mode_Swap
2091 };
2092 static int mode = 0;
2093 if (ImGui::RadioButton("Copy", mode == Mode_Copy)) { mode = Mode_Copy; } ImGui::SameLine();
2094 if (ImGui::RadioButton("Move", mode == Mode_Move)) { mode = Mode_Move; } ImGui::SameLine();
2095 if (ImGui::RadioButton("Swap", mode == Mode_Swap)) { mode = Mode_Swap; }
2096 static const char* names[9] =
2097 {
2098 "Bobby", "Beatrice", "Betty",
2099 "Brianna", "Barry", "Bernard",
2100 "Bibi", "Blaine", "Bryn"
2101 };
2102 for (int n = 0; n < IM_ARRAYSIZE(names); n++)
2103 {
2104 ImGui::PushID(n);
2105 if ((n % 3) != 0)
2107 ImGui::Button(names[n], ImVec2(60, 60));
2108
2109 // Our buttons are both drag sources and drag targets here!
2111 {
2112 // Set payload to carry the index of our item (could be anything)
2113 ImGui::SetDragDropPayload("DND_DEMO_CELL", &n, sizeof(int));
2114
2115 // Display preview (could be anything, e.g. when dragging an image we could decide to display
2116 // the filename and a small preview of the image, etc.)
2117 if (mode == Mode_Copy) { ImGui::Text("Copy %s", names[n]); }
2118 if (mode == Mode_Move) { ImGui::Text("Move %s", names[n]); }
2119 if (mode == Mode_Swap) { ImGui::Text("Swap %s", names[n]); }
2121 }
2123 {
2124 if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("DND_DEMO_CELL"))
2125 {
2126 IM_ASSERT(payload->DataSize == sizeof(int));
2127 int payload_n = *(const int*)payload->Data;
2128 if (mode == Mode_Copy)
2129 {
2130 names[n] = names[payload_n];
2131 }
2132 if (mode == Mode_Move)
2133 {
2134 names[n] = names[payload_n];
2135 names[payload_n] = "";
2136 }
2137 if (mode == Mode_Swap)
2138 {
2139 const char* tmp = names[n];
2140 names[n] = names[payload_n];
2141 names[payload_n] = tmp;
2142 }
2143 }
2145 }
2146 ImGui::PopID();
2147 }
2149 }
2150
2151 if (ImGui::TreeNode("Drag to reorder items (simple)"))
2152 {
2153 // Simple reordering
2154 HelpMarker(
2155 "We don't use the drag and drop api at all here! "
2156 "Instead we query when the item is held but not hovered, and order items accordingly.");
2157 static const char* item_names[] = { "Item One", "Item Two", "Item Three", "Item Four", "Item Five" };
2158 for (int n = 0; n < IM_ARRAYSIZE(item_names); n++)
2159 {
2160 const char* item = item_names[n];
2161 ImGui::Selectable(item);
2162
2164 {
2165 int n_next = n + (ImGui::GetMouseDragDelta(0).y < 0.f ? -1 : 1);
2166 if (n_next >= 0 && n_next < IM_ARRAYSIZE(item_names))
2167 {
2168 item_names[n] = item_names[n_next];
2169 item_names[n_next] = item;
2171 }
2172 }
2173 }
2175 }
2176
2178 }
2179
2180 if (ImGui::TreeNode("Querying Status (Edited/Active/Focused/Hovered etc.)"))
2181 {
2182 // Select an item type
2183 const char* item_names[] =
2184 {
2185 "Text", "Button", "Button (w/ repeat)", "Checkbox", "SliderFloat", "InputText", "InputFloat",
2186 "InputFloat3", "ColorEdit4", "MenuItem", "TreeNode", "TreeNode (w/ double-click)", "Combo", "ListBox"
2187 };
2188 static int item_type = 1;
2189 ImGui::Combo("Item Type", &item_type, item_names, IM_ARRAYSIZE(item_names), IM_ARRAYSIZE(item_names));
2191 HelpMarker("Testing how various types of items are interacting with the IsItemXXX functions. Note that the bool return value of most ImGui function is generally equivalent to calling ImGui::IsItemHovered().");
2192
2193 // Submit selected item item so we can query their status in the code following it.
2194 bool ret = false;
2195 static bool b = false;
2196 static float col4f[4] = { 1.0f, 0.5, 0.0f, 1.0f };
2197 static char str[16] = {};
2198 if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction
2199 if (item_type == 1) { ret = ImGui::Button("ITEM: Button"); } // Testing button
2200 if (item_type == 2) { ImGui::PushButtonRepeat(true); ret = ImGui::Button("ITEM: Button"); ImGui::PopButtonRepeat(); } // Testing button (with repeater)
2201 if (item_type == 3) { ret = ImGui::Checkbox("ITEM: Checkbox", &b); } // Testing checkbox
2202 if (item_type == 4) { ret = ImGui::SliderFloat("ITEM: SliderFloat", &col4f[0], 0.0f, 1.0f); } // Testing basic item
2203 if (item_type == 5) { ret = ImGui::InputText("ITEM: InputText", &str[0], IM_ARRAYSIZE(str)); } // Testing input text (which handles tabbing)
2204 if (item_type == 6) { ret = ImGui::InputFloat("ITEM: InputFloat", col4f, 1.0f); } // Testing +/- buttons on scalar input
2205 if (item_type == 7) { ret = ImGui::InputFloat3("ITEM: InputFloat3", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
2206 if (item_type == 8) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
2207 if (item_type == 9) { ret = ImGui::MenuItem("ITEM: MenuItem"); } // Testing menu item (they use ImGuiButtonFlags_PressedOnRelease button policy)
2208 if (item_type == 10){ ret = ImGui::TreeNode("ITEM: TreeNode"); if (ret) ImGui::TreePop(); } // Testing tree node
2209 if (item_type == 11){ ret = ImGui::TreeNodeEx("ITEM: TreeNode w/ ImGuiTreeNodeFlags_OpenOnDoubleClick", ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_NoTreePushOnOpen); } // Testing tree node with ImGuiButtonFlags_PressedOnDoubleClick button policy.
2210 if (item_type == 12){ const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::Combo("ITEM: Combo", &current, items, IM_ARRAYSIZE(items)); }
2211 if (item_type == 13){ const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", &current, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
2212
2213 // Display the values of IsItemHovered() and other common item state functions.
2214 // Note that the ImGuiHoveredFlags_XXX flags can be combined.
2215 // Because BulletText is an item itself and that would affect the output of IsItemXXX functions,
2216 // we query every state in a single call to avoid storing them and to simplify the code.
2218 "Return value = %d\n"
2219 "IsItemFocused() = %d\n"
2220 "IsItemHovered() = %d\n"
2221 "IsItemHovered(_AllowWhenBlockedByPopup) = %d\n"
2222 "IsItemHovered(_AllowWhenBlockedByActiveItem) = %d\n"
2223 "IsItemHovered(_AllowWhenOverlapped) = %d\n"
2224 "IsItemHovered(_RectOnly) = %d\n"
2225 "IsItemActive() = %d\n"
2226 "IsItemEdited() = %d\n"
2227 "IsItemActivated() = %d\n"
2228 "IsItemDeactivated() = %d\n"
2229 "IsItemDeactivatedAfterEdit() = %d\n"
2230 "IsItemVisible() = %d\n"
2231 "IsItemClicked() = %d\n"
2232 "IsItemToggledOpen() = %d\n"
2233 "GetItemRectMin() = (%.1f, %.1f)\n"
2234 "GetItemRectMax() = (%.1f, %.1f)\n"
2235 "GetItemRectSize() = (%.1f, %.1f)",
2236 ret,
2254 );
2255
2256 static bool embed_all_inside_a_child_window = false;
2257 ImGui::Checkbox("Embed everything inside a child window (for additional testing)", &embed_all_inside_a_child_window);
2258 if (embed_all_inside_a_child_window)
2259 ImGui::BeginChild("outer_child", ImVec2(0, ImGui::GetFontSize() * 20.0f), true);
2260
2261 // Testing IsWindowFocused() function with its various flags.
2262 // Note that the ImGuiFocusedFlags_XXX flags can be combined.
2264 "IsWindowFocused() = %d\n"
2265 "IsWindowFocused(_ChildWindows) = %d\n"
2266 "IsWindowFocused(_ChildWindows|_RootWindow) = %d\n"
2267 "IsWindowFocused(_RootWindow) = %d\n"
2268 "IsWindowFocused(_AnyWindow) = %d\n",
2274
2275 // Testing IsWindowHovered() function with its various flags.
2276 // Note that the ImGuiHoveredFlags_XXX flags can be combined.
2278 "IsWindowHovered() = %d\n"
2279 "IsWindowHovered(_AllowWhenBlockedByPopup) = %d\n"
2280 "IsWindowHovered(_AllowWhenBlockedByActiveItem) = %d\n"
2281 "IsWindowHovered(_ChildWindows) = %d\n"
2282 "IsWindowHovered(_ChildWindows|_RootWindow) = %d\n"
2283 "IsWindowHovered(_ChildWindows|_AllowWhenBlockedByPopup) = %d\n"
2284 "IsWindowHovered(_RootWindow) = %d\n"
2285 "IsWindowHovered(_AnyWindow) = %d\n",
2294
2295 ImGui::BeginChild("child", ImVec2(0, 50), true);
2296 ImGui::Text("This is another child window for testing the _ChildWindows flag.");
2298 if (embed_all_inside_a_child_window)
2300
2301 static char unused_str[] = "This widget is only here to be able to tab-out of the widgets above.";
2302 ImGui::InputText("unused", unused_str, IM_ARRAYSIZE(unused_str), ImGuiInputTextFlags_ReadOnly);
2303
2304 // Calling IsItemHovered() after begin returns the hovered status of the title bar.
2305 // This is useful in particular if you want to create a context menu associated to the title bar of a window.
2306 static bool test_window = false;
2307 ImGui::Checkbox("Hovered/Active tests after Begin() for title bar testing", &test_window);
2308 if (test_window)
2309 {
2310 ImGui::Begin("Title bar Hovered/Active tests", &test_window);
2311 if (ImGui::BeginPopupContextItem()) // <-- This is using IsItemHovered()
2312 {
2313 if (ImGui::MenuItem("Close")) { test_window = false; }
2315 }
2317 "IsItemHovered() after begin = %d (== is title bar hovered)\n"
2318 "IsItemActive() after begin = %d (== is window being clicked/moved)\n",
2320 ImGui::End();
2321 }
2322
2324 }
2325}
@ ImGuiFocusedFlags_RootWindow
Definition imgui.h:1231
@ ImGuiFocusedFlags_AnyWindow
Definition imgui.h:1232
@ ImGuiFocusedFlags_ChildWindows
Definition imgui.h:1230
int ImGuiTreeNodeFlags
Definition imgui.h:199
@ ImGuiDragDropFlags_None
Definition imgui.h:1257
@ ImGuiDataType_Float
Definition imgui.h:1287
@ ImGuiDataType_U32
Definition imgui.h:1284
@ ImGuiDataType_U16
Definition imgui.h:1282
@ ImGuiDataType_S8
Definition imgui.h:1279
@ ImGuiDataType_U64
Definition imgui.h:1286
@ ImGuiDataType_S32
Definition imgui.h:1283
@ ImGuiDataType_S16
Definition imgui.h:1281
@ ImGuiDataType_S64
Definition imgui.h:1285
@ ImGuiDataType_Double
Definition imgui.h:1288
@ ImGuiDataType_U8
Definition imgui.h:1280
@ ImGuiHoveredFlags_AllowWhenBlockedByActiveItem
Definition imgui.h:1247
@ ImGuiHoveredFlags_AllowWhenBlockedByPopup
Definition imgui.h:1245
@ ImGuiHoveredFlags_RectOnly
Definition imgui.h:1250
@ ImGuiHoveredFlags_ChildWindows
Definition imgui.h:1242
@ ImGuiHoveredFlags_RootWindow
Definition imgui.h:1243
@ ImGuiHoveredFlags_AnyWindow
Definition imgui.h:1244
@ ImGuiHoveredFlags_AllowWhenOverlapped
Definition imgui.h:1248
void * ImTextureID
Definition imgui.h:205
unsigned char ImU8
Definition imgui.h:225
int ImGuiSliderFlags
Definition imgui.h:193
@ ImGuiTabBarFlags_NoCloseWithMiddleMouseButton
Definition imgui.h:1060
@ ImGuiTabBarFlags_TabListPopupButton
Definition imgui.h:1059
@ ImGuiTabBarFlags_FittingPolicyDefault_
Definition imgui.h:1066
@ ImGuiTabBarFlags_FittingPolicyMask_
Definition imgui.h:1065
@ ImGuiTabBarFlags_None
Definition imgui.h:1056
@ ImGuiTabBarFlags_FittingPolicyScroll
Definition imgui.h:1064
@ ImGuiTabBarFlags_AutoSelectNewTabs
Definition imgui.h:1058
@ ImGuiTabBarFlags_FittingPolicyResizeDown
Definition imgui.h:1063
@ ImGuiTabBarFlags_Reorderable
Definition imgui.h:1057
@ ImGuiTabItemFlags_Trailing
Definition imgui.h:1080
@ ImGuiTabItemFlags_Leading
Definition imgui.h:1079
@ ImGuiTabItemFlags_NoTooltip
Definition imgui.h:1077
@ ImGuiTabItemFlags_None
Definition imgui.h:1072
int ImGuiTabBarFlags
Definition imgui.h:194
@ ImGuiStyleVar_GrabMinSize
Definition imgui.h:1498
@ ImGuiStyleVar_SelectableTextAlign
Definition imgui.h:1502
@ ImGuiSliderFlags_Logarithmic
Definition imgui.h:1571
@ ImGuiSliderFlags_None
Definition imgui.h:1569
@ ImGuiSliderFlags_NoRoundToFormat
Definition imgui.h:1572
@ ImGuiKey_DownArrow
Definition imgui.h:1318
@ ImGuiKey_UpArrow
Definition imgui.h:1317
unsigned long long ImU64
Definition imgui.h:239
int ImGuiColorEditFlags
Definition imgui.h:183
@ ImGuiInputTextFlags_CharsNoBlank
Definition imgui.h:959
@ ImGuiInputTextFlags_CallbackHistory
Definition imgui.h:963
@ ImGuiInputTextFlags_CallbackCharFilter
Definition imgui.h:965
@ ImGuiInputTextFlags_AllowTabInput
Definition imgui.h:966
@ ImGuiInputTextFlags_CharsHexadecimal
Definition imgui.h:957
@ ImGuiInputTextFlags_CharsDecimal
Definition imgui.h:956
@ ImGuiInputTextFlags_CallbackCompletion
Definition imgui.h:962
@ ImGuiInputTextFlags_Password
Definition imgui.h:971
@ ImGuiInputTextFlags_CtrlEnterForNewLine
Definition imgui.h:967
@ ImGuiInputTextFlags_ReadOnly
Definition imgui.h:970
@ ImGuiInputTextFlags_CharsUppercase
Definition imgui.h:958
@ ImGuiInputTextFlags_CallbackResize
Definition imgui.h:974
@ ImGuiInputTextFlags_CallbackEdit
Definition imgui.h:975
unsigned short ImU16
Definition imgui.h:227
int ImGuiInputTextFlags
Definition imgui.h:189
signed long long ImS64
Definition imgui.h:238
@ ImGuiCol_FrameBgHovered
Definition imgui.h:1421
@ ImGuiCol_FrameBgActive
Definition imgui.h:1422
@ ImGuiCol_SliderGrab
Definition imgui.h:1432
#define IMGUI_PAYLOAD_TYPE_COLOR_4F
Definition imgui.h:1274
int ImGuiComboFlags
Definition imgui.h:185
@ ImGuiComboFlags_NoPreview
Definition imgui.h:1049
@ ImGuiComboFlags_PopupAlignLeft
Definition imgui.h:1043
@ ImGuiComboFlags_NoArrowButton
Definition imgui.h:1048
@ ImGuiTreeNodeFlags_Selected
Definition imgui.h:987
@ ImGuiTreeNodeFlags_OpenOnArrow
Definition imgui.h:994
@ ImGuiTreeNodeFlags_OpenOnDoubleClick
Definition imgui.h:993
@ ImGuiTreeNodeFlags_SpanAvailWidth
Definition imgui.h:998
@ ImGuiTreeNodeFlags_None
Definition imgui.h:986
@ ImGuiSelectableFlags_AllowDoubleClick
Definition imgui.h:1034
@ ImGuiCond_Once
Definition imgui.h:1616
@ ImGuiDir_Right
Definition imgui.h:1297
@ ImGuiDir_Left
Definition imgui.h:1296
signed int ImS32
Definition imgui.h:228
@ ImGuiColorEditFlags_DisplayRGB
Definition imgui.h:1539
@ ImGuiColorEditFlags_AlphaPreview
Definition imgui.h:1536
@ ImGuiColorEditFlags_NoSmallPreview
Definition imgui.h:1526
@ ImGuiColorEditFlags_DisplayHex
Definition imgui.h:1541
@ ImGuiColorEditFlags_Uint8
Definition imgui.h:1542
@ ImGuiColorEditFlags_NoOptions
Definition imgui.h:1525
@ ImGuiColorEditFlags_NoAlpha
Definition imgui.h:1523
@ ImGuiColorEditFlags_NoPicker
Definition imgui.h:1524
@ ImGuiColorEditFlags_NoSidePreview
Definition imgui.h:1530
@ ImGuiColorEditFlags_NoLabel
Definition imgui.h:1529
@ ImGuiColorEditFlags_InputHSV
Definition imgui.h:1547
@ ImGuiColorEditFlags_NoBorder
Definition imgui.h:1532
@ ImGuiColorEditFlags_NoInputs
Definition imgui.h:1527
@ ImGuiColorEditFlags_PickerHueWheel
Definition imgui.h:1545
@ ImGuiColorEditFlags_AlphaPreviewHalf
Definition imgui.h:1537
@ ImGuiColorEditFlags_AlphaBar
Definition imgui.h:1535
@ ImGuiColorEditFlags_HDR
Definition imgui.h:1538
@ ImGuiColorEditFlags_NoDragDrop
Definition imgui.h:1531
@ ImGuiColorEditFlags_PickerHueBar
Definition imgui.h:1544
@ ImGuiColorEditFlags_NoTooltip
Definition imgui.h:1528
@ ImGuiColorEditFlags_DisplayHSV
Definition imgui.h:1540
@ ImGuiColorEditFlags_Float
Definition imgui.h:1543
#define IMGUI_PAYLOAD_TYPE_COLOR_3F
Definition imgui.h:1273
#define IM_CLAMP(V, MN, MX)
Definition imgui_demo.cpp:156
#define IM_PRId64
Definition imgui_demo.cpp:146
#define IM_PRIu64
Definition imgui_demo.cpp:147
IMGUI_API void EndDragDropSource()
Definition imgui.cpp:9889
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)
Definition imgui_widgets.cpp:3512
IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float &out_r, float &out_g, float &out_b)
Definition imgui.cpp:1843
IMGUI_API bool IsItemVisible()
Definition imgui.cpp:4917
IMGUI_API bool IsItemClicked(ImGuiMouseButton mouse_button=0)
Definition imgui.cpp:4882
IMGUI_API bool DragScalar(const char *label, ImGuiDataType data_type, void *p_data, float v_speed=1.0f, const void *p_min=NULL, const void *p_max=NULL, const char *format=NULL, ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:2307
IMGUI_API bool TabItemButton(const char *label, ImGuiTabItemFlags flags=0)
Definition imgui_widgets.cpp:7693
IMGUI_API bool DragIntRange2(const char *label, int *v_current_min, int *v_current_max, float v_speed=1.0f, int v_min=0, int v_max=0, const char *format="%d", const char *format_max=NULL, ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:2500
IMGUI_API void PlotLines(const char *label, const float *values, int values_count, int values_offset=0, const char *overlay_text=NULL, float scale_min=FLT_MAX, float scale_max=FLT_MAX, ImVec2 graph_size=ImVec2(0, 0), int stride=sizeof(float))
Definition imgui_widgets.cpp:6441
IMGUI_API bool IsItemToggledOpen()
Definition imgui.cpp:4887
IMGUI_API ImVec2 GetCursorPos()
Definition imgui.cpp:7493
IMGUI_API bool InputInt(const char *label, int *v, int step=1, int step_fast=100, ImGuiInputTextFlags flags=0)
Definition imgui_widgets.cpp:3469
IMGUI_API bool InputInt4(const char *label, int v[4], ImGuiInputTextFlags flags=0)
Definition imgui_widgets.cpp:3486
IMGUI_API bool VSliderInt(const char *label, const ImVec2 &size, int *v, int v_min, int v_max, const char *format="%d", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:3152
IMGUI_API double GetTime()
Definition imgui.cpp:3453
IMGUI_API void ProgressBar(float fraction, const ImVec2 &size_arg=ImVec2(-FLT_MIN, 0), const char *overlay=NULL)
Definition imgui_widgets.cpp:1240
IMGUI_API bool DragFloat4(const char *label, float v[4], float v_speed=1.0f, float v_min=0.0f, float v_max=0.0f, const char *format="%.3f", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:2441
IMGUI_API bool SetDragDropPayload(const char *type, const void *data, size_t sz, ImGuiCond cond=0)
Definition imgui.cpp:9905
IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags=0)
Definition imgui.cpp:6672
IMGUI_API bool DragInt2(const char *label, int v[2], float v_speed=1.0f, int v_min=0, int v_max=0, const char *format="%d", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:2484
IMGUI_API bool IsItemActivated()
Definition imgui.cpp:4842
IMGUI_API bool ColorEdit3(const char *label, float col[3], ImGuiColorEditFlags flags=0)
Definition imgui_widgets.cpp:4684
IMGUI_API float GetTreeNodeToLabelSpacing()
Definition imgui_widgets.cpp:5941
IMGUI_API bool DragInt4(const char *label, int v[4], float v_speed=1.0f, int v_min=0, int v_max=0, const char *format="%d", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:2494
IMGUI_API const ImGuiPayload * AcceptDragDropPayload(const char *type, ImGuiDragDropFlags flags=0)
Definition imgui.cpp:10008
IMGUI_API bool DragFloat3(const char *label, float v[3], float v_speed=1.0f, float v_min=0.0f, float v_max=0.0f, const char *format="%.3f", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:2436
IMGUI_API bool IsItemEdited()
Definition imgui.cpp:4923
IMGUI_API bool InputFloat4(const char *label, float v[4], const char *format="%.3f", ImGuiInputTextFlags flags=0)
Definition imgui_widgets.cpp:3464
IMGUI_API void ResetMouseDragDelta(ImGuiMouseButton button=0)
Definition imgui.cpp:4803
IMGUI_API void NewLine()
Definition imgui_widgets.cpp:1331
IMGUI_API bool ColorButton(const char *desc_id, const ImVec4 &col, ImGuiColorEditFlags flags=0, ImVec2 size=ImVec2(0, 0))
Definition imgui_widgets.cpp:5334
IMGUI_API bool InputInt2(const char *label, int v[2], ImGuiInputTextFlags flags=0)
Definition imgui_widgets.cpp:3476
IMGUI_API bool InputFloat2(const char *label, float v[2], const char *format="%.3f", ImGuiInputTextFlags flags=0)
Definition imgui_widgets.cpp:3454
IMGUI_API bool IsItemDeactivatedAfterEdit()
Definition imgui.cpp:4863
IMGUI_API bool InputFloat3(const char *label, float v[3], const char *format="%.3f", ImGuiInputTextFlags flags=0)
Definition imgui_widgets.cpp:3459
IMGUI_API bool VSliderFloat(const char *label, const ImVec2 &size, float *v, float v_min, float v_max, const char *format="%.3f", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:3147
IMGUI_API bool SliderInt2(const char *label, int v[2], int v_min, int v_max, const char *format="%d", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:3073
IMGUI_API bool SliderInt4(const char *label, int v[4], int v_min, int v_max, const char *format="%d", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:3083
IMGUI_API bool DragFloatRange2(const char *label, float *v_current_min, float *v_current_max, float v_speed=1.0f, float v_min=0.0f, float v_max=0.0f, const char *format="%.3f", const char *format_max=NULL, ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:2447
IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags=0)
Definition imgui.cpp:6633
IMGUI_API bool SliderInt3(const char *label, int v[3], int v_min, int v_max, const char *format="%d", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:3078
IMGUI_API bool InputInt3(const char *label, int v[3], ImGuiInputTextFlags flags=0)
Definition imgui_widgets.cpp:3481
IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags=0)
Definition imgui.cpp:9775
IMGUI_API bool BeginDragDropTarget()
Definition imgui.cpp:9975
IMGUI_API void SetColorEditOptions(ImGuiColorEditFlags flags)
Definition imgui_widgets.cpp:5418
IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2 &size, const ImVec2 &uv0=ImVec2(0, 0), const ImVec2 &uv1=ImVec2(1, 1), int frame_padding=-1, const ImVec4 &bg_col=ImVec4(0, 0, 0, 0), const ImVec4 &tint_col=ImVec4(1, 1, 1, 1))
Definition imgui_widgets.cpp:1055
IMGUI_API bool SliderAngle(const char *label, float *v_rad, float v_degrees_min=-360.0f, float v_degrees_max=+360.0f, const char *format="%.0f deg", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:3058
IMGUI_API bool SliderFloat4(const char *label, float v[4], float v_min, float v_max, const char *format="%.3f", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:3053
IMGUI_API bool ArrowButton(const char *str_id, ImGuiDir dir)
Definition imgui_widgets.cpp:785
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2 &size, const ImVec2 &uv0=ImVec2(0, 0), const ImVec2 &uv1=ImVec2(1, 1), const ImVec4 &tint_col=ImVec4(1, 1, 1, 1), const ImVec4 &border_col=ImVec4(0, 0, 0, 0))
Definition imgui_widgets.cpp:1000
IMGUI_API void LabelText(const char *label, const char *fmt,...) IM_FMTARGS(2)
Definition imgui_widgets.cpp:338
IMGUI_API bool InputDouble(const char *label, double *v, double step=0.0, double step_fast=0.0, const char *format="%.6f", ImGuiInputTextFlags flags=0)
Definition imgui_widgets.cpp:3491
IMGUI_API bool ColorPicker4(const char *label, float col[4], ImGuiColorEditFlags flags=0, const float *ref_col=NULL, const char *current_label=NULL, const char *original_label=NULL)
Definition imgui_widgets.cpp:4955
IMGUI_API bool IsItemFocused()
Definition imgui.cpp:4870
IMGUI_API void EndDragDropTarget()
Definition imgui.cpp:10058
IMGUI_API bool InputTextWithHint(const char *label, const char *hint, char *buf, size_t buf_size, ImGuiInputTextFlags flags=0, ImGuiInputTextCallback callback=NULL, void *user_data=NULL)
Definition imgui_widgets.cpp:3517
IMGUI_API bool DragInt3(const char *label, int v[3], float v_speed=1.0f, int v_min=0, int v_max=0, const char *format="%d", ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:2489
IMGUI_API bool InputScalar(const char *label, ImGuiDataType data_type, void *p_data, const void *p_step=NULL, const void *p_step_fast=NULL, const char *format=NULL, ImGuiInputTextFlags flags=0)
Definition imgui_widgets.cpp:3341
IMGUI_API bool SliderScalar(const char *label, ImGuiDataType data_type, void *p_data, const void *p_min, const void *p_max, const char *format=NULL, ImGuiSliderFlags flags=0)
Definition imgui_widgets.cpp:2922
Mode
Definition CustomGCode.hpp:48
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:14
double angle(const Eigen::MatrixBase< Derived > &v1, const Eigen::MatrixBase< Derived2 > &v2)
Definition Point.hpp:112
constexpr auto data(C &c) -> decltype(c.data())
Definition span.hpp:195
IGL_INLINE void mode(const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &X, const int d, Eigen::Matrix< T, Eigen::Dynamic, 1 > &M)
Definition mode.cpp:14
S::iterator begin(S &sh, const PathTag &)
Definition geometry_traits.hpp:614
S::iterator end(S &sh, const PathTag &)
Definition geometry_traits.hpp:620
size_t rows(const T &raster)
Definition MarchingSquares.hpp:55
bool check(const DataBase &input, bool check_fontfile=true, bool use_surface=false)
Assert check of inputs data.
Definition EmbossJob.cpp:348
IMGUI_API void AddRect(const ImVec2 &p_min, const ImVec2 &p_max, ImU32 col, float rounding=0.0f, ImDrawFlags flags=0, float thickness=1.0f)
Definition imgui_draw.cpp:1377
ImTextureID TexID
Definition imgui.h:2654
int TexWidth
Definition imgui.h:2664
ImFontAtlas * Fonts
Definition imgui.h:1795
Definition imgui.h:1917
Definition imgui.h:1957
float w
Definition imgui.h:259
T * erase(const T *it)
Definition imgui.h:1699
int size() const
Definition imgui.h:1671
bool empty() const
Definition imgui.h:1670
T * begin()
Definition imgui.h:1679
T * Data
Definition imgui.h:1657
int capacity() const
Definition imgui.h:1674
#define snprintf
Definition unistd.h:49

References ImGui::AcceptDragDropPayload(), ImDrawList::AddRect(), ImDrawList::AddRectFilled(), ImGui::AlignTextToFramePadding(), ImGui::ArrowButton(), ImVector< T >::begin(), ImGui::Begin(), ImGui::BeginChild(), ImGui::BeginCombo(), ImGui::BeginDragDropSource(), ImGui::BeginDragDropTarget(), ImGui::BeginGroup(), ImGui::BeginListBox(), ImGui::BeginPopup(), ImGui::BeginPopupContextItem(), ImGui::BeginTabBar(), ImGui::BeginTabItem(), ImGui::BeginTable(), ImGui::BeginTooltip(), ImGui::Bullet(), ImGui::BulletText(), ImGui::Button(), ImVector< T >::capacity(), ImGui::Checkbox(), ImGui::CheckboxFlags(), ImGui::CollapsingHeader(), ImGui::ColorButton(), ImGui::ColorConvertHSVtoRGB(), ImGui::ColorEdit3(), ImGui::ColorEdit4(), ImGui::ColorPicker4(), ImGui::Combo(), ImVector< T >::Data, ImGuiIO::DeltaTime, ImGui::DragFloat(), ImGui::DragFloat2(), ImGui::DragFloat3(), ImGui::DragFloat4(), ImGui::DragFloatRange2(), ImGui::DragInt(), ImGui::DragInt2(), ImGui::DragInt3(), ImGui::DragInt4(), ImGui::DragIntRange2(), ImGui::DragScalar(), ImVector< T >::empty(), ImGui::End(), ImGui::EndChild(), ImGui::EndCombo(), ImGui::EndDragDropSource(), ImGui::EndDragDropTarget(), ImGui::EndGroup(), ImGui::EndListBox(), ImGui::EndPopup(), ImGui::EndTabBar(), ImGui::EndTabItem(), ImGui::EndTable(), ImGui::EndTooltip(), ImVector< T >::erase(), ImGuiIO::Fonts, ImGui::GetCursorPos(), ImGui::GetCursorScreenPos(), ImGui::GetFontSize(), ImGui::GetIO(), ImGui::GetItemRectMax(), ImGui::GetItemRectMin(), ImGui::GetItemRectSize(), ImGui::GetMouseDragDelta(), ImGui::GetStyle(), ImGui::GetTextLineHeight(), ImGui::GetTextLineHeightWithSpacing(), ImGui::GetTime(), ImGui::GetTreeNodeToLabelSpacing(), ImGui::GetWindowDrawList(), HelpMarker(), ImColor::HSV(), IM_ARRAYSIZE, IM_ASSERT, IM_CLAMP, IM_COL32, IM_PRId64, IM_PRIu64, ImGui::Image(), ImGui::ImageButton(), IMGUI_PAYLOAD_TYPE_COLOR_3F, IMGUI_PAYLOAD_TYPE_COLOR_4F, ImGuiCol_Button, ImGuiCol_ButtonActive, ImGuiCol_ButtonHovered, ImGuiCol_FrameBg, ImGuiCol_FrameBgActive, ImGuiCol_FrameBgHovered, ImGuiCol_SliderGrab, ImGuiColorEditFlags_AlphaBar, ImGuiColorEditFlags_AlphaPreview, ImGuiColorEditFlags_AlphaPreviewHalf, ImGuiColorEditFlags_DisplayHex, ImGuiColorEditFlags_DisplayHSV, ImGuiColorEditFlags_DisplayRGB, ImGuiColorEditFlags_Float, ImGuiColorEditFlags_HDR, ImGuiColorEditFlags_InputHSV, ImGuiColorEditFlags_NoAlpha, ImGuiColorEditFlags_NoBorder, ImGuiColorEditFlags_NoDragDrop, ImGuiColorEditFlags_NoInputs, ImGuiColorEditFlags_NoLabel, ImGuiColorEditFlags_NoOptions, ImGuiColorEditFlags_NoPicker, ImGuiColorEditFlags_NoSidePreview, ImGuiColorEditFlags_NoSmallPreview, ImGuiColorEditFlags_NoTooltip, ImGuiColorEditFlags_PickerHueBar, ImGuiColorEditFlags_PickerHueWheel, ImGuiColorEditFlags_Uint8, ImGuiComboFlags_NoArrowButton, ImGuiComboFlags_NoPreview, ImGuiComboFlags_PopupAlignLeft, ImGuiCond_Once, ImGuiDataType_Double, ImGuiDataType_Float, ImGuiDataType_S16, ImGuiDataType_S32, ImGuiDataType_S64, ImGuiDataType_S8, ImGuiDataType_U16, ImGuiDataType_U32, ImGuiDataType_U64, ImGuiDataType_U8, ImGuiDir_Left, ImGuiDir_Right, ImGuiDragDropFlags_None, ImGuiFocusedFlags_AnyWindow, ImGuiFocusedFlags_ChildWindows, ImGuiFocusedFlags_RootWindow, ImGuiHoveredFlags_AllowWhenBlockedByActiveItem, ImGuiHoveredFlags_AllowWhenBlockedByPopup, ImGuiHoveredFlags_AllowWhenOverlapped, ImGuiHoveredFlags_AnyWindow, ImGuiHoveredFlags_ChildWindows, ImGuiHoveredFlags_RectOnly, ImGuiHoveredFlags_RootWindow, ImGuiInputTextFlags_AllowTabInput, ImGuiInputTextFlags_CallbackCharFilter, ImGuiInputTextFlags_CallbackCompletion, ImGuiInputTextFlags_CallbackEdit, ImGuiInputTextFlags_CallbackHistory, ImGuiInputTextFlags_CallbackResize, ImGuiInputTextFlags_CharsDecimal, ImGuiInputTextFlags_CharsHexadecimal, ImGuiInputTextFlags_CharsNoBlank, ImGuiInputTextFlags_CharsUppercase, ImGuiInputTextFlags_CtrlEnterForNewLine, ImGuiInputTextFlags_Password, ImGuiInputTextFlags_ReadOnly, ImGuiKey_DownArrow, ImGuiKey_UpArrow, ImGuiSelectableFlags_AllowDoubleClick, ImGuiSelectableFlags_None, ImGuiSelectableFlags_SpanAllColumns, ImGuiSliderFlags_AlwaysClamp, ImGuiSliderFlags_Logarithmic, ImGuiSliderFlags_NoInput, ImGuiSliderFlags_None, ImGuiSliderFlags_NoRoundToFormat, ImGuiStyleVar_GrabMinSize, ImGuiStyleVar_ItemSpacing, ImGuiStyleVar_SelectableTextAlign, ImGuiTabBarFlags_AutoSelectNewTabs, ImGuiTabBarFlags_FittingPolicyDefault_, ImGuiTabBarFlags_FittingPolicyMask_, ImGuiTabBarFlags_FittingPolicyResizeDown, ImGuiTabBarFlags_FittingPolicyScroll, ImGuiTabBarFlags_NoCloseWithMiddleMouseButton, ImGuiTabBarFlags_None, ImGuiTabBarFlags_Reorderable, ImGuiTabBarFlags_TabListPopupButton, ImGuiTabItemFlags_Leading, ImGuiTabItemFlags_None, ImGuiTabItemFlags_NoTooltip, ImGuiTabItemFlags_Trailing, ImGuiTableFlags_NoSavedSettings, ImGuiTableFlags_Resizable, ImGuiTreeNodeFlags_Leaf, ImGuiTreeNodeFlags_None, ImGuiTreeNodeFlags_NoTreePushOnOpen, ImGuiTreeNodeFlags_OpenOnArrow, ImGuiTreeNodeFlags_OpenOnDoubleClick, ImGuiTreeNodeFlags_Selected, ImGuiTreeNodeFlags_SpanAvailWidth, ImGuiTreeNodeFlags_SpanFullWidth, ImGui::Indent(), ImGui::InputDouble(), ImGui::InputFloat(), ImGui::InputFloat2(), ImGui::InputFloat3(), ImGui::InputFloat4(), ImGui::InputInt(), ImGui::InputInt2(), ImGui::InputInt3(), ImGui::InputInt4(), ImGui::InputScalar(), ImGui::InputText(), ImGui::InputTextMultiline(), ImGui::InputTextWithHint(), ImGui::IsItemActivated(), ImGui::IsItemActive(), ImGui::IsItemClicked(), ImGui::IsItemDeactivated(), ImGui::IsItemDeactivatedAfterEdit(), ImGui::IsItemEdited(), ImGui::IsItemFocused(), ImGui::IsItemHovered(), ImGui::IsItemToggledOpen(), ImGui::IsItemVisible(), ImGui::IsMouseDoubleClicked(), ImGui::IsWindowFocused(), ImGui::IsWindowHovered(), ImGuiStyle::ItemInnerSpacing, ImGui::LabelText(), ImGui::ListBox(), ImGui::MenuItem(), ImGuiIO::MousePos, ImGui::NewLine(), ImGui::OpenPopup(), ImGui::PlotHistogram(), ImGui::PlotLines(), ImGui::PopButtonRepeat(), ImGui::PopID(), ImGui::PopStyleColor(), ImGui::PopStyleVar(), ImGui::PopTextWrapPos(), ImGui::ProgressBar(), ImVector< T >::push_back(), ImGui::PushButtonRepeat(), ImGui::PushID(), ImGui::PushStyleColor(), ImGui::PushStyleVar(), ImGui::PushTextWrapPos(), ImGui::RadioButton(), ImGui::ResetMouseDragDelta(), ImVector< T >::resize(), ImGui::SameLine(), ImGui::Selectable(), ImGui::Separator(), ImGui::SetColorEditOptions(), ImGui::SetDragDropPayload(), ImGui::SetItemDefaultFocus(), ImGui::SetNextItemOpen(), ImGui::SetNextItemWidth(), ImGui::SetTooltip(), ImVector< T >::Size, ImVector< T >::size(), ImGui::SliderAngle(), ImGui::SliderFloat(), ImGui::SliderFloat2(), ImGui::SliderFloat3(), ImGui::SliderFloat4(), ImGui::SliderInt(), ImGui::SliderInt2(), ImGui::SliderInt3(), ImGui::SliderInt4(), ImGui::SliderScalar(), ImGui::SmallButton(), snprintf, ImGui::Spacing(), ImGui::TabItemButton(), ImGui::TableNextColumn(), ImGui::TableNextRow(), ImFontAtlas::TexHeight, ImFontAtlas::TexID, ImGui::Text(), ImGui::TextColored(), ImGui::TextDisabled(), ImGui::TextWrapped(), ImFontAtlas::TexWidth, ImGui::TreeNode(), ImGui::TreeNodeEx(), ImGui::TreePop(), ImGui::Unindent(), ImGui::VSliderFloat(), ImGui::VSliderInt(), ImVec4::w, ImVec2::x, ImVec4::x, and ImVec2::y.

Referenced by ImGui::ShowDemoWindow().

+ Here is the caller graph for this function:

◆ ShowExampleAppAutoResize()

static void ShowExampleAppAutoResize ( bool *  p_open)
static
7009{
7010 if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize))
7011 {
7012 ImGui::End();
7013 return;
7014 }
7015
7016 static int lines = 10;
7018 "Window will resize every-frame to the size of its content.\n"
7019 "Note that you probably don't want to query the window size to\n"
7020 "output your content because that would create a feedback loop.");
7021 ImGui::SliderInt("Number of lines", &lines, 1, 20);
7022 for (int i = 0; i < lines; i++)
7023 ImGui::Text("%*sThis is line %d", i * 4, "", i); // Pad with space to extend size horizontally
7024 ImGui::End();
7025}

References ImGui::Begin(), ImGui::End(), ImGuiWindowFlags_AlwaysAutoResize, ImGui::SliderInt(), ImGui::Text(), and ImGui::TextUnformatted().

Referenced by ImGui::ShowDemoWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowExampleAppConsole()

static void ShowExampleAppConsole ( bool *  p_open)
static
6631{
6632 static ExampleAppConsole console;
6633 console.Draw("Example: Console", p_open);
6634}
Definition imgui_demo.cpp:6285
void Draw(const char *title, bool *p_open)
Definition imgui_demo.cpp:6342

References ExampleAppConsole::Draw().

Referenced by ImGui::ShowDemoWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowExampleAppConstrainedResize()

static void ShowExampleAppConstrainedResize ( bool *  p_open)
static
7033{
7034 struct CustomConstraints
7035 {
7036 // Helper functions to demonstrate programmatic constraints
7037 static void Square(ImGuiSizeCallbackData* data) { data->DesiredSize.x = data->DesiredSize.y = IM_MAX(data->DesiredSize.x, data->DesiredSize.y); }
7038 static void Step(ImGuiSizeCallbackData* data) { float step = (float)(int)(intptr_t)data->UserData; data->DesiredSize = ImVec2((int)(data->DesiredSize.x / step + 0.5f) * step, (int)(data->DesiredSize.y / step + 0.5f) * step); }
7039 };
7040
7041 const char* test_desc[] =
7042 {
7043 "Resize vertical only",
7044 "Resize horizontal only",
7045 "Width > 100, Height > 100",
7046 "Width 400-500",
7047 "Height 400-500",
7048 "Custom: Always Square",
7049 "Custom: Fixed Steps (100)",
7050 };
7051
7052 static bool auto_resize = false;
7053 static int type = 0;
7054 static int display_lines = 10;
7055 if (type == 0) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 0), ImVec2(-1, FLT_MAX)); // Vertical only
7056 if (type == 1) ImGui::SetNextWindowSizeConstraints(ImVec2(0, -1), ImVec2(FLT_MAX, -1)); // Horizontal only
7057 if (type == 2) ImGui::SetNextWindowSizeConstraints(ImVec2(100, 100), ImVec2(FLT_MAX, FLT_MAX)); // Width > 100, Height > 100
7058 if (type == 3) ImGui::SetNextWindowSizeConstraints(ImVec2(400, -1), ImVec2(500, -1)); // Width 400-500
7059 if (type == 4) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 400), ImVec2(-1, 500)); // Height 400-500
7060 if (type == 5) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Square); // Always Square
7061 if (type == 6) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Step, (void*)(intptr_t)100); // Fixed Step
7062
7063 ImGuiWindowFlags flags = auto_resize ? ImGuiWindowFlags_AlwaysAutoResize : 0;
7064 if (ImGui::Begin("Example: Constrained Resize", p_open, flags))
7065 {
7066 if (ImGui::Button("200x200")) { ImGui::SetWindowSize(ImVec2(200, 200)); } ImGui::SameLine();
7067 if (ImGui::Button("500x500")) { ImGui::SetWindowSize(ImVec2(500, 500)); } ImGui::SameLine();
7068 if (ImGui::Button("800x200")) { ImGui::SetWindowSize(ImVec2(800, 200)); }
7070 ImGui::Combo("Constraint", &type, test_desc, IM_ARRAYSIZE(test_desc));
7072 ImGui::DragInt("Lines", &display_lines, 0.2f, 1, 100);
7073 ImGui::Checkbox("Auto-resize", &auto_resize);
7074 for (int i = 0; i < display_lines; i++)
7075 ImGui::Text("%*sHello, sailor! Making this line long enough for the example.", i * 4, "");
7076 }
7077 ImGui::End();
7078}
Definition imgui.h:1948
#define IM_MAX(A, B)
Definition imgui_demo.cpp:155
IMGUI_API void SetNextWindowSizeConstraints(const ImVec2 &size_min, const ImVec2 &size_max, ImGuiSizeCallback custom_callback=NULL, void *custom_callback_data=NULL)
Definition imgui.cpp:6879
IMGUI_API void SetWindowSize(const ImVec2 &size, ImGuiCond cond=0)
Definition imgui.cpp:6790
Coord step(const Coord &crd, Dir d)
Definition MarchingSquares.hpp:137

References ImGui::Begin(), ImGui::Button(), ImGui::Checkbox(), ImGui::Combo(), ImGui::DragInt(), ImGui::End(), IM_ARRAYSIZE, IM_MAX, ImGuiWindowFlags_AlwaysAutoResize, ImGui::SameLine(), ImGui::SetNextItemWidth(), ImGui::SetNextWindowSizeConstraints(), ImGui::SetWindowSize(), and ImGui::Text().

Referenced by ImGui::ShowDemoWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowExampleAppCustomRendering()

static void ShowExampleAppCustomRendering ( bool *  p_open)
static
7205{
7206 if (!ImGui::Begin("Example: Custom rendering", p_open))
7207 {
7208 ImGui::End();
7209 return;
7210 }
7211
7212 // Tip: If you do a lot of custom rendering, you probably want to use your own geometrical types and benefit of
7213 // overloaded operators, etc. Define IM_VEC2_CLASS_EXTRA in imconfig.h to create implicit conversions between your
7214 // types and ImVec2/ImVec4. Dear ImGui defines overloaded operators but they are internal to imgui.cpp and not
7215 // exposed outside (to avoid messing with your types) In this example we are not using the maths operators!
7216
7217 if (ImGui::BeginTabBar("##TabBar"))
7218 {
7219 if (ImGui::BeginTabItem("Primitives"))
7220 {
7222 ImDrawList* draw_list = ImGui::GetWindowDrawList();
7223
7224 // Draw gradients
7225 // (note that those are currently exacerbating our sRGB/Linear issues)
7226 // Calling ImGui::GetColorU32() multiplies the given colors by the current Style Alpha, but you may pass the IM_COL32() directly as well..
7227 ImGui::Text("Gradients");
7229 {
7231 ImVec2 p1 = ImVec2(p0.x + gradient_size.x, p0.y + gradient_size.y);
7232 ImU32 col_a = ImGui::GetColorU32(IM_COL32(0, 0, 0, 255));
7233 ImU32 col_b = ImGui::GetColorU32(IM_COL32(255, 255, 255, 255));
7234 draw_list->AddRectFilledMultiColor(p0, p1, col_a, col_b, col_b, col_a);
7235 ImGui::InvisibleButton("##gradient1", gradient_size);
7236 }
7237 {
7239 ImVec2 p1 = ImVec2(p0.x + gradient_size.x, p0.y + gradient_size.y);
7240 ImU32 col_a = ImGui::GetColorU32(IM_COL32(0, 255, 0, 255));
7241 ImU32 col_b = ImGui::GetColorU32(IM_COL32(255, 0, 0, 255));
7242 draw_list->AddRectFilledMultiColor(p0, p1, col_a, col_b, col_b, col_a);
7243 ImGui::InvisibleButton("##gradient2", gradient_size);
7244 }
7245
7246 // Draw a bunch of primitives
7247 ImGui::Text("All primitives");
7248 static float sz = 36.0f;
7249 static float thickness = 3.0f;
7250 static int ngon_sides = 6;
7251 static bool circle_segments_override = false;
7252 static int circle_segments_override_v = 12;
7253 static bool curve_segments_override = false;
7254 static int curve_segments_override_v = 8;
7255 static ImVec4 colf = ImVec4(1.0f, 1.0f, 0.4f, 1.0f);
7256 ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 100.0f, "%.0f");
7257 ImGui::DragFloat("Thickness", &thickness, 0.05f, 1.0f, 8.0f, "%.02f");
7258 ImGui::SliderInt("N-gon sides", &ngon_sides, 3, 12);
7259 ImGui::Checkbox("##circlesegmentoverride", &circle_segments_override);
7260 ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
7261 circle_segments_override |= ImGui::SliderInt("Circle segments override", &circle_segments_override_v, 3, 40);
7262 ImGui::Checkbox("##curvessegmentoverride", &curve_segments_override);
7263 ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
7264 curve_segments_override |= ImGui::SliderInt("Curves segments override", &curve_segments_override_v, 3, 40);
7265 ImGui::ColorEdit4("Color", &colf.x);
7266
7268 const ImU32 col = ImColor(colf);
7269 const float spacing = 10.0f;
7271 const float rounding = sz / 5.0f;
7272 const int circle_segments = circle_segments_override ? circle_segments_override_v : 0;
7273 const int curve_segments = curve_segments_override ? curve_segments_override_v : 0;
7274 float x = p.x + 4.0f;
7275 float y = p.y + 4.0f;
7276 for (int n = 0; n < 2; n++)
7277 {
7278 // First line uses a thickness of 1.0f, second line uses the configurable thickness
7279 float th = (n == 0) ? 1.0f : thickness;
7280 draw_list->AddNgon(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, ngon_sides, th); x += sz + spacing; // N-gon
7281 draw_list->AddCircle(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, circle_segments, th); x += sz + spacing; // Circle
7282 draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 0.0f, ImDrawFlags_None, th); x += sz + spacing; // Square
7283 draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, rounding, ImDrawFlags_None, th); x += sz + spacing; // Square with all rounded corners
7284 draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, rounding, corners_tl_br, th); x += sz + spacing; // Square with two rounded corners
7285 draw_list->AddTriangle(ImVec2(x+sz*0.5f,y), ImVec2(x+sz, y+sz-0.5f), ImVec2(x, y+sz-0.5f), col, th);x += sz + spacing; // Triangle
7286 //draw_list->AddTriangle(ImVec2(x+sz*0.2f,y), ImVec2(x, y+sz-0.5f), ImVec2(x+sz*0.4f, y+sz-0.5f), col, th);x+= sz*0.4f + spacing; // Thin triangle
7287 draw_list->AddLine(ImVec2(x, y), ImVec2(x + sz, y), col, th); x += sz + spacing; // Horizontal line (note: drawing a filled rectangle will be faster!)
7288 draw_list->AddLine(ImVec2(x, y), ImVec2(x, y + sz), col, th); x += spacing; // Vertical line (note: drawing a filled rectangle will be faster!)
7289 draw_list->AddLine(ImVec2(x, y), ImVec2(x + sz, y + sz), col, th); x += sz + spacing; // Diagonal line
7290
7291 // Quadratic Bezier Curve (3 control points)
7292 ImVec2 cp3[3] = { ImVec2(x, y + sz * 0.6f), ImVec2(x + sz * 0.5f, y - sz * 0.4f), ImVec2(x + sz, y + sz) };
7293 draw_list->AddBezierQuadratic(cp3[0], cp3[1], cp3[2], col, th, curve_segments); x += sz + spacing;
7294
7295 // Cubic Bezier Curve (4 control points)
7296 ImVec2 cp4[4] = { ImVec2(x, y), ImVec2(x + sz * 1.3f, y + sz * 0.3f), ImVec2(x + sz - sz * 1.3f, y + sz - sz * 0.3f), ImVec2(x + sz, y + sz) };
7297 draw_list->AddBezierCubic(cp4[0], cp4[1], cp4[2], cp4[3], col, th, curve_segments);
7298
7299 x = p.x + 4;
7300 y += sz + spacing;
7301 }
7302 draw_list->AddNgonFilled(ImVec2(x + sz * 0.5f, y + sz * 0.5f), sz*0.5f, col, ngon_sides); x += sz + spacing; // N-gon
7303 draw_list->AddCircleFilled(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, circle_segments); x += sz + spacing; // Circle
7304 draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col); x += sz + spacing; // Square
7305 draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 10.0f); x += sz + spacing; // Square with all rounded corners
7306 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
7307 draw_list->AddTriangleFilled(ImVec2(x+sz*0.5f,y), ImVec2(x+sz, y+sz-0.5f), ImVec2(x, y+sz-0.5f), col); x += sz + spacing; // Triangle
7308 //draw_list->AddTriangleFilled(ImVec2(x+sz*0.2f,y), ImVec2(x, y+sz-0.5f), ImVec2(x+sz*0.4f, y+sz-0.5f), col); x += sz*0.4f + spacing; // Thin triangle
7309 draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + thickness), col); x += sz + spacing; // Horizontal line (faster than AddLine, but only handle integer thickness)
7310 draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + thickness, y + sz), col); x += spacing * 2.0f;// Vertical line (faster than AddLine, but only handle integer thickness)
7311 draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + 1, y + 1), col); x += sz; // Pixel (faster than AddLine)
7312 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));
7313
7314 ImGui::Dummy(ImVec2((sz + spacing) * 10.2f, (sz + spacing) * 3.0f));
7317 }
7318
7319 if (ImGui::BeginTabItem("Canvas"))
7320 {
7321 static ImVector<ImVec2> points;
7322 static ImVec2 scrolling(0.0f, 0.0f);
7323 static bool opt_enable_grid = true;
7324 static bool opt_enable_context_menu = true;
7325 static bool adding_line = false;
7326
7327 ImGui::Checkbox("Enable grid", &opt_enable_grid);
7328 ImGui::Checkbox("Enable context menu", &opt_enable_context_menu);
7329 ImGui::Text("Mouse Left: drag to add lines,\nMouse Right: drag to scroll, click for context menu.");
7330
7331 // Typically you would use a BeginChild()/EndChild() pair to benefit from a clipping region + own scrolling.
7332 // Here we demonstrate that this can be replaced by simple offsetting + custom drawing + PushClipRect/PopClipRect() calls.
7333 // To use a child window instead we could use, e.g:
7334 // ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); // Disable padding
7335 // ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(50, 50, 50, 255)); // Set a background color
7336 // ImGui::BeginChild("canvas", ImVec2(0.0f, 0.0f), true, ImGuiWindowFlags_NoMove);
7337 // ImGui::PopStyleColor();
7338 // ImGui::PopStyleVar();
7339 // [...]
7340 // ImGui::EndChild();
7341
7342 // Using InvisibleButton() as a convenience 1) it will advance the layout cursor and 2) allows us to use IsItemHovered()/IsItemActive()
7343 ImVec2 canvas_p0 = ImGui::GetCursorScreenPos(); // ImDrawList API uses screen coordinates!
7344 ImVec2 canvas_sz = ImGui::GetContentRegionAvail(); // Resize canvas to what's available
7345 if (canvas_sz.x < 50.0f) canvas_sz.x = 50.0f;
7346 if (canvas_sz.y < 50.0f) canvas_sz.y = 50.0f;
7347 ImVec2 canvas_p1 = ImVec2(canvas_p0.x + canvas_sz.x, canvas_p0.y + canvas_sz.y);
7348
7349 // Draw border and background color
7350 ImGuiIO& io = ImGui::GetIO();
7351 ImDrawList* draw_list = ImGui::GetWindowDrawList();
7352 draw_list->AddRectFilled(canvas_p0, canvas_p1, IM_COL32(50, 50, 50, 255));
7353 draw_list->AddRect(canvas_p0, canvas_p1, IM_COL32(255, 255, 255, 255));
7354
7355 // This will catch our interactions
7357 const bool is_hovered = ImGui::IsItemHovered(); // Hovered
7358 const bool is_active = ImGui::IsItemActive(); // Held
7359 const ImVec2 origin(canvas_p0.x + scrolling.x, canvas_p0.y + scrolling.y); // Lock scrolled origin
7360 const ImVec2 mouse_pos_in_canvas(io.MousePos.x - origin.x, io.MousePos.y - origin.y);
7361
7362 // Add first and second point
7363 if (is_hovered && !adding_line && ImGui::IsMouseClicked(ImGuiMouseButton_Left))
7364 {
7365 points.push_back(mouse_pos_in_canvas);
7366 points.push_back(mouse_pos_in_canvas);
7367 adding_line = true;
7368 }
7369 if (adding_line)
7370 {
7371 points.back() = mouse_pos_in_canvas;
7373 adding_line = false;
7374 }
7375
7376 // Pan (we use a zero mouse threshold when there's no context menu)
7377 // You may decide to make that threshold dynamic based on whether the mouse is hovering something etc.
7378 const float mouse_threshold_for_pan = opt_enable_context_menu ? -1.0f : 0.0f;
7379 if (is_active && ImGui::IsMouseDragging(ImGuiMouseButton_Right, mouse_threshold_for_pan))
7380 {
7381 scrolling.x += io.MouseDelta.x;
7382 scrolling.y += io.MouseDelta.y;
7383 }
7384
7385 // Context menu (under default mouse threshold)
7387 if (opt_enable_context_menu && ImGui::IsMouseReleased(ImGuiMouseButton_Right) && drag_delta.x == 0.0f && drag_delta.y == 0.0f)
7388 ImGui::OpenPopupOnItemClick("context");
7389 if (ImGui::BeginPopup("context"))
7390 {
7391 if (adding_line)
7392 points.resize(points.size() - 2);
7393 adding_line = false;
7394 if (ImGui::MenuItem("Remove one", NULL, false, points.Size > 0)) { points.resize(points.size() - 2); }
7395 if (ImGui::MenuItem("Remove all", NULL, false, points.Size > 0)) { points.clear(); }
7397 }
7398
7399 // Draw grid + all lines in the canvas
7400 draw_list->PushClipRect(canvas_p0, canvas_p1, true);
7401 if (opt_enable_grid)
7402 {
7403 const float GRID_STEP = 64.0f;
7404 for (float x = fmodf(scrolling.x, GRID_STEP); x < canvas_sz.x; x += GRID_STEP)
7405 draw_list->AddLine(ImVec2(canvas_p0.x + x, canvas_p0.y), ImVec2(canvas_p0.x + x, canvas_p1.y), IM_COL32(200, 200, 200, 40));
7406 for (float y = fmodf(scrolling.y, GRID_STEP); y < canvas_sz.y; y += GRID_STEP)
7407 draw_list->AddLine(ImVec2(canvas_p0.x, canvas_p0.y + y), ImVec2(canvas_p1.x, canvas_p0.y + y), IM_COL32(200, 200, 200, 40));
7408 }
7409 for (int n = 0; n < points.Size; n += 2)
7410 draw_list->AddLine(ImVec2(origin.x + points[n].x, origin.y + points[n].y), ImVec2(origin.x + points[n + 1].x, origin.y + points[n + 1].y), IM_COL32(255, 255, 0, 255), 2.0f);
7411 draw_list->PopClipRect();
7412
7414 }
7415
7416 if (ImGui::BeginTabItem("BG/FG draw lists"))
7417 {
7418 static bool draw_bg = true;
7419 static bool draw_fg = true;
7420 ImGui::Checkbox("Draw in Background draw list", &draw_bg);
7421 ImGui::SameLine(); HelpMarker("The Background draw list will be rendered below every Dear ImGui windows.");
7422 ImGui::Checkbox("Draw in Foreground draw list", &draw_fg);
7423 ImGui::SameLine(); HelpMarker("The Foreground draw list will be rendered over every Dear ImGui windows.");
7424 ImVec2 window_pos = ImGui::GetWindowPos();
7425 ImVec2 window_size = ImGui::GetWindowSize();
7426 ImVec2 window_center = ImVec2(window_pos.x + window_size.x * 0.5f, window_pos.y + window_size.y * 0.5f);
7427 if (draw_bg)
7428 ImGui::GetBackgroundDrawList()->AddCircle(window_center, window_size.x * 0.6f, IM_COL32(255, 0, 0, 200), 0, 10 + 4);
7429 if (draw_fg)
7430 ImGui::GetForegroundDrawList()->AddCircle(window_center, window_size.y * 0.6f, IM_COL32(0, 255, 0, 200), 0, 10);
7432 }
7433
7435 }
7436
7437 ImGui::End();
7438}
EIGEN_DEVICE_FUNC ColXpr col(Index i)
This is the const version of col().
Definition BlockMethods.h:838
@ ImGuiButtonFlags_MouseButtonRight
Definition imgui.h:1511
@ ImGuiButtonFlags_MouseButtonLeft
Definition imgui.h:1510
@ ImGuiMouseButton_Right
Definition imgui.h:1587
int ImDrawFlags
Definition imgui.h:178
@ ImDrawFlags_RoundCornersTopLeft
Definition imgui.h:2313
@ ImDrawFlags_None
Definition imgui.h:2311
@ ImDrawFlags_RoundCornersBottomRight
Definition imgui.h:2316
IMGUI_API ImVec2 GetWindowSize()
Definition imgui.cpp:6752
IMGUI_API ImDrawList * GetBackgroundDrawList()
Definition imgui.cpp:3492
IMGUI_API float CalcItemWidth()
Definition imgui.cpp:7596
Definition imgui.h:2187
IMGUI_API void AddTriangle(const ImVec2 &p1, const ImVec2 &p2, const ImVec2 &p3, ImU32 col, float thickness=1.0f)
Definition imgui_draw.cpp:1444
IMGUI_API void AddBezierQuadratic(const ImVec2 &p1, const ImVec2 &p2, const ImVec2 &p3, ImU32 col, float thickness, int num_segments=0)
Definition imgui_draw.cpp:1554
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)
Definition imgui_draw.cpp:1405
IMGUI_API void AddNgonFilled(const ImVec2 &center, float radius, ImU32 col, int num_segments)
Definition imgui_draw.cpp:1531
IMGUI_API void AddBezierCubic(const ImVec2 &p1, const ImVec2 &p2, const ImVec2 &p3, const ImVec2 &p4, ImU32 col, float thickness, int num_segments=0)
Definition imgui_draw.cpp:1543
IMGUI_API void AddCircle(const ImVec2 &center, float radius, ImU32 col, int num_segments=0, float thickness=1.0f)
Definition imgui_draw.cpp:1466
IMGUI_API void AddNgon(const ImVec2 &center, float radius, ImU32 col, int num_segments, float thickness=1.0f)
Definition imgui_draw.cpp:1519
IMGUI_API void AddCircleFilled(const ImVec2 &center, float radius, ImU32 col, int num_segments=0)
Definition imgui_draw.cpp:1492
IMGUI_API void AddTriangleFilled(const ImVec2 &p1, const ImVec2 &p2, const ImVec2 &p3, ImU32 col)
Definition imgui_draw.cpp:1455
float x
Definition imgui.h:259
T & back()
Definition imgui.h:1685

References ImDrawList::AddBezierCubic(), ImDrawList::AddBezierQuadratic(), ImDrawList::AddCircle(), ImDrawList::AddCircleFilled(), ImDrawList::AddLine(), ImDrawList::AddNgon(), ImDrawList::AddNgonFilled(), ImDrawList::AddRect(), ImDrawList::AddRectFilled(), ImDrawList::AddRectFilledMultiColor(), ImDrawList::AddTriangle(), ImDrawList::AddTriangleFilled(), ImVector< T >::back(), ImGui::Begin(), ImGui::BeginPopup(), ImGui::BeginTabBar(), ImGui::BeginTabItem(), ImGui::CalcItemWidth(), ImGui::Checkbox(), ImVector< T >::clear(), col(), ImGui::ColorEdit4(), ImGui::DragFloat(), ImGui::Dummy(), ImGui::End(), ImGui::EndPopup(), ImGui::EndTabBar(), ImGui::EndTabItem(), ImGui::GetBackgroundDrawList(), ImGui::GetColorU32(), ImGui::GetContentRegionAvail(), ImGui::GetCursorScreenPos(), ImGui::GetFontSize(), ImGui::GetForegroundDrawList(), ImGui::GetFrameHeight(), ImGui::GetIO(), ImGui::GetMouseDragDelta(), ImGui::GetStyle(), ImGui::GetWindowDrawList(), ImGui::GetWindowPos(), ImGui::GetWindowSize(), HelpMarker(), IM_COL32, ImDrawFlags_None, ImDrawFlags_RoundCornersBottomRight, ImDrawFlags_RoundCornersTopLeft, ImGuiButtonFlags_MouseButtonLeft, ImGuiButtonFlags_MouseButtonRight, ImGuiMouseButton_Left, ImGuiMouseButton_Right, ImGui::InvisibleButton(), ImGui::IsItemActive(), ImGui::IsItemHovered(), ImGui::IsMouseClicked(), ImGui::IsMouseDown(), ImGui::IsMouseDragging(), ImGui::IsMouseReleased(), ImGui::MenuItem(), ImGuiIO::MouseDelta, ImGuiIO::MousePos, ImGui::OpenPopupOnItemClick(), ImDrawList::PopClipRect(), ImGui::PopItemWidth(), ImVector< T >::push_back(), ImDrawList::PushClipRect(), ImGui::PushItemWidth(), ImVector< T >::resize(), ImGui::SameLine(), ImVector< T >::Size, ImVector< T >::size(), ImGui::SliderInt(), ImGui::Text(), ImVec2::x, ImVec4::x, and ImVec2::y.

Referenced by ImGui::ShowDemoWindow().

+ Here is the caller graph for this function:

◆ ShowExampleAppDocuments()

void ShowExampleAppDocuments ( bool *  p_open)
static
7535{
7536 static ExampleAppDocuments app;
7537
7538 // Options
7539 static bool opt_reorderable = true;
7541
7542 bool window_contents_visible = ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar);
7543 if (!window_contents_visible)
7544 {
7545 ImGui::End();
7546 return;
7547 }
7548
7549 // Menu
7550 if (ImGui::BeginMenuBar())
7551 {
7552 if (ImGui::BeginMenu("File"))
7553 {
7554 int open_count = 0;
7555 for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
7556 open_count += app.Documents[doc_n].Open ? 1 : 0;
7557
7558 if (ImGui::BeginMenu("Open", open_count < app.Documents.Size))
7559 {
7560 for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
7561 {
7562 MyDocument* doc = &app.Documents[doc_n];
7563 if (!doc->Open)
7564 if (ImGui::MenuItem(doc->Name))
7565 doc->DoOpen();
7566 }
7568 }
7569 if (ImGui::MenuItem("Close All Documents", NULL, false, open_count > 0))
7570 for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
7571 app.Documents[doc_n].DoQueueClose();
7572 if (ImGui::MenuItem("Exit", "Alt+F4")) {}
7574 }
7576 }
7577
7578 // [Debug] List documents with one checkbox for each
7579 for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
7580 {
7581 MyDocument* doc = &app.Documents[doc_n];
7582 if (doc_n > 0)
7584 ImGui::PushID(doc);
7585 if (ImGui::Checkbox(doc->Name, &doc->Open))
7586 if (!doc->Open)
7587 doc->DoForceClose();
7588 ImGui::PopID();
7589 }
7590
7592
7593 // Submit Tab Bar and Tabs
7594 {
7595 ImGuiTabBarFlags tab_bar_flags = (opt_fitting_flags) | (opt_reorderable ? ImGuiTabBarFlags_Reorderable : 0);
7596 if (ImGui::BeginTabBar("##tabs", tab_bar_flags))
7597 {
7598 if (opt_reorderable)
7600
7601 // [DEBUG] Stress tests
7602 //if ((ImGui::GetFrameCount() % 30) == 0) docs[1].Open ^= 1; // [DEBUG] Automatically show/hide a tab. Test various interactions e.g. dragging with this on.
7603 //if (ImGui::GetIO().KeyCtrl) ImGui::SetTabItemSelected(docs[1].Name); // [DEBUG] Test SetTabItemSelected(), probably not very useful as-is anyway..
7604
7605 // Submit Tabs
7606 for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
7607 {
7608 MyDocument* doc = &app.Documents[doc_n];
7609 if (!doc->Open)
7610 continue;
7611
7613 bool visible = ImGui::BeginTabItem(doc->Name, &doc->Open, tab_flags);
7614
7615 // Cancel attempt to close when unsaved add to save queue so we can display a popup.
7616 if (!doc->Open && doc->Dirty)
7617 {
7618 doc->Open = true;
7619 doc->DoQueueClose();
7620 }
7621
7623 if (visible)
7624 {
7627 }
7628 }
7629
7631 }
7632 }
7633
7634 // Update closing queue
7635 static ImVector<MyDocument*> close_queue;
7636 if (close_queue.empty())
7637 {
7638 // Close queue is locked once we started a popup
7639 for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
7640 {
7641 MyDocument* doc = &app.Documents[doc_n];
7642 if (doc->WantClose)
7643 {
7644 doc->WantClose = false;
7645 close_queue.push_back(doc);
7646 }
7647 }
7648 }
7649
7650 // Display closing confirmation UI
7651 if (!close_queue.empty())
7652 {
7653 int close_queue_unsaved_documents = 0;
7654 for (int n = 0; n < close_queue.Size; n++)
7655 if (close_queue[n]->Dirty)
7656 close_queue_unsaved_documents++;
7657
7658 if (close_queue_unsaved_documents == 0)
7659 {
7660 // Close documents when all are unsaved
7661 for (int n = 0; n < close_queue.Size; n++)
7662 close_queue[n]->DoForceClose();
7663 close_queue.clear();
7664 }
7665 else
7666 {
7667 if (!ImGui::IsPopupOpen("Save?"))
7668 ImGui::OpenPopup("Save?");
7670 {
7671 ImGui::Text("Save change to the following items?");
7672 float item_height = ImGui::GetTextLineHeightWithSpacing();
7673 if (ImGui::BeginChildFrame(ImGui::GetID("frame"), ImVec2(-FLT_MIN, 6.25f * item_height)))
7674 {
7675 for (int n = 0; n < close_queue.Size; n++)
7676 if (close_queue[n]->Dirty)
7677 ImGui::Text("%s", close_queue[n]->Name);
7679 }
7680
7681 ImVec2 button_size(ImGui::GetFontSize() * 7.0f, 0.0f);
7682 if (ImGui::Button("Yes", button_size))
7683 {
7684 for (int n = 0; n < close_queue.Size; n++)
7685 {
7686 if (close_queue[n]->Dirty)
7687 close_queue[n]->DoSave();
7688 close_queue[n]->DoForceClose();
7689 }
7690 close_queue.clear();
7692 }
7694 if (ImGui::Button("No", button_size))
7695 {
7696 for (int n = 0; n < close_queue.Size; n++)
7697 close_queue[n]->DoForceClose();
7698 close_queue.clear();
7700 }
7702 if (ImGui::Button("Cancel", button_size))
7703 {
7704 close_queue.clear();
7706 }
7708 }
7709 }
7710 }
7711
7712 ImGui::End();
7713}
@ ImGuiTabItemFlags_UnsavedDocument
Definition imgui.h:1073
int ImGuiTabItemFlags
Definition imgui.h:195
static void NotifyOfDocumentsClosedElsewhere(ExampleAppDocuments &app)
Definition imgui_demo.cpp:7523
IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2 &size, ImGuiWindowFlags flags=0)
Definition imgui.cpp:5078
IMGUI_API bool IsPopupOpen(const char *str_id, ImGuiPopupFlags flags=0)
Definition imgui.cpp:8102
IMGUI_API void EndChildFrame()
Definition imgui.cpp:5092
Definition imgui_demo.cpp:7501
bool WantClose
Definition imgui_demo.cpp:7451
void DoQueueClose()
Definition imgui_demo.cpp:7463
void DoOpen()
Definition imgui_demo.cpp:7462
bool Dirty
Definition imgui_demo.cpp:7450
static void DisplayContents(MyDocument *doc)
Definition imgui_demo.cpp:7468
void DoForceClose()
Definition imgui_demo.cpp:7464
static void DisplayContextMenu(MyDocument *doc)
Definition imgui_demo.cpp:7485

References ImGui::Begin(), ImGui::BeginChildFrame(), ImGui::BeginMenu(), ImGui::BeginMenuBar(), ImGui::BeginPopupModal(), ImGui::BeginTabBar(), ImGui::BeginTabItem(), ImGui::Button(), ImGui::Checkbox(), ImVector< T >::clear(), ImGui::CloseCurrentPopup(), MyDocument::Dirty, MyDocument::DisplayContents(), MyDocument::DisplayContextMenu(), ExampleAppDocuments::Documents, MyDocument::DoForceClose(), MyDocument::DoOpen(), MyDocument::DoQueueClose(), ImVector< T >::empty(), ImGui::End(), ImGui::EndChildFrame(), ImGui::EndMenu(), ImGui::EndMenuBar(), ImGui::EndPopup(), ImGui::EndTabBar(), ImGui::EndTabItem(), ImGui::GetFontSize(), ImGui::GetID(), ImGui::GetTextLineHeightWithSpacing(), ImGuiTabBarFlags_FittingPolicyDefault_, ImGuiTabBarFlags_Reorderable, ImGuiTabItemFlags_UnsavedDocument, ImGuiWindowFlags_AlwaysAutoResize, ImGuiWindowFlags_MenuBar, ImGui::IsPopupOpen(), ImGui::MenuItem(), MyDocument::Name, NotifyOfDocumentsClosedElsewhere(), MyDocument::Open, ImGui::OpenPopup(), ImGui::PopID(), ImVector< T >::push_back(), ImGui::PushID(), ImGui::SameLine(), ImGui::Separator(), ImVector< T >::Size, ImGui::Text(), and MyDocument::WantClose.

Referenced by ImGui::ShowDemoWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowExampleAppFullscreen()

static void ShowExampleAppFullscreen ( bool *  p_open)
static
7134{
7135 static bool use_work_area = true;
7137
7138 // We demonstrate using the full viewport area or the work area (without menu-bars, task-bars etc.)
7139 // Based on your use case you may want one of the other.
7140 const ImGuiViewport* viewport = ImGui::GetMainViewport();
7141 ImGui::SetNextWindowPos(use_work_area ? viewport->WorkPos : viewport->Pos);
7142 ImGui::SetNextWindowSize(use_work_area ? viewport->WorkSize : viewport->Size);
7143
7144 if (ImGui::Begin("Example: Fullscreen window", p_open, flags))
7145 {
7146 ImGui::Checkbox("Use work area instead of main area", &use_work_area);
7148 HelpMarker("Main Area = entire viewport,\nWork Area = entire viewport minus sections used by the main menu bars, task bars etc.\n\nEnable the main-menu bar in Examples menu to see the difference.");
7149
7150 ImGui::CheckboxFlags("ImGuiWindowFlags_NoBackground", &flags, ImGuiWindowFlags_NoBackground);
7151 ImGui::CheckboxFlags("ImGuiWindowFlags_NoDecoration", &flags, ImGuiWindowFlags_NoDecoration);
7152 ImGui::Indent();
7153 ImGui::CheckboxFlags("ImGuiWindowFlags_NoTitleBar", &flags, ImGuiWindowFlags_NoTitleBar);
7154 ImGui::CheckboxFlags("ImGuiWindowFlags_NoCollapse", &flags, ImGuiWindowFlags_NoCollapse);
7155 ImGui::CheckboxFlags("ImGuiWindowFlags_NoScrollbar", &flags, ImGuiWindowFlags_NoScrollbar);
7157
7158 if (p_open && ImGui::Button("Close this window"))
7159 *p_open = false;
7160 }
7161 ImGui::End();
7162}
@ ImGuiWindowFlags_NoBackground
Definition imgui.h:923
@ ImGuiWindowFlags_NoTitleBar
Definition imgui.h:916
@ ImGuiWindowFlags_NoCollapse
Definition imgui.h:921
@ ImGuiWindowFlags_NoSavedSettings
Definition imgui.h:924
@ ImGuiWindowFlags_NoDecoration
Definition imgui.h:937
@ ImGuiWindowFlags_NoMove
Definition imgui.h:918
@ ImGuiWindowFlags_NoResize
Definition imgui.h:917
@ ImGuiWindowFlags_NoScrollbar
Definition imgui.h:919
IMGUI_API void SetNextWindowSize(const ImVec2 &size, ImGuiCond cond=0)
Definition imgui.cpp:6870
Definition imgui.h:2761
ImVec2 WorkPos
Definition imgui.h:2765
ImVec2 WorkSize
Definition imgui.h:2766

References ImGui::Begin(), ImGui::Button(), ImGui::Checkbox(), ImGui::CheckboxFlags(), ImGui::End(), ImGui::GetMainViewport(), HelpMarker(), ImGuiWindowFlags_NoBackground, ImGuiWindowFlags_NoCollapse, ImGuiWindowFlags_NoDecoration, ImGuiWindowFlags_NoMove, ImGuiWindowFlags_NoResize, ImGuiWindowFlags_NoSavedSettings, ImGuiWindowFlags_NoScrollbar, ImGuiWindowFlags_NoTitleBar, ImGui::Indent(), ImGuiViewport::Pos, ImGui::SameLine(), ImGui::SetNextWindowPos(), ImGui::SetNextWindowSize(), ImGuiViewport::Size, ImGui::Unindent(), ImGuiViewport::WorkPos, and ImGuiViewport::WorkSize.

Referenced by ImGui::ShowDemoWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowExampleAppLayout()

static void ShowExampleAppLayout ( bool *  p_open)
static
6800{
6802 if (ImGui::Begin("Example: Simple layout", p_open, ImGuiWindowFlags_MenuBar))
6803 {
6804 if (ImGui::BeginMenuBar())
6805 {
6806 if (ImGui::BeginMenu("File"))
6807 {
6808 if (ImGui::MenuItem("Close")) *p_open = false;
6810 }
6812 }
6813
6814 // Left
6815 static int selected = 0;
6816 {
6817 ImGui::BeginChild("left pane", ImVec2(150, 0), true);
6818 for (int i = 0; i < 100; i++)
6819 {
6820 char label[128];
6821 sprintf(label, "MyObject %d", i);
6822 if (ImGui::Selectable(label, selected == i))
6823 selected = i;
6824 }
6826 }
6828
6829 // Right
6830 {
6832 ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us
6833 ImGui::Text("MyObject: %d", selected);
6836 {
6837 if (ImGui::BeginTabItem("Description"))
6838 {
6839 ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ");
6841 }
6842 if (ImGui::BeginTabItem("Details"))
6843 {
6844 ImGui::Text("ID: 0123456789");
6846 }
6848 }
6850 if (ImGui::Button("Revert")) {}
6852 if (ImGui::Button("Save")) {}
6854 }
6855 }
6856 ImGui::End();
6857}
@ ImGuiCond_FirstUseEver
Definition imgui.h:1617

References ImGui::Begin(), ImGui::BeginChild(), ImGui::BeginGroup(), ImGui::BeginMenu(), ImGui::BeginMenuBar(), ImGui::BeginTabBar(), ImGui::BeginTabItem(), ImGui::Button(), ImGui::End(), ImGui::EndChild(), ImGui::EndGroup(), ImGui::EndMenu(), ImGui::EndMenuBar(), ImGui::EndTabBar(), ImGui::EndTabItem(), ImGui::GetFrameHeightWithSpacing(), ImGuiCond_FirstUseEver, ImGuiTabBarFlags_None, ImGuiWindowFlags_MenuBar, ImGui::MenuItem(), ImGui::SameLine(), ImGui::Selectable(), ImGui::Separator(), ImGui::SetNextWindowSize(), ImGui::Text(), and ImGui::TextWrapped().

Referenced by ImGui::ShowDemoWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowExampleAppLog()

static void ShowExampleAppLog ( bool *  p_open)
static
6766{
6767 static ExampleAppLog log;
6768
6769 // For the demo: add a debug button _BEFORE_ the normal log window contents
6770 // We take advantage of a rarely used feature: multiple calls to Begin()/End() are appending to the _same_ window.
6771 // Most of the contents of the window will be added by the log.Draw() call.
6773 ImGui::Begin("Example: Log", p_open);
6774 if (ImGui::SmallButton("[Debug] Add 5 entries"))
6775 {
6776 static int counter = 0;
6777 const char* categories[3] = { "info", "warn", "error" };
6778 const char* words[] = { "Bumfuzzled", "Cattywampus", "Snickersnee", "Abibliophobia", "Absquatulate", "Nincompoop", "Pauciloquent" };
6779 for (int n = 0; n < 5; n++)
6780 {
6781 const char* category = categories[counter % IM_ARRAYSIZE(categories)];
6782 const char* word = words[counter % IM_ARRAYSIZE(words)];
6783 log.AddLog("[%05d] [%s] Hello, current time is %.1f, here's a word: '%s'\n",
6784 ImGui::GetFrameCount(), category, ImGui::GetTime(), word);
6785 counter++;
6786 }
6787 }
6788 ImGui::End();
6789
6790 // Actually call in the regular Log helper (which will Begin() into the same window as we just did)
6791 log.Draw("Example: Log", p_open);
6792}
EIGEN_DEVICE_FUNC const LogReturnType log() const
Definition ArrayCwiseUnaryOps.h:105
IMGUI_API int GetFrameCount()
Definition imgui.cpp:3458
Definition imgui_demo.cpp:6645

References ImGui::Begin(), ImGui::End(), ImGui::GetFrameCount(), ImGui::GetTime(), IM_ARRAYSIZE, ImGuiCond_FirstUseEver, log(), ImGui::SetNextWindowSize(), and ImGui::SmallButton().

Referenced by ImGui::ShowDemoWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowExampleAppLongText()

static void ShowExampleAppLongText ( bool *  p_open)
static
6947{
6949 if (!ImGui::Begin("Example: Long text display", p_open))
6950 {
6951 ImGui::End();
6952 return;
6953 }
6954
6955 static int test_type = 0;
6956 static ImGuiTextBuffer log;
6957 static int lines = 0;
6958 ImGui::Text("Printing unusually long amount of text.");
6959 ImGui::Combo("Test type", &test_type,
6960 "Single call to TextUnformatted()\0"
6961 "Multiple calls to Text(), clipped\0"
6962 "Multiple calls to Text(), not clipped (slow)\0");
6963 ImGui::Text("Buffer contents: %d lines, %d bytes", lines, log.size());
6964 if (ImGui::Button("Clear")) { log.clear(); lines = 0; }
6966 if (ImGui::Button("Add 1000 lines"))
6967 {
6968 for (int i = 0; i < 1000; i++)
6969 log.appendf("%i The quick brown fox jumps over the lazy dog\n", lines + i);
6970 lines += 1000;
6971 }
6972 ImGui::BeginChild("Log");
6973 switch (test_type)
6974 {
6975 case 0:
6976 // Single call to TextUnformatted() with a big buffer
6977 ImGui::TextUnformatted(log.begin(), log.end());
6978 break;
6979 case 1:
6980 {
6981 // Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the ImGuiListClipper helper.
6983 ImGuiListClipper clipper;
6984 clipper.Begin(lines);
6985 while (clipper.Step())
6986 for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
6987 ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
6989 break;
6990 }
6991 case 2:
6992 // Multiple calls to Text(), not clipped (slow)
6994 for (int i = 0; i < lines; i++)
6995 ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
6997 break;
6998 }
7000 ImGui::End();
7001}
Definition imgui.h:2051

References ImGui::Begin(), ImGuiListClipper::Begin(), ImGui::BeginChild(), ImGui::Button(), ImGui::Combo(), ImGuiListClipper::DisplayEnd, ImGuiListClipper::DisplayStart, ImGui::End(), ImGui::EndChild(), ImGuiCond_FirstUseEver, ImGuiStyleVar_ItemSpacing, log(), ImGui::PopStyleVar(), ImGui::PushStyleVar(), ImGui::SameLine(), ImGui::SetNextWindowSize(), ImGuiListClipper::Step(), ImGui::Text(), and ImGui::TextUnformatted().

Referenced by ImGui::ShowDemoWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowExampleAppMainMenuBar()

static void ShowExampleAppMainMenuBar ( )
static
6178{
6180 {
6181 if (ImGui::BeginMenu("File"))
6182 {
6185 }
6186 if (ImGui::BeginMenu("Edit"))
6187 {
6188 if (ImGui::MenuItem("Undo", "CTRL+Z")) {}
6189 if (ImGui::MenuItem("Redo", "CTRL+Y", false, false)) {} // Disabled item
6191 if (ImGui::MenuItem("Cut", "CTRL+X")) {}
6192 if (ImGui::MenuItem("Copy", "CTRL+C")) {}
6193 if (ImGui::MenuItem("Paste", "CTRL+V")) {}
6195 }
6197 }
6198}
IMGUI_API bool BeginMainMenuBar()
Definition imgui_widgets.cpp:6658
IMGUI_API void EndMainMenuBar()
Definition imgui_widgets.cpp:6679

References ImGui::BeginMainMenuBar(), ImGui::BeginMenu(), ImGui::EndMainMenuBar(), ImGui::EndMenu(), ImGui::MenuItem(), ImGui::Separator(), and ShowExampleMenuFile().

Referenced by ImGui::ShowDemoWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowExampleAppPropertyEditor()

static void ShowExampleAppPropertyEditor ( bool *  p_open)
static
6912{
6914 if (!ImGui::Begin("Example: Property editor", p_open))
6915 {
6916 ImGui::End();
6917 return;
6918 }
6919
6920 HelpMarker(
6921 "This example shows how you may implement a property editor using two columns.\n"
6922 "All objects/fields data are dummies here.\n"
6923 "Remember that in many simple cases, you can use ImGui::SameLine(xxx) to position\n"
6924 "your cursor horizontally instead of using the Columns() API.");
6925
6928 {
6929 // Iterate placeholder objects (all the same data)
6930 for (int obj_i = 0; obj_i < 4; obj_i++)
6931 {
6932 ShowPlaceholderObject("Object", obj_i);
6933 //ImGui::Separator();
6934 }
6936 }
6938 ImGui::End();
6939}
static void ShowPlaceholderObject(const char *prefix, int uid)
Definition imgui_demo.cpp:6863

References ImGui::Begin(), ImGui::BeginTable(), ImGui::End(), ImGui::EndTable(), HelpMarker(), ImGuiCond_FirstUseEver, ImGuiStyleVar_FramePadding, ImGuiTableFlags_BordersOuter, ImGuiTableFlags_Resizable, ImGui::PopStyleVar(), ImGui::PushStyleVar(), ImGui::SetNextWindowSize(), and ShowPlaceholderObject().

Referenced by ImGui::ShowDemoWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowExampleAppSimpleOverlay()

static void ShowExampleAppSimpleOverlay ( bool *  p_open)
static
7087{
7088 const float PAD = 10.0f;
7089 static int corner = 0;
7090 ImGuiIO& io = ImGui::GetIO();
7092 if (corner != -1)
7093 {
7094 const ImGuiViewport* viewport = ImGui::GetMainViewport();
7095 ImVec2 work_pos = viewport->WorkPos; // Use work area to avoid menu-bar/task-bar, if any!
7096 ImVec2 work_size = viewport->WorkSize;
7097 ImVec2 window_pos, window_pos_pivot;
7098 window_pos.x = (corner & 1) ? (work_pos.x + work_size.x - PAD) : (work_pos.x + PAD);
7099 window_pos.y = (corner & 2) ? (work_pos.y + work_size.y - PAD) : (work_pos.y + PAD);
7100 window_pos_pivot.x = (corner & 1) ? 1.0f : 0.0f;
7101 window_pos_pivot.y = (corner & 2) ? 1.0f : 0.0f;
7102 ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
7103 window_flags |= ImGuiWindowFlags_NoMove;
7104 }
7105 ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background
7106 if (ImGui::Begin("Example: Simple overlay", p_open, window_flags))
7107 {
7108 ImGui::Text("Simple overlay\n" "in the corner of the screen.\n" "(right-click to change position)");
7111 ImGui::Text("Mouse Position: (%.1f,%.1f)", io.MousePos.x, io.MousePos.y);
7112 else
7113 ImGui::Text("Mouse Position: <invalid>");
7115 {
7116 if (ImGui::MenuItem("Custom", NULL, corner == -1)) corner = -1;
7117 if (ImGui::MenuItem("Top-left", NULL, corner == 0)) corner = 0;
7118 if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1;
7119 if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2;
7120 if (ImGui::MenuItem("Bottom-right", NULL, corner == 3)) corner = 3;
7121 if (p_open && ImGui::MenuItem("Close")) *p_open = false;
7123 }
7124 }
7125 ImGui::End();
7126}
@ ImGuiWindowFlags_NoFocusOnAppearing
Definition imgui.h:928
@ ImGuiWindowFlags_NoNav
Definition imgui.h:936
@ ImGuiCond_Always
Definition imgui.h:1615
IMGUI_API void SetNextWindowBgAlpha(float alpha)
Definition imgui.cpp:6919
IMGUI_API bool BeginPopupContextWindow(const char *str_id=NULL, ImGuiPopupFlags popup_flags=1)
Definition imgui.cpp:8419

References ImGui::Begin(), ImGui::BeginPopupContextWindow(), ImGui::End(), ImGui::EndPopup(), ImGui::GetIO(), ImGui::GetMainViewport(), ImGuiCond_Always, ImGuiWindowFlags_AlwaysAutoResize, ImGuiWindowFlags_NoDecoration, ImGuiWindowFlags_NoFocusOnAppearing, ImGuiWindowFlags_NoMove, ImGuiWindowFlags_NoNav, ImGuiWindowFlags_NoSavedSettings, ImGui::IsMousePosValid(), ImGui::MenuItem(), ImGuiIO::MousePos, ImGui::Separator(), ImGui::SetNextWindowBgAlpha(), ImGui::SetNextWindowPos(), ImGui::Text(), ImGuiViewport::WorkPos, ImGuiViewport::WorkSize, ImVec2::x, and ImVec2::y.

Referenced by ImGui::ShowDemoWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowExampleAppWindowTitles()

static void ShowExampleAppWindowTitles ( bool *  p_open)
static
7172{
7173 const ImGuiViewport* viewport = ImGui::GetMainViewport();
7174 const ImVec2 base_pos = viewport->Pos;
7175
7176 // By default, Windows are uniquely identified by their title.
7177 // You can use the "##" and "###" markers to manipulate the display/ID.
7178
7179 // Using "##" to display same title but have unique identifier.
7180 ImGui::SetNextWindowPos(ImVec2(base_pos.x + 100, base_pos.y + 100), ImGuiCond_FirstUseEver);
7181 ImGui::Begin("Same title as another window##1");
7182 ImGui::Text("This is window 1.\nMy title is the same as window 2, but my identifier is unique.");
7183 ImGui::End();
7184
7185 ImGui::SetNextWindowPos(ImVec2(base_pos.x + 100, base_pos.y + 200), ImGuiCond_FirstUseEver);
7186 ImGui::Begin("Same title as another window##2");
7187 ImGui::Text("This is window 2.\nMy title is the same as window 1, but my identifier is unique.");
7188 ImGui::End();
7189
7190 // Using "###" to display a changing title but keep a static identifier "AnimatedTitle"
7191 char buf[128];
7192 sprintf(buf, "Animated title %c %d###AnimatedTitle", "|/-\\"[(int)(ImGui::GetTime() / 0.25f) & 3], ImGui::GetFrameCount());
7193 ImGui::SetNextWindowPos(ImVec2(base_pos.x + 100, base_pos.y + 300), ImGuiCond_FirstUseEver);
7194 ImGui::Begin(buf);
7195 ImGui::Text("This window has a changing title.");
7196 ImGui::End();
7197}
ImVec2 Pos
Definition imgui.h:2763

References ImGui::Begin(), ImGui::End(), ImGui::GetFrameCount(), ImGui::GetMainViewport(), ImGui::GetTime(), ImGuiCond_FirstUseEver, ImGuiViewport::Pos, ImGui::SetNextWindowPos(), ImGui::Text(), ImVec2::x, and ImVec2::y.

Referenced by ImGui::ShowDemoWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowExampleMenuFile()

static void ShowExampleMenuFile ( )
static
6203{
6204 ImGui::MenuItem("(demo menu)", NULL, false, false);
6205 if (ImGui::MenuItem("New")) {}
6206 if (ImGui::MenuItem("Open", "Ctrl+O")) {}
6207 if (ImGui::BeginMenu("Open Recent"))
6208 {
6209 ImGui::MenuItem("fish_hat.c");
6210 ImGui::MenuItem("fish_hat.inl");
6211 ImGui::MenuItem("fish_hat.h");
6212 if (ImGui::BeginMenu("More.."))
6213 {
6214 ImGui::MenuItem("Hello");
6215 ImGui::MenuItem("Sailor");
6216 if (ImGui::BeginMenu("Recurse.."))
6217 {
6220 }
6222 }
6224 }
6225 if (ImGui::MenuItem("Save", "Ctrl+S")) {}
6226 if (ImGui::MenuItem("Save As..")) {}
6227
6229 if (ImGui::BeginMenu("Options"))
6230 {
6231 static bool enabled = true;
6232 ImGui::MenuItem("Enabled", "", &enabled);
6233 ImGui::BeginChild("child", ImVec2(0, 60), true);
6234 for (int i = 0; i < 10; i++)
6235 ImGui::Text("Scrolling Text %d", i);
6237 static float f = 0.5f;
6238 static int n = 0;
6239 ImGui::SliderFloat("Value", &f, 0.0f, 1.0f);
6240 ImGui::InputFloat("Input", &f, 0.1f);
6241 ImGui::Combo("Combo", &n, "Yes\0No\0Maybe\0\0");
6243 }
6244
6245 if (ImGui::BeginMenu("Colors"))
6246 {
6247 float sz = ImGui::GetTextLineHeight();
6248 for (int i = 0; i < ImGuiCol_COUNT; i++)
6249 {
6250 const char* name = ImGui::GetStyleColorName((ImGuiCol)i);
6253 ImGui::Dummy(ImVec2(sz, sz));
6255 ImGui::MenuItem(name);
6256 }
6258 }
6259
6260 // Here we demonstrate appending again to the "Options" menu (which we already created above)
6261 // Of course in this demo it is a little bit silly that this function calls BeginMenu("Options") twice.
6262 // In a real code-base using it would make senses to use this feature from very different code locations.
6263 if (ImGui::BeginMenu("Options")) // <-- Append!
6264 {
6265 static bool b = true;
6266 ImGui::Checkbox("SomeOption", &b);
6268 }
6269
6270 if (ImGui::BeginMenu("Disabled", false)) // Disabled
6271 {
6272 IM_ASSERT(0);
6273 }
6274 if (ImGui::MenuItem("Checked", NULL, true)) {}
6275 if (ImGui::MenuItem("Quit", "Alt+F4")) {}
6276}
int ImGuiCol
Definition imgui.h:167
@ ImGuiCol_COUNT
Definition imgui.h:1466
IMGUI_API const char * GetStyleColorName(ImGuiCol idx)
Definition imgui.cpp:2581

References ImDrawList::AddRectFilled(), ImGui::BeginChild(), ImGui::BeginMenu(), ImGui::Checkbox(), ImGui::Combo(), ImGui::Dummy(), ImGui::EndChild(), ImGui::EndMenu(), ImGui::GetColorU32(), ImGui::GetCursorScreenPos(), ImGui::GetStyleColorName(), ImGui::GetTextLineHeight(), ImGui::GetWindowDrawList(), IM_ASSERT, ImGuiCol_COUNT, ImGui::InputFloat(), ImGui::MenuItem(), ImGui::SameLine(), ImGui::Separator(), ShowExampleMenuFile(), ImGui::SliderFloat(), ImGui::Text(), ImVec2::x, and ImVec2::y.

Referenced by ImGui::ShowDemoWindow(), ShowDemoWindowLayout(), ShowDemoWindowPopups(), ShowExampleAppMainMenuBar(), and ShowExampleMenuFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowFont()

static void ShowFont ( ImFont font)
static
5785{
5786 ImGuiIO& io = ImGui::GetIO();
5788 bool font_details_opened = ImGui::TreeNode(font, "Font: \"%s\"\n%.2f px, %d glyphs, %d file(s)",
5789 font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount);
5790 ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) { io.FontDefault = font; }
5791 if (!font_details_opened)
5792 return;
5793
5794 // Display preview text
5795 ImGui::PushFont(font);
5796 ImGui::Text("The quick brown fox jumps over the lazy dog");
5798
5799 // Display details
5801 ImGui::DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f"); // Scale only this font
5803 "Note than the default embedded font is NOT meant to be scaled.\n\n"
5804 "Font are currently rendered into bitmaps at a given size at the time of building the atlas. "
5805 "You may oversample them to get some flexibility with scaling. "
5806 "You can also render at multiple sizes and select which one to use at runtime.\n\n"
5807 "(Glimmer of hope: the atlas system will be rewritten in the future to make scaling more flexible.)");
5808 ImGui::Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent);
5809 ImGui::Text("Fallback character: '%c' (U+%04X)", font->FallbackChar, font->FallbackChar);
5810 ImGui::Text("Ellipsis character: '%c' (U+%04X)", font->EllipsisChar, font->EllipsisChar);
5811 const int surface_sqrt = (int)sqrtf((float)font->MetricsTotalSurface);
5812 ImGui::Text("Texture Area: about %d px ~%dx%d px", font->MetricsTotalSurface, surface_sqrt, surface_sqrt);
5813 for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
5814 if (font->ConfigData)
5815 if (const ImFontConfig* cfg = &font->ConfigData[config_i])
5816 ImGui::BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d, Offset: (%.1f,%.1f)",
5817 config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y);
5818
5819 // Display all glyphs of the fonts in separate pages of 256 characters
5820 if (ImGui::TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
5821 {
5822 const ImU32 glyph_col = ImGui::GetColorU32(ImGuiCol_Text);
5823 for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
5824 {
5825 // Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k)
5826 // This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT
5827 // is large // (if ImWchar==ImWchar32 we will do at least about 272 queries here)
5828 if (!(base & 4095) && font->IsGlyphRangeUnused(base, base + 4095))
5829 {
5830 base += 4096 - 256;
5831 continue;
5832 }
5833
5834 int count = 0;
5835 for (unsigned int n = 0; n < 256; n++)
5836 if (font->FindGlyphNoFallback((ImWchar)(base + n)))
5837 count++;
5838 if (count <= 0)
5839 continue;
5840 if (!ImGui::TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph"))
5841 continue;
5842 float cell_size = font->FontSize * 1;
5843 float cell_spacing = style.ItemSpacing.y;
5844 ImVec2 base_pos = ImGui::GetCursorScreenPos();
5845 ImDrawList* draw_list = ImGui::GetWindowDrawList();
5846 for (unsigned int n = 0; n < 256; n++)
5847 {
5848 // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions
5849 // available here and thus cannot easily generate a zero-terminated UTF-8 encoded string.
5850 ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing));
5851 ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);
5852 const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base + n));
5853 draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50));
5854 if (glyph)
5855 font->RenderChar(draw_list, cell_size, cell_p1, glyph_col, (ImWchar)(base + n));
5856 if (glyph && ImGui::IsMouseHoveringRect(cell_p1, cell_p2))
5857 {
5859 ImGui::Text("Codepoint: U+%04X", base + n);
5861 ImGui::Text("Visible: %d", glyph->Visible);
5862 ImGui::Text("AdvanceX: %.1f", glyph->AdvanceX);
5863 ImGui::Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1);
5864 ImGui::Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph->U0, glyph->V0, glyph->U1, glyph->V1);
5866 }
5867 }
5868 ImGui::Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16));
5870 }
5872 }
5874}
float AdvanceX
Definition imgui.h:2528
float X1
Definition imgui.h:2529
float X0
Definition imgui.h:2529
float V0
Definition imgui.h:2530
float U0
Definition imgui.h:2530
float V1
Definition imgui.h:2530
unsigned int Visible
Definition imgui.h:2526
@ ImGuiCol_Text
Definition imgui.h:1413
float Y1
Definition imgui.h:2529
float U1
Definition imgui.h:2530
float Y0
Definition imgui.h:2529
#define IM_UNICODE_CODEPOINT_MAX
Definition imgui.h:2010
Definition imgui.h:2524
IMGUI_API void PushFont(ImFont *font)
Definition imgui.cpp:6532
IMGUI_API bool IsMouseHoveringRect(const ImVec2 &r_min, const ImVec2 &r_max, bool clip=true)
Definition imgui.cpp:4609
IMGUI_API void PopFont()
Definition imgui.cpp:6542
std::map< int, Glyph > Glyphs
Definition Emboss.hpp:54
IGL_INLINE void count(const Eigen::SparseMatrix< XType > &X, const int dim, Eigen::SparseVector< SType > &S)
Definition count.cpp:12
Definition imgui.h:2495
char Name[40]
Definition imgui.h:2515
ImVector< ImFontGlyph > Glyphs
Definition imgui.h:2698
float FontSize
Definition imgui.h:2694
IMGUI_API bool IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last)
Definition imgui_draw.cpp:3189
short ConfigDataCount
Definition imgui.h:2704
ImWchar EllipsisChar
Definition imgui.h:2706
float Ascent
Definition imgui.h:2709
int MetricsTotalSurface
Definition imgui.h:2710
IMGUI_API void RenderChar(ImDrawList *draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const
Definition imgui_draw.cpp:3497
IMGUI_API const ImFontGlyph * FindGlyphNoFallback(ImWchar c) const
Definition imgui_draw.cpp:3293
float Descent
Definition imgui.h:2709
ImWchar FallbackChar
Definition imgui.h:2705
float Scale
Definition imgui.h:2708
const ImFontConfig * ConfigData
Definition imgui.h:2703
ImFont * FontDefault
Definition imgui.h:1798

References ImDrawList::AddRect(), ImFontGlyph::AdvanceX, ImFont::Ascent, ImGui::BeginTooltip(), ImGui::BulletText(), ImFont::ConfigData, ImFont::ConfigDataCount, ImFont::Descent, ImGui::DragFloat(), ImGui::Dummy(), ImFont::EllipsisChar, ImGui::EndTooltip(), ImFont::FallbackChar, ImFont::FindGlyphNoFallback(), ImGuiIO::FontDefault, ImFont::FontSize, ImGui::GetColorU32(), ImGui::GetCursorScreenPos(), ImGui::GetFontSize(), ImGui::GetIO(), ImGui::GetStyle(), ImGui::GetWindowDrawList(), ImFont::Glyphs, HelpMarker(), IM_COL32, IM_UNICODE_CODEPOINT_MAX, ImGuiCol_Text, ImFont::IsGlyphRangeUnused(), ImGui::IsMouseHoveringRect(), ImFont::MetricsTotalSurface, ImFontConfig::Name, ImGui::PopFont(), ImGui::PushFont(), ImFont::RenderChar(), ImGui::SameLine(), ImFont::Scale, ImGui::Separator(), ImGui::SetNextItemWidth(), ImVector< T >::Size, ImGui::SmallButton(), style, ImGui::Text(), ImGui::TreeNode(), ImGui::TreePop(), ImFontGlyph::U0, ImFontGlyph::U1, ImFontGlyph::V0, ImFontGlyph::V1, ImFontGlyph::Visible, ImVec2::x, ImFontGlyph::X0, ImFontGlyph::X1, ImVec2::y, ImFontGlyph::Y0, and ImFontGlyph::Y1.

Referenced by ImGui::ShowFontAtlas().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowPlaceholderObject()

static void ShowPlaceholderObject ( const char *  prefix,
int  uid 
)
static
6864{
6865 // Use object uid as identifier. Most commonly you could also use the object pointer as a base ID.
6866 ImGui::PushID(uid);
6867
6868 // Text and Tree nodes are less high than framed widgets, using AlignTextToFramePadding() we add vertical spacing to make the tree lines equal high.
6872 bool node_open = ImGui::TreeNode("Object", "%s_%u", prefix, uid);
6874 ImGui::Text("my sailor is rich");
6875
6876 if (node_open)
6877 {
6878 static float placeholder_members[8] = { 0.0f, 0.0f, 1.0f, 3.1416f, 100.0f, 999.0f };
6879 for (int i = 0; i < 8; i++)
6880 {
6881 ImGui::PushID(i); // Use field index as identifier.
6882 if (i < 2)
6883 {
6884 ShowPlaceholderObject("Child", 424242);
6885 }
6886 else
6887 {
6888 // Here we use a TreeNode to highlight on hover (we could use e.g. Selectable as well)
6893 ImGui::TreeNodeEx("Field", flags, "Field_%d", i);
6894
6896 ImGui::SetNextItemWidth(-FLT_MIN);
6897 if (i >= 5)
6898 ImGui::InputFloat("##value", &placeholder_members[i], 1.0f);
6899 else
6900 ImGui::DragFloat("##value", &placeholder_members[i], 0.01f);
6902 }
6903 ImGui::PopID();
6904 }
6906 }
6907 ImGui::PopID();
6908}

References ImGui::AlignTextToFramePadding(), ImGui::DragFloat(), ImGuiTreeNodeFlags_Bullet, ImGuiTreeNodeFlags_Leaf, ImGuiTreeNodeFlags_NoTreePushOnOpen, ImGui::InputFloat(), ImGui::NextColumn(), ImGui::PopID(), ImGui::PushID(), ImGui::SetNextItemWidth(), ShowPlaceholderObject(), ImGui::TableNextRow(), ImGui::TableSetColumnIndex(), ImGui::Text(), ImGui::TreeNode(), ImGui::TreeNodeEx(), and ImGui::TreePop().

Referenced by ShowExampleAppPropertyEditor(), and ShowPlaceholderObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowTableColumnsStatusFlags()

static void ShowTableColumnsStatusFlags ( ImGuiTableColumnFlags  flags)
static
3521{
3526}
@ ImGuiTableColumnFlags_IsEnabled
Definition imgui.h:1185
@ ImGuiTableColumnFlags_IsVisible
Definition imgui.h:1186

References ImGui::CheckboxFlags(), ImGuiTableColumnFlags_IsEnabled, ImGuiTableColumnFlags_IsHovered, ImGuiTableColumnFlags_IsSorted, and ImGuiTableColumnFlags_IsVisible.

Referenced by ShowDemoWindowTables().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: