mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
Shallow alignment of ImGuiKey stuff + moving some in internals. Internals: add offset to ImBitArray<>, simpify ActiveIdUsingKeyInputMask.
This commit is contained in:
parent
08f3aa8972
commit
8555335935
@ -9182,7 +9182,8 @@ bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
flags |= ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings;
|
flags |= ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings;
|
||||||
return BeginPopupEx(g.CurrentWindow->GetID(str_id), flags);
|
ImGuiID id = g.CurrentWindow->GetID(str_id);
|
||||||
|
return BeginPopupEx(id, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup.
|
// If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup.
|
||||||
@ -12377,8 +12378,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL");
|
Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL");
|
||||||
|
|
||||||
int active_id_using_key_input_count = 0;
|
int active_id_using_key_input_count = 0;
|
||||||
for (int n = 0; n < g.ActiveIdUsingKeyInputMask.Size; n++)
|
for (int n = 0; n < ImGuiKey_NamedKey_COUNT; n++)
|
||||||
active_id_using_key_input_count += g.ActiveIdUsingKeyInputMask.TestBit(n) ? 1 : 0;
|
active_id_using_key_input_count += g.ActiveIdUsingKeyInputMask[n] ? 1 : 0;
|
||||||
Text("ActiveIdUsing: Wheel: %d, NavDirMask: %X, NavInputMask: %X, KeyInputMask: %d key(s)", g.ActiveIdUsingMouseWheel, g.ActiveIdUsingNavDirMask, g.ActiveIdUsingNavInputMask, active_id_using_key_input_count);
|
Text("ActiveIdUsing: Wheel: %d, NavDirMask: %X, NavInputMask: %X, KeyInputMask: %d key(s)", g.ActiveIdUsingMouseWheel, g.ActiveIdUsingNavDirMask, g.ActiveIdUsingNavInputMask, active_id_using_key_input_count);
|
||||||
Text("HoveredId: 0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredIdPreviousFrame, g.HoveredIdTimer, g.HoveredIdAllowOverlap); // Not displaying g.HoveredId as it is update mid-frame
|
Text("HoveredId: 0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredIdPreviousFrame, g.HoveredIdTimer, g.HoveredIdAllowOverlap); // Not displaying g.HoveredId as it is update mid-frame
|
||||||
Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize);
|
Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize);
|
||||||
|
13
imgui.h
13
imgui.h
@ -1343,6 +1343,7 @@ enum ImGuiSortDirection_
|
|||||||
|
|
||||||
enum ImGuiKey_
|
enum ImGuiKey_
|
||||||
{
|
{
|
||||||
|
// Keyboard
|
||||||
ImGuiKey_None = 0,
|
ImGuiKey_None = 0,
|
||||||
ImGuiKey_Tab = 512, // == ImGuiKey_NamedKey_BEGIN
|
ImGuiKey_Tab = 512, // == ImGuiKey_NamedKey_BEGIN
|
||||||
ImGuiKey_LeftArrow,
|
ImGuiKey_LeftArrow,
|
||||||
@ -1394,7 +1395,7 @@ enum ImGuiKey_
|
|||||||
ImGuiKey_KeypadEnter,
|
ImGuiKey_KeypadEnter,
|
||||||
ImGuiKey_KeypadEqual,
|
ImGuiKey_KeypadEqual,
|
||||||
|
|
||||||
// Gamepad (some of those are expected to be analog values from 0.0f to 1.0f) ..............// NAVIGATION action
|
// Gamepad (some of those are analog values, 0.0f to 1.0f) // NAVIGATION action
|
||||||
ImGuiKey_GamepadStart, // Menu (Xbox) + (Switch) Start/Options (PS) // --
|
ImGuiKey_GamepadStart, // Menu (Xbox) + (Switch) Start/Options (PS) // --
|
||||||
ImGuiKey_GamepadBack, // View (Xbox) - (Switch) Share (PS) // --
|
ImGuiKey_GamepadBack, // View (Xbox) - (Switch) Share (PS) // --
|
||||||
ImGuiKey_GamepadFaceUp, // Y (Xbox) X (Switch) Triangle (PS) // -> ImGuiNavInput_Input
|
ImGuiKey_GamepadFaceUp, // Y (Xbox) X (Switch) Triangle (PS) // -> ImGuiNavInput_Input
|
||||||
@ -1422,22 +1423,18 @@ enum ImGuiKey_
|
|||||||
|
|
||||||
ImGuiKey_COUNT, // No valid ImGuiKey is ever greater than this value
|
ImGuiKey_COUNT, // No valid ImGuiKey is ever greater than this value
|
||||||
|
|
||||||
// Legacy range used by legacy io.KeyMap[]. Prior to 1.87 we required user to fill io.KeysDown[512] using their own native index.
|
// [Internal] Prior to 1.87 we required user to fill io.KeysDown[512] using their own native index + a io.KeyMap[] array.
|
||||||
// We are ditching this method but keeping a legacy path for user code doing e.g. IsKeyPressed(MY_NATIVE_KEY_CODE)
|
// We are ditching this method but keeping a legacy path for user code doing e.g. IsKeyPressed(MY_NATIVE_KEY_CODE)
|
||||||
ImGuiKey_LegacyNativeKey_BEGIN = 0,
|
|
||||||
ImGuiKey_LegacyNativeKey_END = 512,
|
|
||||||
ImGuiKey_NamedKey_BEGIN = 512,
|
ImGuiKey_NamedKey_BEGIN = 512,
|
||||||
ImGuiKey_NamedKey_END = ImGuiKey_COUNT,
|
ImGuiKey_NamedKey_END = ImGuiKey_COUNT,
|
||||||
ImGuiKey_NamedKey_COUNT = ImGuiKey_NamedKey_END - ImGuiKey_NamedKey_BEGIN,
|
ImGuiKey_NamedKey_COUNT = ImGuiKey_NamedKey_END - ImGuiKey_NamedKey_BEGIN,
|
||||||
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
|
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||||
ImGuiKey_KeysData_SIZE = ImGuiKey_NamedKey_COUNT, // Size of KeysData[]: only hold named keys
|
ImGuiKey_KeysData_SIZE = ImGuiKey_NamedKey_COUNT, // Size of KeysData[]: only hold named keys
|
||||||
ImGuiKey_KeysData_OFFSET = ImGuiKey_NamedKey_BEGIN, // First key stored in KeysData[0]
|
ImGuiKey_KeysData_OFFSET = ImGuiKey_NamedKey_BEGIN // First key stored in KeysData[0]
|
||||||
#else
|
#else
|
||||||
ImGuiKey_KeysData_SIZE = ImGuiKey_COUNT, // Size of KeysData[]: hold legacy 0..512 keycodes + named keys
|
ImGuiKey_KeysData_SIZE = ImGuiKey_COUNT, // Size of KeysData[]: hold legacy 0..512 keycodes + named keys
|
||||||
ImGuiKey_KeysData_OFFSET = ImGuiKey_LegacyNativeKey_BEGIN, // First key stored in KeysData[0]
|
ImGuiKey_KeysData_OFFSET = 0 // First key stored in KeysData[0]
|
||||||
#endif
|
#endif
|
||||||
ImGuiKey_Gamepad_BEGIN = ImGuiKey_GamepadStart,
|
|
||||||
ImGuiKey_Gamepad_END = ImGuiKey_GamepadRStickRight + 1
|
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
, ImGuiKey_KeyPadEnter = ImGuiKey_KeypadEnter // Renamed in 1.87
|
, ImGuiKey_KeyPadEnter = ImGuiKey_KeypadEnter // Renamed in 1.87
|
||||||
|
@ -5699,15 +5699,15 @@ static void ShowDemoWindowMisc()
|
|||||||
// We iterate both legacy native range and named ImGuiKey ranges, which is a little odd but this allow displaying the data for old/new backends.
|
// We iterate both legacy native range and named ImGuiKey ranges, which is a little odd but this allow displaying the data for old/new backends.
|
||||||
// User code should never have to go through such hoops: old code may use native keycodes, new code may use ImGuiKey codes.
|
// User code should never have to go through such hoops: old code may use native keycodes, new code may use ImGuiKey codes.
|
||||||
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
|
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||||
struct funcs { static bool IsNativeDupe(ImGuiKey) { return false; } };
|
struct funcs { static bool IsLegacyNativeDupe(ImGuiKey) { return false; } };
|
||||||
const ImGuiKey key_first = ImGuiKey_NamedKey_BEGIN;
|
const ImGuiKey key_first = ImGuiKey_NamedKey_BEGIN;
|
||||||
#else
|
#else
|
||||||
struct funcs { static bool IsNativeDupe(ImGuiKey key) { return key < ImGuiKey_LegacyNativeKey_END && ImGui::GetIO().KeyMap[key] != -1; } }; // Hide Native<>ImGuiKey duplicates when both exists in the array
|
struct funcs { static bool IsLegacyNativeDupe(ImGuiKey key) { return key < 512 && ImGui::GetIO().KeyMap[key] != -1; } }; // Hide Native<>ImGuiKey duplicates when both exists in the array
|
||||||
const ImGuiKey key_first = 0;
|
const ImGuiKey key_first = 0;
|
||||||
#endif
|
#endif
|
||||||
ImGui::Text("Keys down:"); for (ImGuiKey key = key_first; key < ImGuiKey_COUNT; key++) { if (funcs::IsNativeDupe(key)) continue; if (ImGui::IsKeyDown(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d (%.02f secs)", ImGui::GetKeyName(key), key, ImGui::GetKeyData(key)->DownDuration); } }
|
ImGui::Text("Keys down:"); for (ImGuiKey key = key_first; key < ImGuiKey_COUNT; key++) { if (funcs::IsLegacyNativeDupe(key)) continue; if (ImGui::IsKeyDown(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d (%.02f secs)", ImGui::GetKeyName(key), key, ImGui::GetKeyData(key)->DownDuration); } }
|
||||||
ImGui::Text("Keys pressed:"); for (ImGuiKey key = key_first; key < ImGuiKey_COUNT; key++) { if (funcs::IsNativeDupe(key)) continue; if (ImGui::IsKeyPressed(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d", ImGui::GetKeyName(key), key); } }
|
ImGui::Text("Keys pressed:"); for (ImGuiKey key = key_first; key < ImGuiKey_COUNT; key++) { if (funcs::IsLegacyNativeDupe(key)) continue; if (ImGui::IsKeyPressed(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d", ImGui::GetKeyName(key), key); } }
|
||||||
ImGui::Text("Keys released:"); for (ImGuiKey key = key_first; key < ImGuiKey_COUNT; key++) { if (funcs::IsNativeDupe(key)) continue; if (ImGui::IsKeyReleased(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d", ImGui::GetKeyName(key), key); } }
|
ImGui::Text("Keys released:"); for (ImGuiKey key = key_first; key < ImGuiKey_COUNT; key++) { if (funcs::IsLegacyNativeDupe(key)) continue; if (ImGui::IsKeyReleased(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d", ImGui::GetKeyName(key), key); } }
|
||||||
ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : "");
|
ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : "");
|
||||||
ImGui::Text("Chars queue:"); for (int i = 0; i < io.InputQueueCharacters.Size; i++) { ImWchar c = io.InputQueueCharacters[i]; ImGui::SameLine(); ImGui::Text("\'%c\' (0x%04X)", (c > ' ' && c <= 255) ? (char)c : '?', c); } // FIXME: We should convert 'c' to UTF-8 here but the functions are not public.
|
ImGui::Text("Chars queue:"); for (int i = 0; i < io.InputQueueCharacters.Size; i++) { ImWchar c = io.InputQueueCharacters[i]; ImGui::SameLine(); ImGui::Text("\'%c\' (0x%04X)", (c > ' ' && c <= 255) ? (char)c : '?', c); } // FIXME: We should convert 'c' to UTF-8 here but the functions are not public.
|
||||||
ImGui::Text("NavInputs down:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputs[i] > 0.0f) { ImGui::SameLine(); ImGui::Text("[%d] %.2f (%.02f secs)", i, io.NavInputs[i], io.NavInputsDownDuration[i]); }
|
ImGui::Text("NavInputs down:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputs[i] > 0.0f) { ImGui::SameLine(); ImGui::Text("[%d] %.2f (%.02f secs)", i, io.NavInputs[i], io.NavInputsDownDuration[i]); }
|
||||||
|
@ -540,21 +540,19 @@ inline void ImBitArraySetBitRange(ImU32* arr, int n, int n2) // Works on ran
|
|||||||
|
|
||||||
// Helper: ImBitArray class (wrapper over ImBitArray functions)
|
// Helper: ImBitArray class (wrapper over ImBitArray functions)
|
||||||
// Store 1-bit per value.
|
// Store 1-bit per value.
|
||||||
template<int BITCOUNT>
|
template<int BITCOUNT, int OFFSET = 0>
|
||||||
struct IMGUI_API ImBitArray
|
struct IMGUI_API ImBitArray
|
||||||
{
|
{
|
||||||
static const int Size = BITCOUNT;
|
|
||||||
ImU32 Storage[(BITCOUNT + 31) >> 5];
|
ImU32 Storage[(BITCOUNT + 31) >> 5];
|
||||||
ImBitArray() { ClearAllBits(); }
|
ImBitArray() { ClearAllBits(); }
|
||||||
void ClearAllBits() { memset(Storage, 0, sizeof(Storage)); }
|
void ClearAllBits() { memset(Storage, 0, sizeof(Storage)); }
|
||||||
void SetAllBits() { memset(Storage, 255, sizeof(Storage)); }
|
void SetAllBits() { memset(Storage, 255, sizeof(Storage)); }
|
||||||
bool TestBit(int n) const { IM_ASSERT(n < BITCOUNT); return ImBitArrayTestBit(Storage, n); }
|
bool TestBit(int n) const { IM_ASSERT(n + OFFSET < BITCOUNT); return ImBitArrayTestBit(Storage, n + OFFSET); }
|
||||||
void SetBit(int n) { IM_ASSERT(n < BITCOUNT); ImBitArraySetBit(Storage, n); }
|
void SetBit(int n) { IM_ASSERT(n + OFFSET < BITCOUNT); ImBitArraySetBit(Storage, n + OFFSET); }
|
||||||
void ClearBit(int n) { IM_ASSERT(n < BITCOUNT); ImBitArrayClearBit(Storage, n); }
|
void ClearBit(int n) { IM_ASSERT(n + OFFSET < BITCOUNT); ImBitArrayClearBit(Storage, n + OFFSET); }
|
||||||
void SetBitRange(int n, int n2) { ImBitArraySetBitRange(Storage, n, n2); } // Works on range [n..n2)
|
void SetBitRange(int n, int n2) { ImBitArraySetBitRange(Storage, n + OFFSET, n2 + OFFSET); } // Works on range [n..n2)
|
||||||
|
bool operator[](int n) const { IM_ASSERT(n + OFFSET < BITCOUNT); return ImBitArrayTestBit(Storage, n + OFFSET); }
|
||||||
};
|
};
|
||||||
template<int BITCOUNT>
|
|
||||||
const int ImBitArray<BITCOUNT>::Size;
|
|
||||||
|
|
||||||
// Helper: ImBitVector
|
// Helper: ImBitVector
|
||||||
// Store 1-bit per value.
|
// Store 1-bit per value.
|
||||||
@ -1157,6 +1155,16 @@ struct ImGuiPtrOrIndex
|
|||||||
// [SECTION] Inputs support
|
// [SECTION] Inputs support
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
typedef ImBitArray<ImGuiKey_NamedKey_COUNT, -ImGuiKey_NamedKey_BEGIN> ImBitArrayForNamedKeys;
|
||||||
|
|
||||||
|
enum ImGuiKeyPrivate_
|
||||||
|
{
|
||||||
|
ImGuiKey_LegacyNativeKey_BEGIN = 0,
|
||||||
|
ImGuiKey_LegacyNativeKey_END = 512,
|
||||||
|
ImGuiKey_Gamepad_BEGIN = ImGuiKey_GamepadStart,
|
||||||
|
ImGuiKey_Gamepad_END = ImGuiKey_GamepadRStickRight + 1
|
||||||
|
};
|
||||||
|
|
||||||
enum ImGuiInputEventType
|
enum ImGuiInputEventType
|
||||||
{
|
{
|
||||||
ImGuiInputEventType_None = 0,
|
ImGuiInputEventType_None = 0,
|
||||||
@ -1605,7 +1613,7 @@ struct ImGuiContext
|
|||||||
bool ActiveIdUsingMouseWheel; // Active widget will want to read mouse wheel. Blocks scrolling the underlying window.
|
bool ActiveIdUsingMouseWheel; // Active widget will want to read mouse wheel. Blocks scrolling the underlying window.
|
||||||
ImU32 ActiveIdUsingNavDirMask; // Active widget will want to read those nav move requests (e.g. can activate a button and move away from it)
|
ImU32 ActiveIdUsingNavDirMask; // Active widget will want to read those nav move requests (e.g. can activate a button and move away from it)
|
||||||
ImU32 ActiveIdUsingNavInputMask; // Active widget will want to read those nav inputs.
|
ImU32 ActiveIdUsingNavInputMask; // Active widget will want to read those nav inputs.
|
||||||
ImBitArray<ImGuiKey_NamedKey_COUNT> ActiveIdUsingKeyInputMask; // Active widget will want to read those key inputs. When we grow the ImGuiKey enum we'll need to either to order the enum to make useful keys come first, either redesign this into e.g. a small array.
|
ImBitArrayForNamedKeys ActiveIdUsingKeyInputMask; // Active widget will want to read those key inputs. When we grow the ImGuiKey enum we'll need to either to order the enum to make useful keys come first, either redesign this into e.g. a small array.
|
||||||
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
||||||
ImGuiWindow* ActiveIdWindow;
|
ImGuiWindow* ActiveIdWindow;
|
||||||
ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
|
ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
|
||||||
@ -2652,8 +2660,8 @@ namespace ImGui
|
|||||||
IMGUI_API void SetActiveIdUsingNavAndKeys();
|
IMGUI_API void SetActiveIdUsingNavAndKeys();
|
||||||
inline bool IsActiveIdUsingNavDir(ImGuiDir dir) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavDirMask & (1 << dir)) != 0; }
|
inline bool IsActiveIdUsingNavDir(ImGuiDir dir) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavDirMask & (1 << dir)) != 0; }
|
||||||
inline bool IsActiveIdUsingNavInput(ImGuiNavInput input) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavInputMask & (1 << input)) != 0; }
|
inline bool IsActiveIdUsingNavInput(ImGuiNavInput input) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavInputMask & (1 << input)) != 0; }
|
||||||
inline bool IsActiveIdUsingKey(ImGuiKey key) { IM_ASSERT(IsNamedKey(key)); ImGuiContext& g = *GImGui; return g.ActiveIdUsingKeyInputMask.TestBit(key - ImGuiKey_NamedKey_BEGIN); }
|
inline bool IsActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; return g.ActiveIdUsingKeyInputMask[key]; }
|
||||||
inline void SetActiveIdUsingKey(ImGuiKey key) { IM_ASSERT(IsNamedKey(key)); ImGuiContext& g = *GImGui; g.ActiveIdUsingKeyInputMask.SetBit(key - ImGuiKey_NamedKey_BEGIN); }
|
inline void SetActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; g.ActiveIdUsingKeyInputMask.SetBit(key); }
|
||||||
IMGUI_API bool IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold = -1.0f);
|
IMGUI_API bool IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold = -1.0f);
|
||||||
inline bool IsNavInputDown(ImGuiNavInput n) { ImGuiContext& g = *GImGui; return g.IO.NavInputs[n] > 0.0f; }
|
inline bool IsNavInputDown(ImGuiNavInput n) { ImGuiContext& g = *GImGui; return g.IO.NavInputs[n] > 0.0f; }
|
||||||
inline bool IsNavInputTest(ImGuiNavInput n, ImGuiInputReadMode rm) { return (GetNavInputAmount(n, rm) > 0.0f); }
|
inline bool IsNavInputTest(ImGuiNavInput n, ImGuiInputReadMode rm) { return (GetNavInputAmount(n, rm) > 0.0f); }
|
||||||
|
@ -6885,6 +6885,7 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
BeginDisabled();
|
BeginDisabled();
|
||||||
const ImGuiMenuColumns* offsets = &window->DC.MenuColumns;
|
const ImGuiMenuColumns* offsets = &window->DC.MenuColumns;
|
||||||
bool pressed;
|
bool pressed;
|
||||||
|
const ImGuiSelectableFlags selectable_flags = ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups;
|
||||||
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
||||||
{
|
{
|
||||||
// Menu inside an horizontal menu bar
|
// Menu inside an horizontal menu bar
|
||||||
@ -6895,7 +6896,7 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y));
|
PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y));
|
||||||
float w = label_size.x;
|
float w = label_size.x;
|
||||||
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
||||||
pressed = Selectable("", menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups, ImVec2(w, 0.0f));
|
pressed = Selectable("", menu_is_open, selectable_flags, ImVec2(w, 0.0f));
|
||||||
RenderText(text_pos, label);
|
RenderText(text_pos, label);
|
||||||
PopStyleVar();
|
PopStyleVar();
|
||||||
window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar().
|
window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar().
|
||||||
@ -6911,7 +6912,7 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, 0.0f, checkmark_w); // Feedback to next frame
|
float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, 0.0f, checkmark_w); // Feedback to next frame
|
||||||
float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
|
float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
|
||||||
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
||||||
pressed = Selectable("", menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, 0.0f));
|
pressed = Selectable("", menu_is_open, selectable_flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, 0.0f));
|
||||||
RenderText(text_pos, label);
|
RenderText(text_pos, label);
|
||||||
if (icon_w > 0.0f)
|
if (icon_w > 0.0f)
|
||||||
RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon);
|
RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon);
|
||||||
|
Loading…
Reference in New Issue
Block a user