mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-27 16:29:02 +08:00
Comments and some extra line-wrapping in demo (#3193)
This commit is contained in:
parent
4758f74676
commit
7938550d52
1
imgui.h
1
imgui.h
@ -532,6 +532,7 @@ namespace ImGui
|
||||
|
||||
// Widgets: Images
|
||||
// - Read about ImTextureID here: https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples
|
||||
// - 'uv0' and 'uv1' are texture coordinates. Read about them from the same link above.
|
||||
// - Note that Image() may add +2.0f to provided size if a border is visible, ImageButton() adds style.FramePadding*2.0f to provided size.
|
||||
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& image_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));
|
||||
IMGUI_API bool ImageButton(const char* str_id, ImTextureID user_texture_id, const ImVec2& image_size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), const ImVec4& bg_col = ImVec4(0, 0, 0, 0), const ImVec4& tint_col = ImVec4(1, 1, 1, 1));
|
||||
|
151
imgui_demo.cpp
151
imgui_demo.cpp
@ -54,7 +54,7 @@
|
||||
// Because we can't assume anything about your support of maths operators, we cannot use them in imgui_demo.cpp.
|
||||
|
||||
// Navigating this file:
|
||||
// - In Visual Studio IDE: CTRL+comma ("Edit.GoToAll") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
||||
// - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
||||
// - With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments.
|
||||
|
||||
/*
|
||||
@ -171,7 +171,8 @@ Index of this file:
|
||||
#define IM_MAX(A, B) (((A) >= (B)) ? (A) : (B))
|
||||
#define IM_CLAMP(V, MN, MX) ((V) < (MN) ? (MN) : (V) > (MX) ? (MX) : (V))
|
||||
|
||||
// Enforce cdecl calling convention for functions called by the standard library, in case compilation settings changed the default to e.g. __vectorcall
|
||||
// Enforce cdecl calling convention for functions called by the standard library,
|
||||
// in case compilation settings changed the default to e.g. __vectorcall
|
||||
#ifndef IMGUI_CDECL
|
||||
#ifdef _MSC_VER
|
||||
#define IMGUI_CDECL __cdecl
|
||||
@ -759,7 +760,8 @@ static void ShowDemoWindowWidgets()
|
||||
static int item_current = 0;
|
||||
ImGui::Combo("combo", &item_current, items, IM_ARRAYSIZE(items));
|
||||
ImGui::SameLine(); HelpMarker(
|
||||
"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.");
|
||||
"Using the simplified one-liner Combo API here.\n"
|
||||
"Refer to the \"Combo\" section below for an explanation of how to use the more flexible and general BeginCombo/EndCombo API.");
|
||||
}
|
||||
|
||||
{
|
||||
@ -770,7 +772,8 @@ static void ShowDemoWindowWidgets()
|
||||
static int item_current = 1;
|
||||
ImGui::ListBox("listbox", &item_current, items, IM_ARRAYSIZE(items), 4);
|
||||
ImGui::SameLine(); HelpMarker(
|
||||
"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.");
|
||||
"Using the simplified one-liner ListBox API here.\n"
|
||||
"Refer to the \"List boxes\" section below for an explanation of how to use the more flexible and general BeginListBox/EndListBox API.");
|
||||
}
|
||||
|
||||
ImGui::TreePop();
|
||||
@ -1088,7 +1091,7 @@ static void ShowDemoWindowWidgets()
|
||||
"CJK text will only appear if the font was loaded with the appropriate CJK character ranges. "
|
||||
"Call io.Fonts->AddFontFromFileTTF() manually to load extra character ranges. "
|
||||
"Read docs/FONTS.md for details.");
|
||||
ImGui::Text("Hiragana: \xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91\xe3\x81\x93 (kakikukeko)"); // Normally we would use u8"blah blah" with the proper characters directly in the string.
|
||||
ImGui::Text("Hiragana: \xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91\xe3\x81\x93 (kakikukeko)");
|
||||
ImGui::Text("Kanjis: \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e (nihongo)");
|
||||
static char buf[32] = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e";
|
||||
//static char buf[32] = u8"NIHONGO"; // <- this is how you would write it with C++11, using real kanjis
|
||||
@ -1132,7 +1135,7 @@ static void ShowDemoWindowWidgets()
|
||||
ImVec2 pos = ImGui::GetCursorScreenPos();
|
||||
ImVec2 uv_min = ImVec2(0.0f, 0.0f); // Top-left
|
||||
ImVec2 uv_max = ImVec2(1.0f, 1.0f); // Lower-right
|
||||
ImVec4 tint_col = use_text_color_for_tint ? ImGui::GetStyleColorVec4(ImGuiCol_Text) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint
|
||||
ImVec4 tint_col = use_text_color_for_tint ? ImGui::GetStyleColorVec4(ImGuiCol_Text) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint
|
||||
ImVec4 border_col = ImGui::GetStyleColorVec4(ImGuiCol_Border);
|
||||
ImGui::Image(my_tex_id, ImVec2(my_tex_w, my_tex_h), uv_min, uv_max, tint_col, border_col);
|
||||
if (ImGui::BeginItemTooltip())
|
||||
@ -1191,9 +1194,9 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::CheckboxFlags("ImGuiComboFlags_PopupAlignLeft", &flags, ImGuiComboFlags_PopupAlignLeft);
|
||||
ImGui::SameLine(); HelpMarker("Only makes a difference if the popup is larger than the combo");
|
||||
if (ImGui::CheckboxFlags("ImGuiComboFlags_NoArrowButton", &flags, ImGuiComboFlags_NoArrowButton))
|
||||
flags &= ~ImGuiComboFlags_NoPreview; // Clear the other flag, as we cannot combine both
|
||||
flags &= ~ImGuiComboFlags_NoPreview; // Clear incompatible flags
|
||||
if (ImGui::CheckboxFlags("ImGuiComboFlags_NoPreview", &flags, ImGuiComboFlags_NoPreview))
|
||||
flags &= ~(ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_WidthFitPreview); // Clear the other flag, as we cannot combine both
|
||||
flags &= ~(ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_WidthFitPreview); // Clear incompatible flags
|
||||
if (ImGui::CheckboxFlags("ImGuiComboFlags_WidthFitPreview", &flags, ImGuiComboFlags_WidthFitPreview))
|
||||
flags &= ~ImGuiComboFlags_NoPreview;
|
||||
|
||||
@ -1210,7 +1213,10 @@ static void ShowDemoWindowWidgets()
|
||||
// stored in the object itself, etc.)
|
||||
const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO" };
|
||||
static int item_current_idx = 0; // Here we store our selection data as an index.
|
||||
const char* combo_preview_value = items[item_current_idx]; // Pass in the preview value visible before opening the combo (it could be anything)
|
||||
|
||||
// Pass in the preview value visible before opening the combo (it could technically be different contents or not pulled from items[])
|
||||
const char* combo_preview_value = items[item_current_idx];
|
||||
|
||||
if (ImGui::BeginCombo("combo 1", combo_preview_value, flags))
|
||||
{
|
||||
for (int n = 0; n < IM_ARRAYSIZE(items); n++)
|
||||
@ -1250,8 +1256,10 @@ static void ShowDemoWindowWidgets()
|
||||
IMGUI_DEMO_MARKER("Widgets/List Boxes");
|
||||
if (ImGui::TreeNode("List boxes"))
|
||||
{
|
||||
// BeginListBox() is essentially a thin wrapper to using BeginChild()/EndChild() with the ImGuiChildFlags_FrameStyle flag for stylistic changes + displaying a label.
|
||||
// You may be tempted to simply use BeginChild() directly, however note that BeginChild() requires EndChild() to always be called (inconsistent with BeginListBox()/EndListBox()).
|
||||
// BeginListBox() is essentially a thin wrapper to using BeginChild()/EndChild()
|
||||
// using the ImGuiChildFlags_FrameStyle flag for stylistic changes + displaying a label.
|
||||
// You may be tempted to simply use BeginChild() directly. However note that BeginChild() requires EndChild()
|
||||
// to always be called (inconsistent with BeginListBox()/EndListBox()).
|
||||
|
||||
// Using the generic BeginListBox() API, you have full control over how to display the combo contents.
|
||||
// (your selection data could be an index, a pointer to the object, an id for the object, a flag intrusively
|
||||
@ -1570,16 +1578,21 @@ static void ShowDemoWindowWidgets()
|
||||
};
|
||||
static char buf1[64];
|
||||
ImGui::InputText("Completion", buf1, 64, ImGuiInputTextFlags_CallbackCompletion, Funcs::MyCallback);
|
||||
ImGui::SameLine(); HelpMarker("Here we append \"..\" each time Tab is pressed. See 'Examples>Console' for a more meaningful demonstration of using this callback.");
|
||||
ImGui::SameLine(); HelpMarker(
|
||||
"Here we append \"..\" each time Tab is pressed. "
|
||||
"See 'Examples>Console' for a more meaningful demonstration of using this callback.");
|
||||
|
||||
static char buf2[64];
|
||||
ImGui::InputText("History", buf2, 64, ImGuiInputTextFlags_CallbackHistory, Funcs::MyCallback);
|
||||
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.");
|
||||
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.");
|
||||
|
||||
static char buf3[64];
|
||||
static int edit_count = 0;
|
||||
ImGui::InputText("Edit", buf3, 64, ImGuiInputTextFlags_CallbackEdit, Funcs::MyCallback, (void*)&edit_count);
|
||||
ImGui::SameLine(); HelpMarker("Here we toggle the casing of the first character on every edit + count edits.");
|
||||
ImGui::SameLine(); HelpMarker(
|
||||
"Here we toggle the casing of the first character on every edit + count edits.");
|
||||
ImGui::SameLine(); ImGui::Text("(%d)", edit_count);
|
||||
|
||||
ImGui::TreePop();
|
||||
@ -1754,8 +1767,9 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
// 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 "+")
|
||||
// Note that we submit it before the regular tabs, but because of the ImGuiTabItemFlags_Trailing flag it will always appear at the end.
|
||||
// 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 "+")
|
||||
// We submit it before the regular tabs, but thanks to the ImGuiTabItemFlags_Trailing flag it will always appear at the end.
|
||||
if (show_trailing_button)
|
||||
if (ImGui::TabItemButton("+", ImGuiTabItemFlags_Trailing | ImGuiTabItemFlags_NoTooltip))
|
||||
active_tabs.push_back(next_tab_id++); // Add new tab
|
||||
@ -2039,7 +2053,8 @@ static void ShowDemoWindowWidgets()
|
||||
if (ImGui::Button("Default: Float + HDR + Hue Wheel"))
|
||||
ImGui::SetColorEditOptions(ImGuiColorEditFlags_Float | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_PickerHueWheel);
|
||||
|
||||
// Always both a small version of both types of pickers (to make it more visible in the demo to people who are skimming quickly through it)
|
||||
// Always display a small version of both types of pickers
|
||||
// (that's in order to make it more visible in the demo to people who are skimming quickly through it)
|
||||
ImGui::Text("Both types:");
|
||||
float w = (ImGui::GetContentRegionAvail().x - ImGui::GetStyle().ItemSpacing.y) * 0.40f;
|
||||
ImGui::SetNextItemWidth(w);
|
||||
@ -3381,7 +3396,9 @@ static void ShowDemoWindowLayout()
|
||||
IMGUI_DEMO_MARKER("Layout/Scrolling/Horizontal contents size demo window");
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(2, 0));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2, 0));
|
||||
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.");
|
||||
HelpMarker(
|
||||
"Test how different widgets react and impact the work rectangle growing when horizontal scrolling is enabled.\n\n"
|
||||
"Use 'Metrics->Tools->Show windows rectangles' to visualize rectangles.");
|
||||
ImGui::Checkbox("H-scrollbar", &show_h_scrollbar);
|
||||
ImGui::Checkbox("Button", &show_button); // Will grow contents size (unless explicitly overwritten)
|
||||
ImGui::Checkbox("Tree nodes", &show_tree_nodes); // Will grow contents size and display highlight over full width
|
||||
@ -3537,7 +3554,8 @@ static void ShowDemoWindowLayout()
|
||||
|
||||
HelpMarker(
|
||||
"Hit-testing is by default performed in item submission order, which generally is perceived as 'back-to-front'.\n\n"
|
||||
"By using SetNextItemAllowOverlap() you can notify that an item may be overlapped by another. Doing so alters the hovering logic: items using AllowOverlap mode requires an extra frame to accept hovered state.");
|
||||
"By using SetNextItemAllowOverlap() you can notify that an item may be overlapped by another. "
|
||||
"Doing so alters the hovering logic: items using AllowOverlap mode requires an extra frame to accept hovered state.");
|
||||
ImGui::Checkbox("Enable AllowOverlap", &enable_allow_overlap);
|
||||
|
||||
ImVec2 button1_pos = ImGui::GetCursorScreenPos();
|
||||
@ -3924,7 +3942,8 @@ struct MyItem
|
||||
}
|
||||
|
||||
// qsort() is instable so always return a way to differenciate items.
|
||||
// Your own compare function may want to avoid fallback on implicit sort specs e.g. a Name compare if it wasn't already part of the sort specs.
|
||||
// Your own compare function may want to avoid fallback on implicit sort specs.
|
||||
// e.g. a Name compare if it wasn't already part of the sort specs.
|
||||
return (a->ID - b->ID);
|
||||
}
|
||||
};
|
||||
@ -4107,8 +4126,9 @@ static void ShowDemoWindowTables()
|
||||
// as TableNextColumn() will automatically wrap around and create new rows as needed.
|
||||
// This is generally more convenient when your cells all contains the same type of data.
|
||||
HelpMarker(
|
||||
"Only using TableNextColumn(), which tends to be convenient for tables where every cell contains the same type of contents.\n"
|
||||
"This is also more similar to the old NextColumn() function of the Columns API, and provided to facilitate the Columns->Tables API transition.");
|
||||
"Only using TableNextColumn(), which tends to be convenient for tables where every cell contains "
|
||||
"the same type of contents.\n This is also more similar to the old NextColumn() function of the "
|
||||
"Columns API, and provided to facilitate the Columns->Tables API transition.");
|
||||
if (ImGui::BeginTable("table3", 3))
|
||||
{
|
||||
for (int item = 0; item < 14; item++)
|
||||
@ -4164,8 +4184,8 @@ static void ShowDemoWindowTables()
|
||||
|
||||
if (ImGui::BeginTable("table1", 3, flags))
|
||||
{
|
||||
// Display headers so we can inspect their interaction with borders.
|
||||
// (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)
|
||||
// Display headers so we can inspect their interaction with borders
|
||||
// (Headers are not the main purpose of this section of the demo, so we are not elaborating on them now. See other sections for details)
|
||||
if (display_headers)
|
||||
{
|
||||
ImGui::TableSetupColumn("One");
|
||||
@ -4204,7 +4224,9 @@ static void ShowDemoWindowTables()
|
||||
PushStyleCompact();
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersV", &flags, ImGuiTableFlags_BordersV);
|
||||
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.");
|
||||
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.");
|
||||
PopStyleCompact();
|
||||
|
||||
if (ImGui::BeginTable("table1", 3, flags))
|
||||
@ -4345,7 +4367,8 @@ static void ShowDemoWindowTables()
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
// 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)
|
||||
// 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)
|
||||
if (ImGui::BeginTable("table2", 3, flags | ImGuiTableFlags_SizingFixedFit, ImVec2(0.0f, 0.0f)))
|
||||
{
|
||||
ImGui::TableSetupColumn("One");
|
||||
@ -4378,7 +4401,8 @@ static void ShowDemoWindowTables()
|
||||
"e.g.:\n"
|
||||
"- BorderOuterV\n"
|
||||
"- any form of row selection\n"
|
||||
"Because of this, activating BorderOuterV sets the default to PadOuterX. Using PadOuterX or NoPadOuterX you can override the default.\n\n"
|
||||
"Because of this, activating BorderOuterV sets the default to PadOuterX. "
|
||||
"Using PadOuterX or NoPadOuterX you can override the default.\n\n"
|
||||
"Actual padding values are using style.CellPadding.\n\n"
|
||||
"In this demo we don't show horizontal borders to emphasize how they don't affect default horizontal padding.");
|
||||
|
||||
@ -4494,7 +4518,8 @@ static void ShowDemoWindowTables()
|
||||
EditTableSizingFlags(&sizing_policy_flags[table_n]);
|
||||
|
||||
// To make it easier to understand the different sizing policy,
|
||||
// For each policy: we display one table where the columns have equal contents width, and one where the columns have different contents width.
|
||||
// For each policy: we display one table where the columns have equal contents width,
|
||||
// and one where the columns have different contents width.
|
||||
if (ImGui::BeginTable("table1", 3, sizing_policy_flags[table_n] | flags1))
|
||||
{
|
||||
for (int row = 0; row < 3; row++)
|
||||
@ -4523,7 +4548,9 @@ static void ShowDemoWindowTables()
|
||||
ImGui::Spacing();
|
||||
ImGui::TextUnformatted("Advanced");
|
||||
ImGui::SameLine();
|
||||
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.");
|
||||
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.");
|
||||
|
||||
enum ContentsType { CT_ShowWidth, CT_ShortText, CT_LongText, CT_Button, CT_FillButton, CT_InputText };
|
||||
static ImGuiTableFlags flags = ImGuiTableFlags_ScrollY | ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_Resizable;
|
||||
@ -4538,7 +4565,9 @@ static void ShowDemoWindowTables()
|
||||
if (contents_type == CT_FillButton)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
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.");
|
||||
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.");
|
||||
}
|
||||
ImGui::DragInt("Columns", &column_count, 0.1f, 1, 64, "%d", ImGuiSliderFlags_AlwaysClamp);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable);
|
||||
@ -4584,7 +4613,9 @@ static void ShowDemoWindowTables()
|
||||
IMGUI_DEMO_MARKER("Tables/Vertical scrolling, with clipping");
|
||||
if (ImGui::TreeNode("Vertical scrolling, with clipping"))
|
||||
{
|
||||
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.");
|
||||
HelpMarker(
|
||||
"Here we activate ScrollY, which will create a child window container to allow hosting scrollable contents.\n\n"
|
||||
"We also demonstrate using ImGuiListClipper to virtualize the submission of many items.");
|
||||
static ImGuiTableFlags flags = ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable;
|
||||
|
||||
PushStyleCompact();
|
||||
@ -4630,8 +4661,9 @@ static void ShowDemoWindowTables()
|
||||
HelpMarker(
|
||||
"When ScrollX is enabled, the default sizing policy becomes ImGuiTableFlags_SizingFixedFit, "
|
||||
"as automatically stretching columns doesn't make much sense with horizontal scrolling.\n\n"
|
||||
"Also note that as of the current version, you will almost always want to enable ScrollY along with ScrollX,"
|
||||
"because the container window won't automatically extend vertically to fix contents (this may be improved in future versions).");
|
||||
"Also note that as of the current version, you will almost always want to enable ScrollY along with ScrollX, "
|
||||
"because the container window won't automatically extend vertically to fix contents "
|
||||
"(this may be improved in future versions).");
|
||||
static ImGuiTableFlags flags = ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable;
|
||||
static int freeze_cols = 1;
|
||||
static int freeze_rows = 1;
|
||||
@ -4688,7 +4720,8 @@ static void ShowDemoWindowTables()
|
||||
HelpMarker(
|
||||
"Showcase using Stretch columns + ScrollX together: "
|
||||
"this is rather unusual and only makes sense when specifying an 'inner_width' for the table!\n"
|
||||
"Without an explicit value, inner_width is == outer_size.x and therefore using Stretch columns + ScrollX together doesn't make sense.");
|
||||
"Without an explicit value, inner_width is == outer_size.x and therefore using Stretch columns "
|
||||
"along with ScrollX doesn't make sense.");
|
||||
static ImGuiTableFlags flags2 = ImGuiTableFlags_SizingStretchSame | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_RowBg | ImGuiTableFlags_ContextMenuInBody;
|
||||
static float inner_width = 1000.0f;
|
||||
PushStyleCompact();
|
||||
@ -4746,8 +4779,9 @@ static void ShowDemoWindowTables()
|
||||
}
|
||||
|
||||
// Create the real table we care about for the example!
|
||||
// We use a scrolling table to be able to showcase the difference between the _IsEnabled and _IsVisible flags above, otherwise in
|
||||
// a non-scrolling table columns are always visible (unless using ImGuiTableFlags_NoKeepColumnsVisible + resizing the parent window down)
|
||||
// We use a scrolling table to be able to showcase the difference between the _IsEnabled and _IsVisible flags above,
|
||||
// otherwise in a non-scrolling table columns are always visible (unless using ImGuiTableFlags_NoKeepColumnsVisible
|
||||
// + resizing the parent window down).
|
||||
const ImGuiTableFlags flags
|
||||
= ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY
|
||||
| ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV
|
||||
@ -4769,7 +4803,8 @@ static void ShowDemoWindowTables()
|
||||
float indent_step = (float)((int)TEXT_BASE_WIDTH / 2);
|
||||
for (int row = 0; row < 8; row++)
|
||||
{
|
||||
ImGui::Indent(indent_step); // Add some indentation to demonstrate usage of per-column IndentEnable/IndentDisable flags.
|
||||
// Add some indentation to demonstrate usage of per-column IndentEnable/IndentDisable flags.
|
||||
ImGui::Indent(indent_step);
|
||||
ImGui::TableNextRow();
|
||||
for (int column = 0; column < column_count; column++)
|
||||
{
|
||||
@ -4818,7 +4853,9 @@ static void ShowDemoWindowTables()
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
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.");
|
||||
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.");
|
||||
|
||||
static ImGuiTableFlags flags2 = ImGuiTableFlags_None;
|
||||
PushStyleCompact();
|
||||
@ -4828,7 +4865,8 @@ static void ShowDemoWindowTables()
|
||||
PopStyleCompact();
|
||||
if (ImGui::BeginTable("table2", 4, flags2))
|
||||
{
|
||||
// We could also set ImGuiTableFlags_SizingFixedFit on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed.
|
||||
// We could also set ImGuiTableFlags_SizingFixedFit on the table and then all columns
|
||||
// will default to ImGuiTableColumnFlags_WidthFixed.
|
||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 100.0f);
|
||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 15.0f);
|
||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 30.0f);
|
||||
@ -4900,7 +4938,10 @@ static void ShowDemoWindowTables()
|
||||
IMGUI_DEMO_MARKER("Tables/Row height");
|
||||
if (ImGui::TreeNode("Row height"))
|
||||
{
|
||||
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 require a unique clipping rectangle per row.");
|
||||
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\n"
|
||||
"We cannot honor a _maximum_ row height as that would require a unique clipping rectangle per row.");
|
||||
if (ImGui::BeginTable("table_row_height", 1, ImGuiTableFlags_Borders))
|
||||
{
|
||||
for (int row = 0; row < 8; row++)
|
||||
@ -4913,7 +4954,10 @@ static void ShowDemoWindowTables()
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
HelpMarker("Showcase using SameLine(0,0) to share Current Line Height between cells.\n\nPlease note that Tables Row Height is not the same thing as Current Line Height, as a table cell may contains multiple lines.");
|
||||
HelpMarker(
|
||||
"Showcase using SameLine(0,0) to share Current Line Height between cells.\n\n"
|
||||
"Please note that Tables Row Height is not the same thing as Current Line Height, "
|
||||
"as a table cell may contains multiple lines.");
|
||||
if (ImGui::BeginTable("table_share_lineheight", 2, ImGuiTableFlags_Borders))
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
@ -5163,7 +5207,8 @@ static void ShowDemoWindowTables()
|
||||
{
|
||||
HelpMarker(
|
||||
"Showcase using PushItemWidth() and how it is preserved on a per-column basis.\n\n"
|
||||
"Note that on auto-resizing non-resizable fixed columns, querying the content width for e.g. right-alignment doesn't make sense.");
|
||||
"Note that on auto-resizing non-resizable fixed columns, querying the content width for "
|
||||
"e.g. right-alignment doesn't make sense.");
|
||||
if (ImGui::BeginTable("table_item_width", 3, ImGuiTableFlags_Borders))
|
||||
{
|
||||
ImGui::TableSetupColumn("small");
|
||||
@ -5302,13 +5347,16 @@ static void ShowDemoWindowTables()
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
// Demonstrate creating custom context menus inside columns, while playing it nice with context menus provided by TableHeadersRow()/TableHeader()
|
||||
// Demonstrate creating custom context menus inside columns,
|
||||
// while playing it nice with context menus provided by TableHeadersRow()/TableHeader()
|
||||
if (open_action != -1)
|
||||
ImGui::SetNextItemOpen(open_action != 0);
|
||||
IMGUI_DEMO_MARKER("Tables/Context menus");
|
||||
if (ImGui::TreeNode("Context menus"))
|
||||
{
|
||||
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.");
|
||||
HelpMarker(
|
||||
"By default, right-clicking over a TableHeadersRow()/TableHeader() line will open the default context-menu.\n"
|
||||
"Using ImGuiTableFlags_ContextMenuInBody we also allow right-clicking over columns body.");
|
||||
static ImGuiTableFlags flags1 = ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders | ImGuiTableFlags_ContextMenuInBody;
|
||||
|
||||
PushStyleCompact();
|
||||
@ -5345,7 +5393,9 @@ static void ShowDemoWindowTables()
|
||||
// [2.1] Right-click on the TableHeadersRow() line to open the default table context menu.
|
||||
// [2.2] Right-click on the ".." to open a custom popup
|
||||
// [2.3] Right-click in columns to open another custom popup
|
||||
HelpMarker("Demonstrate mixing table context menu (over header), item context button (over button) and custom per-colum context menu (over column body).");
|
||||
HelpMarker(
|
||||
"Demonstrate mixing table context menu (over header), item context button (over button) "
|
||||
"and custom per-colunm context menu (over column body).");
|
||||
ImGuiTableFlags flags2 = ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders;
|
||||
if (ImGui::BeginTable("table_context_menu_2", COLUMNS_COUNT, flags2))
|
||||
{
|
||||
@ -5804,7 +5854,7 @@ static void ShowDemoWindowTables()
|
||||
// Here we demonstrate marking our data set as needing to be sorted again if we modified a quantity,
|
||||
// and we are currently sorting on the column showing the Quantity.
|
||||
// To avoid triggering a sort while holding the button, we only trigger it when the button has been released.
|
||||
// You will probably need a more advanced system in your code if you want to automatically sort when a specific entry changes.
|
||||
// You will probably need some extra logic if you want to automatically sort when a specific entry changes.
|
||||
if (ImGui::TableSetColumnIndex(2))
|
||||
{
|
||||
if (ImGui::SmallButton("Chop")) { item->Quantity += 1; }
|
||||
@ -6092,8 +6142,10 @@ static void ShowDemoWindowInputs()
|
||||
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]); }
|
||||
ImGui::Text("Mouse wheel: %.1f", io.MouseWheel);
|
||||
|
||||
// We iterate both legacy native range and named ImGuiKey ranges, which is a little odd but this allows displaying the data for old/new backends.
|
||||
// User code should never have to go through such hoops! You can generally iterate between ImGuiKey_NamedKey_BEGIN and ImGuiKey_NamedKey_END.
|
||||
// We iterate both legacy native range and named ImGuiKey ranges. This is a little unusual/odd but this allows
|
||||
// displaying the data for old/new backends.
|
||||
// User code should never have to go through such hoops!
|
||||
// You can generally iterate between ImGuiKey_NamedKey_BEGIN and ImGuiKey_NamedKey_END.
|
||||
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||
struct funcs { static bool IsLegacyNativeDupe(ImGuiKey) { return false; } };
|
||||
ImGuiKey start_key = ImGuiKey_NamedKey_BEGIN;
|
||||
@ -6132,7 +6184,8 @@ static void ShowDemoWindowInputs()
|
||||
{
|
||||
HelpMarker(
|
||||
"Hovering the colored canvas will override io.WantCaptureXXX fields.\n"
|
||||
"Notice how normally (when set to none), the value of io.WantCaptureKeyboard would be false when hovering and true when clicking.");
|
||||
"Notice how normally (when set to none), the value of io.WantCaptureKeyboard would be false when hovering "
|
||||
"and true when clicking.");
|
||||
static int capture_override_mouse = -1;
|
||||
static int capture_override_keyboard = -1;
|
||||
const char* capture_override_desc[] = { "None", "Set to false", "Set to true" };
|
||||
|
@ -1007,6 +1007,8 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, ImS6
|
||||
return held;
|
||||
}
|
||||
|
||||
// - Read about ImTextureID here: https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples
|
||||
// - 'uv0' and 'uv1' are texture coordinates. Read about them from the same link above.
|
||||
void ImGui::Image(ImTextureID user_texture_id, const ImVec2& image_size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
|
Loading…
Reference in New Issue
Block a user