mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Better documented the difference between BeginListBox() and BeginChild() w/ ImGuiChildFlags_FrameStyle.
BeginListBox() can't yet expose child flags because coarse clipping require query of stored size (same issue as with adding resize support to Tables).
This commit is contained in:
parent
fa4c49b4a7
commit
44345c2108
12
imgui.cpp
12
imgui.cpp
@ -14287,8 +14287,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
Text("KEY OWNERS");
|
Text("KEY OWNERS");
|
||||||
{
|
{
|
||||||
Indent();
|
Indent();
|
||||||
if (BeginListBox("##owners", ImVec2(-FLT_MIN, GetTextLineHeightWithSpacing() * 6)))
|
if (BeginChild("##owners", ImVec2(-FLT_MIN, GetTextLineHeightWithSpacing() * 6), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY, ImGuiWindowFlags_NoSavedSettings))
|
||||||
{
|
|
||||||
for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1))
|
for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1))
|
||||||
{
|
{
|
||||||
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
|
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
|
||||||
@ -14298,15 +14297,13 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
owner_data->LockUntilRelease ? " LockUntilRelease" : owner_data->LockThisFrame ? " LockThisFrame" : "");
|
owner_data->LockUntilRelease ? " LockUntilRelease" : owner_data->LockThisFrame ? " LockThisFrame" : "");
|
||||||
DebugLocateItemOnHover(owner_data->OwnerCurr);
|
DebugLocateItemOnHover(owner_data->OwnerCurr);
|
||||||
}
|
}
|
||||||
EndListBox();
|
EndChild();
|
||||||
}
|
|
||||||
Unindent();
|
Unindent();
|
||||||
}
|
}
|
||||||
Text("SHORTCUT ROUTING");
|
Text("SHORTCUT ROUTING");
|
||||||
{
|
{
|
||||||
Indent();
|
Indent();
|
||||||
if (BeginListBox("##routes", ImVec2(-FLT_MIN, GetTextLineHeightWithSpacing() * 6)))
|
if (BeginChild("##routes", ImVec2(-FLT_MIN, GetTextLineHeightWithSpacing() * 6), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY, ImGuiWindowFlags_NoSavedSettings))
|
||||||
{
|
|
||||||
for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1))
|
for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1))
|
||||||
{
|
{
|
||||||
ImGuiKeyRoutingTable* rt = &g.KeysRoutingTable;
|
ImGuiKeyRoutingTable* rt = &g.KeysRoutingTable;
|
||||||
@ -14320,8 +14317,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
idx = routing_data->NextEntryIndex;
|
idx = routing_data->NextEntryIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EndListBox();
|
EndChild();
|
||||||
}
|
|
||||||
Text("(ActiveIdUsing: AllKeyboardKeys: %d, NavDirMask: 0x%X)", g.ActiveIdUsingAllKeyboardKeys, g.ActiveIdUsingNavDirMask);
|
Text("(ActiveIdUsing: AllKeyboardKeys: %d, NavDirMask: 0x%X)", g.ActiveIdUsingAllKeyboardKeys, g.ActiveIdUsingNavDirMask);
|
||||||
Unindent();
|
Unindent();
|
||||||
}
|
}
|
||||||
|
4
imgui.h
4
imgui.h
@ -635,8 +635,8 @@ namespace ImGui
|
|||||||
IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper.
|
IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper.
|
||||||
|
|
||||||
// Widgets: List Boxes
|
// Widgets: List Boxes
|
||||||
// - This is essentially a thin wrapper to using BeginChild/EndChild with some stylistic changes.
|
// - This is essentially a thin wrapper to using BeginChild/EndChild with the ImGuiChildFlags_FrameStyle flag for stylistic changes + displaying a label.
|
||||||
// - The BeginListBox()/EndListBox() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() or any items.
|
// - You can submit contents and manage your selection state however you want it, by creating e.g. Selectable() or any other items.
|
||||||
// - The simplified/old ListBox() api are helpers over BeginListBox()/EndListBox() which are kept available for convenience purpose. This is analoguous to how Combos are created.
|
// - The simplified/old ListBox() api are helpers over BeginListBox()/EndListBox() which are kept available for convenience purpose. This is analoguous to how Combos are created.
|
||||||
// - Choose frame width: size.x > 0.0f: custom / size.x < 0.0f or -FLT_MIN: right-align / size.x = 0.0f (default): use current ItemWidth
|
// - Choose frame width: size.x > 0.0f: custom / size.x < 0.0f or -FLT_MIN: right-align / size.x = 0.0f (default): use current ItemWidth
|
||||||
// - Choose frame height: size.y > 0.0f: custom / size.y < 0.0f or -FLT_MIN: bottom-align / size.y = 0.0f (default): arbitrary default height which can fit ~7 items
|
// - Choose frame height: size.y > 0.0f: custom / size.y < 0.0f or -FLT_MIN: bottom-align / size.y = 0.0f (default): arbitrary default height which can fit ~7 items
|
||||||
|
@ -1250,6 +1250,9 @@ static void ShowDemoWindowWidgets()
|
|||||||
IMGUI_DEMO_MARKER("Widgets/List Boxes");
|
IMGUI_DEMO_MARKER("Widgets/List Boxes");
|
||||||
if (ImGui::TreeNode("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()).
|
||||||
|
|
||||||
// Using the generic BeginListBox() API, you have full control over how to display the combo contents.
|
// 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
|
// (your selection data could be an index, a pointer to the object, an id for the object, a flag intrusively
|
||||||
// stored in the object itself, etc.)
|
// stored in the object itself, etc.)
|
||||||
|
@ -6863,6 +6863,7 @@ void ImGui::SetNextItemSelectionUserData(ImGuiSelectionUserData selection_user_d
|
|||||||
// - ListBox()
|
// - ListBox()
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// This is essentially a thin wrapper to using BeginChild/EndChild with the ImGuiChildFlags_FrameStyle flag for stylistic changes + displaying a label.
|
||||||
// Tip: To have a list filling the entire window width, use size.x = -FLT_MIN and pass an non-visible label e.g. "##empty"
|
// Tip: To have a list filling the entire window width, use size.x = -FLT_MIN and pass an non-visible label e.g. "##empty"
|
||||||
// Tip: If your vertical size is calculated from an item count (e.g. 10 * item_height) consider adding a fractional part to facilitate seeing scrolling boundaries (e.g. 10.25 * item_height).
|
// Tip: If your vertical size is calculated from an item count (e.g. 10 * item_height) consider adding a fractional part to facilitate seeing scrolling boundaries (e.g. 10.25 * item_height).
|
||||||
bool ImGui::BeginListBox(const char* label, const ImVec2& size_arg)
|
bool ImGui::BeginListBox(const char* label, const ImVec2& size_arg)
|
||||||
@ -6892,7 +6893,7 @@ bool ImGui::BeginListBox(const char* label, const ImVec2& size_arg)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME-OPT: We could omit the BeginGroup() if label_size.x but would need to omit the EndGroup() as well.
|
// FIXME-OPT: We could omit the BeginGroup() if label_size.x == 0.0f but would need to omit the EndGroup() as well.
|
||||||
BeginGroup();
|
BeginGroup();
|
||||||
if (label_size.x > 0.0f)
|
if (label_size.x > 0.0f)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user