@ -185,12 +185,11 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
- combo: flag for BeginCombo to not return true when unchanged (#1182)
- combo: a way/helper to customize the combo preview (#1658)
- combo/listbox: keyboard control. need InputText-like non-active focus + key handling. considering keyboard for custom listbox (pr #203)
- listbox: refactor and clean the begin/end api
- listbox: multiple selection.
- listbox: unselect option (#1208)
- listbox: make it easier/more natural to implement range-select (need some sort of info/ref about the last clicked/focused item that user can translate to an index?) (wip stash)
- listbox: user may want to initial scroll to focus on the one selected value?
- listbox: expose hovered item for a basic ListBox
- listbox: expose hovered item for a simplified ListBox api
- listbox: keyboard navigation.
- listbox: disable capturing mouse wheel if the listbox has no scrolling. (#1681)
- listbox: scrolling should track modified selection.
// - The BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items.
// - The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose.
// - The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose. This is analogous to how ListBox are created.
IMGUI_APIboolSelectable(constchar*label,bool*p_selected,ImGuiSelectableFlagsflags=0,constImVec2&size=ImVec2(0,0));// "bool* p_selected" point to the selection state (read-write), as a convenient helper.
// Widgets: List Boxes
// - FIXME: To be consistent with all the newer API, ListBoxHeader/ListBoxFooter should in reality be called BeginListBox/EndListBox. Will rename them.
// - This is essentially a thin wrapper to using BeginChild/EndChild with some stylistic changes.
// - 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.
// - 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 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
IMGUI_APIboolBeginListBox(constchar*label,constImVec2&size=ImVec2(0,0));// open a framed scrolling region
IMGUI_APIvoidEndListBox();// only call EndListBox() if BeginListBox() returned true!
IMGUI_APIboolListBoxHeader(constchar*label,constImVec2&size=ImVec2(0,0));// use if you want to reimplement ListBox() will custom data or interactions. if the function return true, you can output elements then call ListBoxFooter() afterwards.
staticinlinevoidOpenPopupContextItem(constchar*str_id=NULL,ImGuiMouseButtonmb=1){OpenPopupOnItemClick(str_id,mb);}// Bool return value removed. Use IsWindowAppearing() in BeginPopup() instead. Renamed in 1.77, renamed back in 1.79. Sorry!
"Refer to the \"Combo\" section below for an explanation of the full BeginCombo/EndCombo API, "
"and demonstration of various flags.\n");
"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 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.");
// FIXME: In principle this function should be called BeginListBox(). We should rename it after re-evaluating if we want to keep the same signature.
// 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).
// FIXME: In principle this function should be called EndListBox(). We should rename it after re-evaluating if we want to keep the same signature.
voidImGui::ListBoxFooter()
voidImGui::EndListBox()
{
ImGuiContext&g=*GImGui;
ImGuiWindow*window=g.CurrentWindow;
IM_ASSERT((window->Flags&ImGuiWindowFlags_ChildWindow)&&"Mismatched ListBoxHeader/ListBoxFooter calls. Did you test the return value of ListBoxHeader()?");
IM_ASSERT((window->Flags&ImGuiWindowFlags_ChildWindow)&&"Mismatched BeginListBox/EndListBox calls. Did you test the return value of BeginListBox?");
EndChildFrame();
EndGroup();// This is only required to be able to do IsItemXXX query on the whole ListBox including label
// Assume all items have even height (= 1 line of text). If you need items of different height,
// you can create a custom version of ListBox() in your code without using the clipper.
ImGuiContext&g=*GImGui;
boolvalue_changed=false;
ImGuiListClipperclipper;
clipper.Begin(items_count,GetTextLineHeightWithSpacing());// We know exactly our line height here so we pass it as a minor optimization, but generally you don't need to.