mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-03 22:51:06 +01:00 
			
		
		
		
	Merge branch 'master' into navigation
This commit is contained in:
		
							
								
								
									
										27
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -4722,7 +4722,7 @@ bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags)
 | 
			
		||||
    return is_open;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool ImGui::BeginPopup(const char* str_id)
 | 
			
		||||
bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags)
 | 
			
		||||
{
 | 
			
		||||
    ImGuiContext& g = *GImGui;
 | 
			
		||||
    if (g.OpenPopupStack.Size <= g.CurrentPopupStack.Size) // Early out for performance
 | 
			
		||||
@@ -4730,7 +4730,7 @@ bool ImGui::BeginPopup(const char* str_id)
 | 
			
		||||
        g.NextWindowData.Clear(); // We behave like Begin() and need to consume those values
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    return BeginPopupEx(g.CurrentWindow->GetID(str_id), ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
 | 
			
		||||
    return BeginPopupEx(g.CurrentWindow->GetID(str_id), flags|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool ImGui::IsPopupOpen(ImGuiID id)
 | 
			
		||||
@@ -4745,7 +4745,7 @@ bool ImGui::IsPopupOpen(const char* str_id)
 | 
			
		||||
    return g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].PopupId == g.CurrentWindow->GetID(str_id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags extra_flags)
 | 
			
		||||
bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags flags)
 | 
			
		||||
{
 | 
			
		||||
    ImGuiContext& g = *GImGui;
 | 
			
		||||
    ImGuiWindow* window = g.CurrentWindow;
 | 
			
		||||
@@ -4760,8 +4760,7 @@ bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags ext
 | 
			
		||||
    if (g.NextWindowData.PosCond == 0)
 | 
			
		||||
        SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
 | 
			
		||||
 | 
			
		||||
    ImGuiWindowFlags flags = extra_flags|ImGuiWindowFlags_Popup|ImGuiWindowFlags_Modal|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoSavedSettings;
 | 
			
		||||
    bool is_open = Begin(name, p_open, flags);
 | 
			
		||||
    bool is_open = Begin(name, p_open, flags | ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings);
 | 
			
		||||
    if (!is_open || (p_open && !*p_open)) // NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
 | 
			
		||||
    {
 | 
			
		||||
        EndPopup();
 | 
			
		||||
@@ -9709,6 +9708,12 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
 | 
			
		||||
        const bool is_shortcut_key_only = (io.OptMacOSXBehaviors ? (io.KeySuper && !io.KeyCtrl) : (io.KeyCtrl && !io.KeySuper)) && !io.KeyAlt && !io.KeyShift; // OS X style: Shortcuts using Cmd/Super instead of Ctrl
 | 
			
		||||
        const bool is_wordmove_key_down = io.OptMacOSXBehaviors ? io.KeyAlt : io.KeyCtrl;                     // OS X style: Text editing cursor movement using Alt instead of Ctrl
 | 
			
		||||
        const bool is_startend_key_down = io.OptMacOSXBehaviors && 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.KeyCtrl && !io.KeyShift && !io.KeyAlt && !io.KeySuper;
 | 
			
		||||
        const bool is_shift_key_only = io.KeyShift && !io.KeyCtrl && !io.KeyAlt && !io.KeySuper;
 | 
			
		||||
 | 
			
		||||
        const bool is_cut   = ((is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_X)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Delete))) && is_editable && !is_password && (!is_multiline || edit_state.HasSelection());
 | 
			
		||||
        const bool is_copy  = ((is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_C)) || (is_ctrl_key_only  && IsKeyPressedMap(ImGuiKey_Insert))) && !is_password && (!is_multiline || edit_state.HasSelection());
 | 
			
		||||
        const bool is_paste = ((is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_V)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && is_editable;
 | 
			
		||||
 | 
			
		||||
        if (IsKeyPressedMap(ImGuiKey_LeftArrow))                        { edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINESTART : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDLEFT : STB_TEXTEDIT_K_LEFT) | k_mask); }
 | 
			
		||||
        else if (IsKeyPressedMap(ImGuiKey_RightArrow))                  { edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINEEND : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDRIGHT : STB_TEXTEDIT_K_RIGHT) | k_mask); }
 | 
			
		||||
@@ -9750,13 +9755,9 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
 | 
			
		||||
        else if (is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_Z) && is_editable && is_undoable)      { edit_state.OnKeyPressed(STB_TEXTEDIT_K_UNDO); edit_state.ClearSelection(); }
 | 
			
		||||
        else if (is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_Y) && is_editable && is_undoable)      { edit_state.OnKeyPressed(STB_TEXTEDIT_K_REDO); edit_state.ClearSelection(); }
 | 
			
		||||
        else if (is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_A))                                    { edit_state.SelectAll(); edit_state.CursorFollow = true; }
 | 
			
		||||
        else if (is_shortcut_key_only && !is_password && ((IsKeyPressedMap(ImGuiKey_X) && is_editable) || IsKeyPressedMap(ImGuiKey_C)) && (!is_multiline || edit_state.HasSelection()))
 | 
			
		||||
        else if (is_cut || is_copy)
 | 
			
		||||
        {
 | 
			
		||||
            // Cut, Copy
 | 
			
		||||
            const bool cut = IsKeyPressedMap(ImGuiKey_X);
 | 
			
		||||
            if (cut && !edit_state.HasSelection())
 | 
			
		||||
                edit_state.SelectAll();
 | 
			
		||||
 | 
			
		||||
            if (io.SetClipboardTextFn)
 | 
			
		||||
            {
 | 
			
		||||
                const int ib = edit_state.HasSelection() ? ImMin(edit_state.StbState.select_start, edit_state.StbState.select_end) : 0;
 | 
			
		||||
@@ -9766,13 +9767,15 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
 | 
			
		||||
                SetClipboardText(edit_state.TempTextBuffer.Data);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (cut)
 | 
			
		||||
            if (is_cut)
 | 
			
		||||
            {
 | 
			
		||||
                if (!edit_state.HasSelection())
 | 
			
		||||
                    edit_state.SelectAll();
 | 
			
		||||
                edit_state.CursorFollow = true;
 | 
			
		||||
                stb_textedit_cut(&edit_state, &edit_state.StbState);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else if (is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_V) && is_editable)
 | 
			
		||||
        else if (is_paste)
 | 
			
		||||
        {
 | 
			
		||||
            // Paste
 | 
			
		||||
            if (const char* clipboard = GetClipboardText())
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user