mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Refactored rare transient bool stacks into a set of flags, added unexposed ImGuiItemFlags_SelectableDontClosePopup (#323)
This commit is contained in:
@ -47,6 +47,7 @@ typedef int ImGuiLayoutType; // enum ImGuiLayoutType_
|
||||
typedef int ImGuiButtonFlags; // enum ImGuiButtonFlags_
|
||||
typedef int ImGuiTreeNodeFlags; // enum ImGuiTreeNodeFlags_
|
||||
typedef int ImGuiSliderFlags; // enum ImGuiSliderFlags_
|
||||
typedef int ImGuiItemFlags; // enum ImGuiItemFlags_
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// STB libraries
|
||||
@ -574,6 +575,16 @@ struct ImGuiContext
|
||||
}
|
||||
};
|
||||
|
||||
// Transient per-window flags, reset at the beginning of the frame. For child window, inherited from parent on first Begin().
|
||||
enum ImGuiItemFlags_
|
||||
{
|
||||
ImGuiItemFlags_AllowKeyboardFocus = 1 << 0, // [true]
|
||||
ImGuiItemFlags_AllowNavDefaultFocus = 1 << 1, // [true]
|
||||
ImGuiItemFlags_ButtonRepeat = 1 << 2, // [false] // Button() can be held will a repeat behavior
|
||||
ImGuiItemFlags_SelectableDontClosePopup = 1 << 3, // [false] // MenuItem/Selectable() automatically closes owner Popup window
|
||||
ImGuiItemFlags_Default_ = ImGuiItemFlags_AllowKeyboardFocus|ImGuiItemFlags_AllowNavDefaultFocus
|
||||
};
|
||||
|
||||
// Transient per-window data, reset at the beginning of the frame
|
||||
// FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiDrawContext is quite tenuous and could be reconsidered.
|
||||
struct IMGUI_API ImGuiDrawContext
|
||||
@ -602,15 +613,12 @@ struct IMGUI_API ImGuiDrawContext
|
||||
ImGuiLayoutType LayoutType;
|
||||
|
||||
// We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.
|
||||
ImGuiItemFlags ItemFlags; // == ItemFlagsStack.back() [empty == ImGuiItemFlags_Default]
|
||||
float ItemWidth; // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
|
||||
float TextWrapPos; // == TextWrapPosStack.back() [empty == -1.0f]
|
||||
bool AllowKeyboardFocus; // == AllowKeyboardFocusStack.back() [empty == true]
|
||||
bool AllowNavDefaultFocus; // (not exposed via stack)
|
||||
bool ButtonRepeat; // == ButtonRepeatStack.back() [empty == false]
|
||||
ImVector<ImGuiItemFlags>ItemFlagsStack;
|
||||
ImVector<float> ItemWidthStack;
|
||||
ImVector<float> TextWrapPosStack;
|
||||
ImVector<bool> AllowKeyboardFocusStack;
|
||||
ImVector<bool> ButtonRepeatStack;
|
||||
ImVector<ImGuiGroupData>GroupStack;
|
||||
ImGuiColorEditMode ColorEditMode;
|
||||
int StackSizesBackup[6]; // Store size of various stacks for asserting
|
||||
@ -647,8 +655,7 @@ struct IMGUI_API ImGuiDrawContext
|
||||
StateStorage = NULL;
|
||||
LayoutType = ImGuiLayoutType_Vertical;
|
||||
ItemWidth = 0.0f;
|
||||
ButtonRepeat = false;
|
||||
AllowKeyboardFocus = AllowNavDefaultFocus = true;
|
||||
ItemFlags = ImGuiItemFlags_Default_;
|
||||
TextWrapPos = -1.0f;
|
||||
ColorEditMode = ImGuiColorEditMode_RGB;
|
||||
memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
|
||||
@ -782,8 +789,9 @@ namespace ImGui
|
||||
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_x, float default_y);
|
||||
IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
|
||||
|
||||
IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled);
|
||||
IMGUI_API void PopItemFlag();
|
||||
IMGUI_API void OpenPopupEx(const char* str_id, bool reopen_existing);
|
||||
|
||||
IMGUI_API int CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate);
|
||||
|
||||
// NB: All position are in absolute pixels coordinates (not window coordinates)
|
||||
|
Reference in New Issue
Block a user