mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-03 22:51:06 +01:00 
			
		
		
		
	Tools: Item Picker: Mouse button can be changed by holding Ctrl+Shift. (#2673)
This commit is contained in:
		@@ -43,6 +43,8 @@ Other Changes:
 | 
				
			|||||||
  Enter keep the input active and select all text.
 | 
					  Enter keep the input active and select all text.
 | 
				
			||||||
- Nav: Fixed moving/resizing window with gamepad or keyboard when running at very high framerate.
 | 
					- Nav: Fixed moving/resizing window with gamepad or keyboard when running at very high framerate.
 | 
				
			||||||
- Misc: io.Framerate moving average now converge in 60 frames instead of 120. (#5236, #4138)
 | 
					- Misc: io.Framerate moving average now converge in 60 frames instead of 120. (#5236, #4138)
 | 
				
			||||||
 | 
					- Tools: Item Picker: Mouse button can be changed by holding Ctrl+Shift, making it easier
 | 
				
			||||||
 | 
					  to use the Item Picker in e.g. menus. (#2673)
 | 
				
			||||||
- Backends: Metal: Use __bridge for ARC based systems. (#5403) [@stack]
 | 
					- Backends: Metal: Use __bridge for ARC based systems. (#5403) [@stack]
 | 
				
			||||||
- Backends: Metal: Add dispatch synchronization. (#5447) [@luigifcruz]
 | 
					- Backends: Metal: Add dispatch synchronization. (#5447) [@luigifcruz]
 | 
				
			||||||
- Backends: OSX: Fixes to support full app creation in C++. (#5403) [@stack]
 | 
					- Backends: OSX: Fixes to support full app creation in C++. (#5403) [@stack]
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										14
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -13229,16 +13229,24 @@ void ImGui::UpdateDebugToolItemPicker()
 | 
				
			|||||||
    SetMouseCursor(ImGuiMouseCursor_Hand);
 | 
					    SetMouseCursor(ImGuiMouseCursor_Hand);
 | 
				
			||||||
    if (IsKeyPressed(ImGuiKey_Escape))
 | 
					    if (IsKeyPressed(ImGuiKey_Escape))
 | 
				
			||||||
        g.DebugItemPickerActive = false;
 | 
					        g.DebugItemPickerActive = false;
 | 
				
			||||||
    if (IsMouseClicked(0) && hovered_id)
 | 
					    const bool change_mapping = g.IO.KeyMods == (ImGuiModFlags_Ctrl | ImGuiModFlags_Shift);
 | 
				
			||||||
 | 
					    if (!change_mapping && IsMouseClicked(g.DebugItemPickerMouseButton) && hovered_id)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        g.DebugItemPickerBreakId = hovered_id;
 | 
					        g.DebugItemPickerBreakId = hovered_id;
 | 
				
			||||||
        g.DebugItemPickerActive = false;
 | 
					        g.DebugItemPickerActive = false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    SetNextWindowBgAlpha(0.60f);
 | 
					    for (int mouse_button = 0; mouse_button < 3; mouse_button++)
 | 
				
			||||||
 | 
					        if (change_mapping && IsMouseClicked(mouse_button))
 | 
				
			||||||
 | 
					            g.DebugItemPickerMouseButton = (ImU8)mouse_button;
 | 
				
			||||||
 | 
					    SetNextWindowBgAlpha(0.70f);
 | 
				
			||||||
    BeginTooltip();
 | 
					    BeginTooltip();
 | 
				
			||||||
    Text("HoveredId: 0x%08X", hovered_id);
 | 
					    Text("HoveredId: 0x%08X", hovered_id);
 | 
				
			||||||
    Text("Press ESC to abort picking.");
 | 
					    Text("Press ESC to abort picking.");
 | 
				
			||||||
    TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click to break in debugger!");
 | 
					    const char* mouse_button_names[] = { "Left", "Right", "Middle" };
 | 
				
			||||||
 | 
					    if (change_mapping)
 | 
				
			||||||
 | 
					        Text("Remap w/ Ctrl+Shift: click anywhere to select new mouse button.");
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					        TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click %s Button to break in debugger! (remap w/ Ctrl+Shift)", mouse_button_names[g.DebugItemPickerMouseButton]);
 | 
				
			||||||
    EndTooltip();
 | 
					    EndTooltip();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7805,7 +7805,8 @@ void ShowExampleAppDocuments(bool* p_open)
 | 
				
			|||||||
            if (ImGui::MenuItem("Close All Documents", NULL, false, open_count > 0))
 | 
					            if (ImGui::MenuItem("Close All Documents", NULL, false, open_count > 0))
 | 
				
			||||||
                for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
 | 
					                for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
 | 
				
			||||||
                    app.Documents[doc_n].DoQueueClose();
 | 
					                    app.Documents[doc_n].DoQueueClose();
 | 
				
			||||||
            if (ImGui::MenuItem("Exit", "Alt+F4")) {}
 | 
					            if (ImGui::MenuItem("Exit", "Ctrl+F4") && p_open)
 | 
				
			||||||
 | 
					                *p_open = false;
 | 
				
			||||||
            ImGui::EndMenu();
 | 
					            ImGui::EndMenu();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ImGui::EndMenuBar();
 | 
					        ImGui::EndMenuBar();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1822,6 +1822,7 @@ struct ImGuiContext
 | 
				
			|||||||
    ImGuiDebugLogFlags      DebugLogFlags;
 | 
					    ImGuiDebugLogFlags      DebugLogFlags;
 | 
				
			||||||
    ImGuiTextBuffer         DebugLogBuf;
 | 
					    ImGuiTextBuffer         DebugLogBuf;
 | 
				
			||||||
    bool                    DebugItemPickerActive;              // Item picker is active (started with DebugStartItemPicker())
 | 
					    bool                    DebugItemPickerActive;              // Item picker is active (started with DebugStartItemPicker())
 | 
				
			||||||
 | 
					    ImU8                    DebugItemPickerMouseButton;
 | 
				
			||||||
    ImGuiID                 DebugItemPickerBreakId;             // Will call IM_DEBUG_BREAK() when encountering this ID
 | 
					    ImGuiID                 DebugItemPickerBreakId;             // Will call IM_DEBUG_BREAK() when encountering this ID
 | 
				
			||||||
    ImGuiMetricsConfig      DebugMetricsConfig;
 | 
					    ImGuiMetricsConfig      DebugMetricsConfig;
 | 
				
			||||||
    ImGuiStackTool          DebugStackTool;
 | 
					    ImGuiStackTool          DebugStackTool;
 | 
				
			||||||
@@ -1979,6 +1980,7 @@ struct ImGuiContext
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        DebugLogFlags = ImGuiDebugLogFlags_OutputToTTY;
 | 
					        DebugLogFlags = ImGuiDebugLogFlags_OutputToTTY;
 | 
				
			||||||
        DebugItemPickerActive = false;
 | 
					        DebugItemPickerActive = false;
 | 
				
			||||||
 | 
					        DebugItemPickerMouseButton = ImGuiMouseButton_Left;
 | 
				
			||||||
        DebugItemPickerBreakId = 0;
 | 
					        DebugItemPickerBreakId = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
 | 
					        memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user