mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-04 07:01:04 +01:00 
			
		
		
		
	Renamed ImGuiKeyModFlags to ImGuiModFlags (Breaking but technically never advertised type)
This commit is contained in:
		@@ -37,6 +37,9 @@ HOW TO UPDATE?
 | 
			
		||||
 | 
			
		||||
Breaking changes:
 | 
			
		||||
 | 
			
		||||
- Renamed ImGuiKeyModFlags to ImGuiModFlags. Kept inline redirection enums (will obsolete).
 | 
			
		||||
  (This was never used in public API functions but technically present in imgui.h and ImGuiIO).
 | 
			
		||||
 | 
			
		||||
Other Changes:
 | 
			
		||||
 | 
			
		||||
- IO: Fixed backward-compatibility regression introduced in 1.87: (#4921, #4858)
 | 
			
		||||
@@ -340,7 +343,7 @@ If you are stuck on ancient compiler you may need to stay at this version onward
 | 
			
		||||
 | 
			
		||||
Breaking Changes:
 | 
			
		||||
 | 
			
		||||
- Removed GetWindowContentRegionWidth() function. keep inline redirection helper.
 | 
			
		||||
- Removed GetWindowContentRegionWidth() function. Keep inline redirection helper.
 | 
			
		||||
  Can use 'GetWindowContentRegionMax().x - GetWindowContentRegionMin().x' instead but it's not
 | 
			
		||||
  very useful in practice, and the only use of it in the demo was illfit.
 | 
			
		||||
  Using 'GetContentRegionAvail().x' is generally a better choice.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										28
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -385,6 +385,7 @@ CODE
 | 
			
		||||
 When you are not sure about an old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
 | 
			
		||||
 You can read releases logs https://github.com/ocornut/imgui/releases for more details.
 | 
			
		||||
 | 
			
		||||
 - 2022/04/05 (1.88) - inputs: renamed ImGuiKeyModFlags to ImGuiModFlags. Kept inline redirection enums (will obsolete). This was never used in public API functions but technically present in imgui.h and ImGuiIO.
 | 
			
		||||
 - 2022/01/20 (1.87) - inputs: reworded gamepad IO.
 | 
			
		||||
                        - Backend writing to io.NavInputs[]            -> backend should call io.AddKeyEvent()/io.AddKeyAnalogEvent() with ImGuiKey_GamepadXXX values.
 | 
			
		||||
 - 2022/01/19 (1.87) - sliders, drags: removed support for legacy arithmetic operators (+,+-,*,/) when inputing text. This doesn't break any api/code but a feature that used to be accessible by end-users (which seemingly no one used).
 | 
			
		||||
@@ -1251,7 +1252,7 @@ void ImGuiIO::ClearInputKeys()
 | 
			
		||||
        KeysData[n].DownDurationPrev = -1.0f;
 | 
			
		||||
    }
 | 
			
		||||
    KeyCtrl = KeyShift = KeyAlt = KeySuper = false;
 | 
			
		||||
    KeyMods = ImGuiKeyModFlags_None;
 | 
			
		||||
    KeyMods = ImGuiModFlags_None;
 | 
			
		||||
    for (int n = 0; n < IM_ARRAYSIZE(NavInputsDownDuration); n++)
 | 
			
		||||
        NavInputsDownDuration[n] = NavInputsDownDurationPrev[n] = -1.0f;
 | 
			
		||||
}
 | 
			
		||||
@@ -3994,7 +3995,7 @@ static void ImGui::UpdateKeyboardInputs()
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    // Synchronize io.KeyMods with individual modifiers io.KeyXXX bools
 | 
			
		||||
    io.KeyMods = GetMergedKeyModFlags();
 | 
			
		||||
    io.KeyMods = GetMergedModFlags();
 | 
			
		||||
 | 
			
		||||
    // Clear gamepad data if disabled
 | 
			
		||||
    if ((io.BackendFlags & ImGuiBackendFlags_HasGamepad) == 0)
 | 
			
		||||
@@ -4246,15 +4247,16 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
 | 
			
		||||
    io.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ImGuiKeyModFlags ImGui::GetMergedKeyModFlags()
 | 
			
		||||
// [Internal] Do not use directly (can read io.KeyMods instead)
 | 
			
		||||
ImGuiModFlags ImGui::GetMergedModFlags()
 | 
			
		||||
{
 | 
			
		||||
    ImGuiContext& g = *GImGui;
 | 
			
		||||
    ImGuiKeyModFlags key_mod_flags = ImGuiKeyModFlags_None;
 | 
			
		||||
    if (g.IO.KeyCtrl)   { key_mod_flags |= ImGuiKeyModFlags_Ctrl; }
 | 
			
		||||
    if (g.IO.KeyShift)  { key_mod_flags |= ImGuiKeyModFlags_Shift; }
 | 
			
		||||
    if (g.IO.KeyAlt)    { key_mod_flags |= ImGuiKeyModFlags_Alt; }
 | 
			
		||||
    if (g.IO.KeySuper)  { key_mod_flags |= ImGuiKeyModFlags_Super; }
 | 
			
		||||
    return key_mod_flags;
 | 
			
		||||
    ImGuiModFlags key_mods = ImGuiModFlags_None;
 | 
			
		||||
    if (g.IO.KeyCtrl)   { key_mods |= ImGuiModFlags_Ctrl; }
 | 
			
		||||
    if (g.IO.KeyShift)  { key_mods |= ImGuiModFlags_Shift; }
 | 
			
		||||
    if (g.IO.KeyAlt)    { key_mods |= ImGuiModFlags_Alt; }
 | 
			
		||||
    if (g.IO.KeySuper)  { key_mods |= ImGuiModFlags_Super; }
 | 
			
		||||
    return key_mods;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ImGui::NewFrame()
 | 
			
		||||
@@ -7897,7 +7899,7 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
 | 
			
		||||
                    if (key == ImGuiKey_ModShift) { io.KeyShift = keydata->Down; }
 | 
			
		||||
                    if (key == ImGuiKey_ModAlt) { io.KeyAlt = keydata->Down; }
 | 
			
		||||
                    if (key == ImGuiKey_ModSuper) { io.KeySuper = keydata->Down; }
 | 
			
		||||
                    io.KeyMods = GetMergedKeyModFlags();
 | 
			
		||||
                    io.KeyMods = GetMergedModFlags();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                // Allow legacy code using io.KeysDown[GetKeyIndex()] with new backends
 | 
			
		||||
@@ -8030,9 +8032,9 @@ static void ImGui::ErrorCheckEndFrameSanityChecks()
 | 
			
		||||
    // send key release events mid-frame. This would normally trigger this assertion and lead to sheared inputs.
 | 
			
		||||
    // We silently accommodate for this case by ignoring/ the case where all io.KeyXXX modifiers were released (aka key_mod_flags == 0),
 | 
			
		||||
    // while still correctly asserting on mid-frame key press events.
 | 
			
		||||
    const ImGuiKeyModFlags key_mod_flags = GetMergedKeyModFlags();
 | 
			
		||||
    IM_ASSERT((key_mod_flags == 0 || g.IO.KeyMods == key_mod_flags) && "Mismatching io.KeyCtrl/io.KeyShift/io.KeyAlt/io.KeySuper vs io.KeyMods");
 | 
			
		||||
    IM_UNUSED(key_mod_flags);
 | 
			
		||||
    const ImGuiModFlags key_mods = GetMergedModFlags();
 | 
			
		||||
    IM_ASSERT((key_mods == 0 || g.IO.KeyMods == key_mods) && "Mismatching io.KeyCtrl/io.KeyShift/io.KeyAlt/io.KeySuper vs io.KeyMods");
 | 
			
		||||
    IM_UNUSED(key_mods);
 | 
			
		||||
 | 
			
		||||
    // [EXPERIMENTAL] Recover from errors: You may call this yourself before EndFrame().
 | 
			
		||||
    //ErrorCheckEndFrameRecover();
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										22
									
								
								imgui.h
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								imgui.h
									
									
									
									
									
								
							@@ -65,7 +65,7 @@ Index of this file:
 | 
			
		||||
// Version
 | 
			
		||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
 | 
			
		||||
#define IMGUI_VERSION               "1.88 WIP"
 | 
			
		||||
#define IMGUI_VERSION_NUM           18715
 | 
			
		||||
#define IMGUI_VERSION_NUM           18716
 | 
			
		||||
#define IMGUI_CHECKVERSION()        ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
 | 
			
		||||
#define IMGUI_HAS_TABLE
 | 
			
		||||
 | 
			
		||||
@@ -189,7 +189,7 @@ typedef int ImGuiDragDropFlags;     // -> enum ImGuiDragDropFlags_   // Flags: f
 | 
			
		||||
typedef int ImGuiFocusedFlags;      // -> enum ImGuiFocusedFlags_    // Flags: for IsWindowFocused()
 | 
			
		||||
typedef int ImGuiHoveredFlags;      // -> enum ImGuiHoveredFlags_    // Flags: for IsItemHovered(), IsWindowHovered() etc.
 | 
			
		||||
typedef int ImGuiInputTextFlags;    // -> enum ImGuiInputTextFlags_  // Flags: for InputText(), InputTextMultiline()
 | 
			
		||||
typedef int ImGuiKeyModFlags;       // -> enum ImGuiKeyModFlags_     // Flags: for io.KeyMods (Ctrl/Shift/Alt/Super)
 | 
			
		||||
typedef int ImGuiModFlags;          // -> enum ImGuiModFlags_        // Flags: for io.KeyMods (Ctrl/Shift/Alt/Super)
 | 
			
		||||
typedef int ImGuiPopupFlags;        // -> enum ImGuiPopupFlags_      // Flags: for OpenPopup*(), BeginPopupContext*(), IsPopupOpen()
 | 
			
		||||
typedef int ImGuiSelectableFlags;   // -> enum ImGuiSelectableFlags_ // Flags: for Selectable()
 | 
			
		||||
typedef int ImGuiSliderFlags;       // -> enum ImGuiSliderFlags_     // Flags: for DragFloat(), DragInt(), SliderFloat(), SliderInt() etc.
 | 
			
		||||
@@ -1452,13 +1452,13 @@ enum ImGuiKey_
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Helper "flags" version of key-mods to store and compare multiple key-mods easily. Sometimes used for storage (e.g. io.KeyMods) but otherwise not much used in public API.
 | 
			
		||||
enum ImGuiKeyModFlags_
 | 
			
		||||
enum ImGuiModFlags_
 | 
			
		||||
{
 | 
			
		||||
    ImGuiKeyModFlags_None           = 0,
 | 
			
		||||
    ImGuiKeyModFlags_Ctrl           = 1 << 0,
 | 
			
		||||
    ImGuiKeyModFlags_Shift          = 1 << 1,
 | 
			
		||||
    ImGuiKeyModFlags_Alt            = 1 << 2,
 | 
			
		||||
    ImGuiKeyModFlags_Super          = 1 << 3    // Cmd/Super/Windows key
 | 
			
		||||
    ImGuiModFlags_None              = 0,
 | 
			
		||||
    ImGuiModFlags_Ctrl              = 1 << 0,
 | 
			
		||||
    ImGuiModFlags_Shift             = 1 << 1,
 | 
			
		||||
    ImGuiModFlags_Alt               = 1 << 2,   // Menu
 | 
			
		||||
    ImGuiModFlags_Super             = 1 << 3    // Cmd/Super/Windows key
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Gamepad/Keyboard navigation
 | 
			
		||||
@@ -2025,7 +2025,7 @@ struct ImGuiIO
 | 
			
		||||
    float       NavInputs[ImGuiNavInput_COUNT];     // Gamepad inputs. Cleared back to zero by EndFrame(). Keyboard keys will be auto-mapped and be written here by NewFrame().
 | 
			
		||||
 | 
			
		||||
    // Other state maintained from data above + IO function calls
 | 
			
		||||
    ImGuiKeyModFlags KeyMods;                       // Key mods flags (same as io.KeyCtrl/KeyShift/KeyAlt/KeySuper but merged into flags), updated by NewFrame()
 | 
			
		||||
    ImGuiModFlags KeyMods;                          // Key mods flags (same as io.KeyCtrl/KeyShift/KeyAlt/KeySuper but merged into flags), updated by NewFrame()
 | 
			
		||||
    ImGuiKeyData KeysData[ImGuiKey_KeysData_SIZE];  // Key state for all known keys. Use IsKeyXXX() functions to access this.
 | 
			
		||||
    bool        WantCaptureMouseUnlessPopupClose;   // Alternative to WantCaptureMouse: (WantCaptureMouse == true && WantCaptureMouseUnlessPopupClose == false) when a click over void is expected to close a popup.
 | 
			
		||||
    ImVec2      MousePosPrev;                       // Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid)
 | 
			
		||||
@@ -3018,6 +3018,10 @@ enum ImDrawCornerFlags_
 | 
			
		||||
    ImDrawCornerFlags_Right     = ImDrawCornerFlags_TopRight | ImDrawCornerFlags_BotRight
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// RENAMED ImGuiKeyModFlags -> ImGuiModFlags in 1.88 (from April 2022)
 | 
			
		||||
typedef int ImGuiKeyModFlags;
 | 
			
		||||
enum ImGuiKeyModFlags_ { ImGuiKeyModFlags_None = ImGuiModFlags_None, ImGuiKeyModFlags_Ctrl = ImGuiModFlags_Ctrl, ImGuiKeyModFlags_Shift = ImGuiModFlags_Shift, ImGuiKeyModFlags_Alt = ImGuiModFlags_Alt, ImGuiKeyModFlags_Super = ImGuiModFlags_Super };
 | 
			
		||||
 | 
			
		||||
#endif // #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
 | 
			
		||||
 | 
			
		||||
//-----------------------------------------------------------------------------
 | 
			
		||||
 
 | 
			
		||||
@@ -1658,7 +1658,7 @@ struct ImGuiContext
 | 
			
		||||
    ImGuiActivateFlags      NavActivateFlags;
 | 
			
		||||
    ImGuiID                 NavJustMovedToId;                   // Just navigated to this id (result of a successfully MoveRequest).
 | 
			
		||||
    ImGuiID                 NavJustMovedToFocusScopeId;         // Just navigated to this focus scope id (result of a successfully MoveRequest).
 | 
			
		||||
    ImGuiKeyModFlags        NavJustMovedToKeyMods;
 | 
			
		||||
    ImGuiModFlags           NavJustMovedToKeyMods;
 | 
			
		||||
    ImGuiID                 NavNextActivateId;                  // Set by ActivateItem(), queued until next frame.
 | 
			
		||||
    ImGuiActivateFlags      NavNextActivateFlags;
 | 
			
		||||
    ImGuiInputSource        NavInputSource;                     // Keyboard or Gamepad mode? THIS WILL ONLY BE None or NavGamepad or NavKeyboard.
 | 
			
		||||
@@ -1679,7 +1679,7 @@ struct ImGuiContext
 | 
			
		||||
    bool                    NavMoveForwardToNextFrame;
 | 
			
		||||
    ImGuiNavMoveFlags       NavMoveFlags;
 | 
			
		||||
    ImGuiScrollFlags        NavMoveScrollFlags;
 | 
			
		||||
    ImGuiKeyModFlags        NavMoveKeyMods;
 | 
			
		||||
    ImGuiModFlags           NavMoveKeyMods;
 | 
			
		||||
    ImGuiDir                NavMoveDir;                         // Direction of the move request (left/right/up/down)
 | 
			
		||||
    ImGuiDir                NavMoveDirForDebug;
 | 
			
		||||
    ImGuiDir                NavMoveClipDir;                     // FIXME-NAV: Describe the purpose of this better. Might want to rename?
 | 
			
		||||
@@ -1870,7 +1870,7 @@ struct ImGuiContext
 | 
			
		||||
        NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = NavActivateInputId = 0;
 | 
			
		||||
        NavJustMovedToId = NavJustMovedToFocusScopeId = NavNextActivateId = 0;
 | 
			
		||||
        NavActivateFlags = NavNextActivateFlags = ImGuiActivateFlags_None;
 | 
			
		||||
        NavJustMovedToKeyMods = ImGuiKeyModFlags_None;
 | 
			
		||||
        NavJustMovedToKeyMods = ImGuiModFlags_None;
 | 
			
		||||
        NavInputSource = ImGuiInputSource_None;
 | 
			
		||||
        NavLayer = ImGuiNavLayer_Main;
 | 
			
		||||
        NavIdIsAlive = false;
 | 
			
		||||
@@ -1886,7 +1886,7 @@ struct ImGuiContext
 | 
			
		||||
        NavMoveForwardToNextFrame = false;
 | 
			
		||||
        NavMoveFlags = ImGuiNavMoveFlags_None;
 | 
			
		||||
        NavMoveScrollFlags = ImGuiScrollFlags_None;
 | 
			
		||||
        NavMoveKeyMods = ImGuiKeyModFlags_None;
 | 
			
		||||
        NavMoveKeyMods = ImGuiModFlags_None;
 | 
			
		||||
        NavMoveDir = NavMoveDirForDebug = NavMoveClipDir = ImGuiDir_None;
 | 
			
		||||
        NavScoringDebugCount = 0;
 | 
			
		||||
        NavTabbingDir = 0;
 | 
			
		||||
@@ -2682,7 +2682,7 @@ namespace ImGui
 | 
			
		||||
    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             IsNavInputTest(ImGuiNavInput n, ImGuiInputReadMode rm)      { return (GetNavInputAmount(n, rm) > 0.0f); }
 | 
			
		||||
    IMGUI_API ImGuiKeyModFlags GetMergedKeyModFlags();
 | 
			
		||||
    IMGUI_API ImGuiModFlags GetMergedModFlags();
 | 
			
		||||
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
 | 
			
		||||
    inline bool             IsKeyPressedMap(ImGuiKey key, bool repeat = true)           { IM_ASSERT(IsNamedKey(key)); return IsKeyPressed(key, repeat); } // [removed in 1.87]
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -4265,19 +4265,18 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
 | 
			
		||||
    if (g.ActiveId == id && !g.ActiveIdIsJustActivated && !clear_active_id)
 | 
			
		||||
    {
 | 
			
		||||
        IM_ASSERT(state != NULL);
 | 
			
		||||
        IM_ASSERT(io.KeyMods == GetMergedKeyModFlags() && "Mismatching io.KeyCtrl/io.KeyShift/io.KeyAlt/io.KeySuper vs io.KeyMods"); // We rarely do this check, but if anything let's do it here.
 | 
			
		||||
 | 
			
		||||
        const int row_count_per_page = ImMax((int)((inner_size.y - style.FramePadding.y) / g.FontSize), 1);
 | 
			
		||||
        state->Stb.row_count_per_page = row_count_per_page;
 | 
			
		||||
 | 
			
		||||
        const int k_mask = (io.KeyShift ? STB_TEXTEDIT_K_SHIFT : 0);
 | 
			
		||||
        const bool is_osx = io.ConfigMacOSXBehaviors;
 | 
			
		||||
        const bool is_osx_shift_shortcut = is_osx && (io.KeyMods == (ImGuiKeyModFlags_Super | ImGuiKeyModFlags_Shift));
 | 
			
		||||
        const bool is_osx_shift_shortcut = is_osx && (io.KeyMods == (ImGuiModFlags_Super | ImGuiModFlags_Shift));
 | 
			
		||||
        const bool is_wordmove_key_down = is_osx ? io.KeyAlt : io.KeyCtrl;                     // OS X style: Text editing cursor movement using Alt instead of Ctrl
 | 
			
		||||
        const bool is_startend_key_down = is_osx && io.KeySuper && !io.KeyCtrl && !io.KeyAlt;  // OS X style: Line/Text Start and End using Cmd+Arrows instead of Home/End
 | 
			
		||||
        const bool is_ctrl_key_only = (io.KeyMods == ImGuiKeyModFlags_Ctrl);
 | 
			
		||||
        const bool is_shift_key_only = (io.KeyMods == ImGuiKeyModFlags_Shift);
 | 
			
		||||
        const bool is_shortcut_key = g.IO.ConfigMacOSXBehaviors ? (io.KeyMods == ImGuiKeyModFlags_Super) : (io.KeyMods == ImGuiKeyModFlags_Ctrl);
 | 
			
		||||
        const bool is_ctrl_key_only = (io.KeyMods == ImGuiModFlags_Ctrl);
 | 
			
		||||
        const bool is_shift_key_only = (io.KeyMods == ImGuiModFlags_Shift);
 | 
			
		||||
        const bool is_shortcut_key = g.IO.ConfigMacOSXBehaviors ? (io.KeyMods == ImGuiModFlags_Super) : (io.KeyMods == ImGuiModFlags_Ctrl);
 | 
			
		||||
 | 
			
		||||
        const bool is_cut   = ((is_shortcut_key && IsKeyPressed(ImGuiKey_X)) || (is_shift_key_only && IsKeyPressed(ImGuiKey_Delete))) && !is_readonly && !is_password && (!is_multiline || state->HasSelection());
 | 
			
		||||
        const bool is_copy  = ((is_shortcut_key && IsKeyPressed(ImGuiKey_C)) || (is_ctrl_key_only  && IsKeyPressed(ImGuiKey_Insert))) && !is_password && (!is_multiline || state->HasSelection());
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user