mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-14 17:07:01 +00:00
Popups: added comments, reorganized the functions in imgui.h
This commit is contained in:
parent
6e138504c1
commit
078571b7a9
@ -55,7 +55,7 @@ Other Changes:
|
||||
- Popups: Fix an edge case where programatically closing a popup while clicking on its empty space
|
||||
would attempt to focus it and close other popups. (#2880)
|
||||
- Popups: Fix BeginPopupContextVoid() when clicking over the area made unavailable by a modal. (#1636)
|
||||
- Fix GetGlyphRangesKorean() end-range to end at 0xD7A3 (instead of 0xD79D). (#348, #3217) [@marukrap]
|
||||
- Popups: Clarified some of the comments and function prototypes.
|
||||
- Metrics: Added a "Settings" section with some details about persistent ini settings.
|
||||
- Nav, Menus: Fix vertical wrap-around in menus or popups created with multiple appending calls to
|
||||
BeginMenu()/EndMenu() or BeginPopup/EndPopup(). (#3223, #1207) [@rokups]
|
||||
@ -63,6 +63,7 @@ Other Changes:
|
||||
drag source uses _SourceNoPreviewTooltip flags. (#3160) [@rokups]
|
||||
- Columns: Lower overhead on column switches and switching to background channel.
|
||||
Benefits Columns but was primarily made with Tables in mind!
|
||||
- Fonts: Fix GetGlyphRangesKorean() end-range to end at 0xD7A3 (instead of 0xD79D). (#348, #3217) [@marukrap]
|
||||
- ImDrawList: Fixed an issue where draw command merging or primitive unreserve while crossing the
|
||||
VtxOffset boundary would lead to draw commands with wrong VtxOffset. (#3129, #3163, #3232, #2591)
|
||||
[@thedmd, @Shironekoben, @sergeyn, @ocornut]
|
||||
|
@ -202,11 +202,13 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- listbox: future api should allow to enable horizontal scrolling (#2510)
|
||||
|
||||
!- popups/menus: clarify usage of popups id, how MenuItem/Selectable closing parent popups affects the ID, etc. this is quite fishy needs improvement! (#331, #402)
|
||||
- popups/modal: make modal title bar blink when trying to click outside the modal
|
||||
- modals: make modal title bar blink when trying to click outside the modal
|
||||
- modals: technically speaking, we could make Begin() with ImGuiWindowFlags_Modal work without involving popup. May help untangle a few things, as modals are more like regular windows than popups.
|
||||
- popups: if the popup functions took explicit ImGuiID it would allow the user to manage the scope of those ID. (#331)
|
||||
- popups: clicking outside (to close popup) and holding shouldn't drag window below.
|
||||
- popups: add variant using global identifier similar to Begin/End (#402)
|
||||
- popups: border options. richer api like BeginChild() perhaps? (#197)
|
||||
- popups/modals: although it is sometimes convenient that popups/modals lifetime is owned by imgui, we could also a bool-owned-by-user api as long as Begin() return value testing is enforced.
|
||||
|
||||
- tooltip: drag and drop with tooltip near monitor edges lose/changes its last direction instead of locking one. The drag and drop tooltip should always follow without changing direction.
|
||||
- tooltip: tooltip that doesn't fit in entire screen seems to lose their "last preferred direction" and may teleport when moving mouse.
|
||||
|
@ -7891,7 +7891,7 @@ bool ImGui::OpenPopupContextItem(const char* str_id, ImGuiMouseButton mouse_butt
|
||||
// This is a helper to handle the simplest case of associating one named popup to one given widget.
|
||||
// - You can pass a NULL str_id to use the identifier of the last item.
|
||||
// - You may want to handle this on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters).
|
||||
// - This is essentially the same as calling OpenPopupContextItem() + BeginPopupEx() but written to avoid
|
||||
// - This is essentially the same as calling OpenPopupContextItem() + BeginPopup() but written to avoid
|
||||
// computing the ID twice because BeginPopupContextXXX functions are called very frequently.
|
||||
bool ImGui::BeginPopupContextItem(const char* str_id, ImGuiMouseButton mouse_button)
|
||||
{
|
||||
|
50
imgui.h
50
imgui.h
@ -591,28 +591,34 @@ namespace ImGui
|
||||
IMGUI_API void SetTooltipV(const char* fmt, va_list args) IM_FMTLIST(1);
|
||||
|
||||
// Popups, Modals
|
||||
// The properties of popups windows are:
|
||||
// - They block normal mouse hovering detection outside them. (*1)
|
||||
// - Unless modal, they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
|
||||
// Because hovering detection is disabled outside the popup, when clicking outside the click will not be seen by underlying widgets! (*1)
|
||||
// - Their visibility state (~bool) is held internally by Dear ImGui instead of being held by the programmer as we are used to with regular Begin() calls.
|
||||
// User can manipulate the visibility state by calling OpenPopup(), CloseCurrentPopup() etc.
|
||||
// - We default to use the right mouse (ImGuiMouseButton_Right=1) for the Popup Context functions.
|
||||
// Those three properties are connected: we need to retain popup visibility state in the library because popups may be closed as any time.
|
||||
// (*1) You can bypass that restriction and detect hovering even when normally blocked by a popup.
|
||||
// To do this use the ImGuiHoveredFlags_AllowWhenBlockedByPopup when calling IsItemHovered() or IsWindowHovered().
|
||||
// This is what BeginPopupContextItem() and BeginPopupContextWindow() are doing already, allowing a right-click to reopen another popups without losing the click.
|
||||
// - The BeginPopupContextXXX functions are essentially helpers to do an OpenPopup() in some condition + BeginPopup().
|
||||
IMGUI_API void OpenPopup(const char* str_id); // call to mark popup as open (don't call every frame!). popups are closed when user click outside, or if CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. By default, Selectable()/MenuItem() are calling CloseCurrentPopup(). Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
|
||||
IMGUI_API bool BeginPopup(const char* str_id, ImGuiWindowFlags flags = 0); // return true if the popup is open, and you can start outputting to it. only call EndPopup() if BeginPopup() returns true!
|
||||
IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiMouseButton mouse_button = 1); // helper to open and begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
|
||||
IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiMouseButton mouse_button = 1, bool also_over_items = true); // helper to open and begin popup when clicked on current window.
|
||||
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiMouseButton mouse_button = 1); // helper to open and begin popup when clicked in void (where there are no imgui windows).
|
||||
IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // modal dialog (regular window with title bar, block interactions behind the modal window, can't close the modal window by clicking outside)
|
||||
IMGUI_API void EndPopup(); // only call EndPopup() if BeginPopupXXX() returns true!
|
||||
IMGUI_API bool OpenPopupContextItem(const char* str_id = NULL, ImGuiMouseButton mouse_button = 1); // helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
|
||||
IMGUI_API bool IsPopupOpen(const char* str_id); // return true if the popup is open at the current BeginPopup() level of the popup stack
|
||||
IMGUI_API void CloseCurrentPopup(); // close the popup we have begin-ed into. clicking on a MenuItem or Selectable automatically close the current popup.
|
||||
// - They block normal mouse hovering detection (and therefore most mouse interactions) behind them.
|
||||
// - If not modal: they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
|
||||
// - Their visibility state (~bool) is held internally instead of being held by the programmer as we are used to with regular Begin*() calls.
|
||||
// - The 3 properties above are related: we need to retain popup visibility state in the library because popups may be closed as any time.
|
||||
// - You can bypass the hovering restriction by using ImGuiHoveredFlags_AllowWhenBlockedByPopup when calling IsItemHovered() or IsWindowHovered().
|
||||
// - IMPORTANT: Popup identifiers are relative to the current ID stack, so OpenPopup and BeginPopup generally needs to be at the same level of the stack.
|
||||
// This is sometimes leading to confusing mistakes. May rework this in the future.
|
||||
// Popups: begin/end functions
|
||||
// - BeginPopup(): query popup state, if open start appending into the window. Call EndPopup() afterwards. ImGuiWindowFlags are forwarded to the window.
|
||||
// - BeginPopupModal(): block every interactions behind the window, cannot be closed by user, add a dimming background, has a title bar.
|
||||
IMGUI_API bool BeginPopup(const char* str_id, ImGuiWindowFlags flags = 0); // return true if the popup is open, and you can start outputting to it.
|
||||
IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // return true if the modal is open, and you can start outputting to it.
|
||||
IMGUI_API void EndPopup(); // only call EndPopup() if BeginPopupXXX() returns true!
|
||||
// Popups: open/close functions
|
||||
// - OpenPopup(): set popup state to open.
|
||||
// - If not modal: they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
|
||||
// - CloseCurrentPopup(): use inside the BeginPopup()/EndPopup() scope to close manually.
|
||||
// - CloseCurrentPopup() is called by default by Selectable()/MenuItem() when activated (FIXME: need some options).
|
||||
IMGUI_API void OpenPopup(const char* str_id); // call to mark popup as open (don't call every frame!).
|
||||
IMGUI_API bool OpenPopupContextItem(const char* str_id = NULL, ImGuiMouseButton mouse_b = 1); // helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
|
||||
IMGUI_API void CloseCurrentPopup(); // manually close the popup we have begin-ed into.
|
||||
IMGUI_API bool IsPopupOpen(const char* str_id); // return true if the popup is open at the current BeginPopup() level of the popup stack
|
||||
// Popups: open+begin combined functions helpers
|
||||
// - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking.
|
||||
// - They are convenient to easily create context menus, hence the name.
|
||||
IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiMouseButton mouse_b = 1); // open+begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
|
||||
IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiMouseButton mouse_b = 1, bool also_over_items = true); // open+begin popup when clicked on current window.
|
||||
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiMouseButton mouse_b = 1); // open+begin popup when clicked in void (where there are no windows).
|
||||
|
||||
// Columns
|
||||
// - You can also use SameLine(pos_x) to mimic simplified columns.
|
||||
|
Loading…
Reference in New Issue
Block a user