Menus: rework to allow for an icon column (not yet exposed, but usable via internals) + fix menus being affected by style.SelectableTextAlign (#126)

This commit is contained in:
ocornut
2021-07-08 14:44:32 +02:00
parent 30d164eb26
commit f8fae02270
3 changed files with 62 additions and 24 deletions

View File

@ -1038,13 +1038,15 @@ struct IMGUI_API ImGuiMenuColumns
ImU32 TotalWidth;
ImU32 NextTotalWidth;
ImU16 Spacing;
ImU16 OffsetShortcut; // Offsets are locked in Update()
ImU16 OffsetIcon; // Always zero for now
ImU16 OffsetLabel; // Offsets are locked in Update()
ImU16 OffsetShortcut;
ImU16 OffsetMark;
ImU16 Widths[3]; // Width of: Label, Shortcut, Mark (accumulators for current frame)
ImU16 Widths[4]; // Width of: Icon, Label, Shortcut, Mark (accumulators for current frame)
ImGuiMenuColumns() { memset(this, 0, sizeof(*this)); }
void Update(float spacing, bool window_reappearing);
float DeclColumns(float w_label, float w_shortcut, float w_mark);
float DeclColumns(float w_icon, float w_label, float w_shortcut, float w_mark);
void CalcNextTotalWidth(bool update_offsets);
};
@ -2440,6 +2442,9 @@ namespace ImGui
IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy);
IMGUI_API bool BeginViewportSideBar(const char* name, ImGuiViewport* viewport, ImGuiDir dir, float size, ImGuiWindowFlags window_flags);
// Menus
IMGUI_API bool MenuItemEx(const char* label, const char* icon, const char* shortcut = NULL, bool selected = false, bool enabled = true);
// Combos
IMGUI_API bool BeginComboPopup(ImGuiID popup_id, const ImRect& bb, ImGuiComboFlags flags);
IMGUI_API bool BeginComboPreview();