mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 05:01:05 +01:00 
			
		
		
		
	Comments + Internals: Selectable: decoupled internal flags and removed their menu / menu-item semantic as upcoming changes are requiring more flexibility.
This commit is contained in:
		
							
								
								
									
										2
									
								
								.github/issue_template.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/issue_template.md
									
									
									
									
										vendored
									
									
								
							| @@ -13,7 +13,7 @@ SELECT "PREVIEW CHANGES" TO TURN THE URL ABOVE INTO A CLICKABLE LINK. | |||||||
|  |  | ||||||
| XXX | XXX | ||||||
|  |  | ||||||
| **Back-end/Renderer/OS:** _(if the question is related to inputs or rendering, otherwise delete this section)_ | **Back-end file/Renderer/OS:** _(if the question is related to inputs/rendering/build, otherwise delete this section)_ | ||||||
|  |  | ||||||
| XXX | XXX | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								TODO.txt
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								TODO.txt
									
									
									
									
									
								
							| @@ -25,6 +25,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i | |||||||
|  - window: increase minimum size of a window with menus or fix the menu rendering so that it doesn't look odd. |  - window: increase minimum size of a window with menus or fix the menu rendering so that it doesn't look odd. | ||||||
|  - window: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon? |  - window: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon? | ||||||
|  - window: expose contents size. (#1045) |  - window: expose contents size. (#1045) | ||||||
|  |  - window: using SetWindowPos() inside Begin() and moving the window with the mouse reacts a very ugly glitch. We should just defer the SetWindowPos() call. | ||||||
|  - window: GetWindowSize() returns (0,0) when not calculated? (#1045) |  - window: GetWindowSize() returns (0,0) when not calculated? (#1045) | ||||||
|  - window: freeze window flag: if not focused/hovered, return false, render with previous ImDrawList. and/or reduce refresh rate.  |  - window: freeze window flag: if not focused/hovered, return false, render with previous ImDrawList. and/or reduce refresh rate.  | ||||||
| !- scrolling: allow immediately effective change of scroll after Begin() if we haven't appended items yet. | !- scrolling: allow immediately effective change of scroll after Begin() if we haven't appended items yet. | ||||||
| @@ -39,6 +40,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i | |||||||
|  - drawlist: would be good to be able to deep copy of ImDrawData (we have a deep copy of ImDrawList now). |  - drawlist: would be good to be able to deep copy of ImDrawData (we have a deep copy of ImDrawList now). | ||||||
|  - drawlist/opt: AddRect() axis aligned pixel aligned (no-aa) could use 8 triangles instead of 16 and no normal calculation. |  - drawlist/opt: AddRect() axis aligned pixel aligned (no-aa) could use 8 triangles instead of 16 and no normal calculation. | ||||||
|  - drawlist: rendering: provide a way for imgui to output to a single/global vertex buffer, re-order indices only at the end of the frame (ref: https://gist.github.com/floooh/10388a0afbe08fce9e617d8aefa7d302) |  - drawlist: rendering: provide a way for imgui to output to a single/global vertex buffer, re-order indices only at the end of the frame (ref: https://gist.github.com/floooh/10388a0afbe08fce9e617d8aefa7d302) | ||||||
|  |  - drawlist: callback: add an extra void* in ImDrawCallback to allow passing render-local data to the callback (would break API). | ||||||
|  |  | ||||||
|  - main: considering adding an Init() function? some constructs are awkward in the implementation because of the lack of them. |  - main: considering adding an Init() function? some constructs are awkward in the implementation because of the lack of them. | ||||||
|  - main: find a way to preserve relative orders of multiple reappearing windows (so an app toggling between "modes" e.g. fullscreen vs all tools) won't lose relative ordering. |  - main: find a way to preserve relative orders of multiple reappearing windows (so an app toggling between "modes" e.g. fullscreen vs all tools) won't lose relative ordering. | ||||||
|   | |||||||
							
								
								
									
										12
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -11220,9 +11220,11 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl | |||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     // We use NoHoldingActiveID on menus so that use can click and hold on menu and drag to browse child entries | ||||||
|     ImGuiButtonFlags button_flags = 0; |     ImGuiButtonFlags button_flags = 0; | ||||||
|     if (flags & ImGuiSelectableFlags_Menu) button_flags |= ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_NoHoldingActiveID; |     if (flags & ImGuiSelectableFlags_NoHoldingActiveID) button_flags |= ImGuiButtonFlags_NoHoldingActiveID; | ||||||
|     if (flags & ImGuiSelectableFlags_MenuItem) button_flags |= ImGuiButtonFlags_PressedOnRelease; |     if (flags & ImGuiSelectableFlags_PressedOnClick) button_flags |= ImGuiButtonFlags_PressedOnClick; | ||||||
|  |     if (flags & ImGuiSelectableFlags_PressedOnRelease) button_flags |= ImGuiButtonFlags_PressedOnRelease; | ||||||
|     if (flags & ImGuiSelectableFlags_Disabled) button_flags |= ImGuiButtonFlags_Disabled; |     if (flags & ImGuiSelectableFlags_Disabled) button_flags |= ImGuiButtonFlags_Disabled; | ||||||
|     if (flags & ImGuiSelectableFlags_AllowDoubleClick) button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick; |     if (flags & ImGuiSelectableFlags_AllowDoubleClick) button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick; | ||||||
|     bool hovered, held; |     bool hovered, held; | ||||||
| @@ -11378,7 +11380,7 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool selected, boo | |||||||
|     ImVec2 pos = window->DC.CursorPos; |     ImVec2 pos = window->DC.CursorPos; | ||||||
|     ImVec2 label_size = CalcTextSize(label, NULL, true); |     ImVec2 label_size = CalcTextSize(label, NULL, true); | ||||||
|  |  | ||||||
|     ImGuiSelectableFlags flags = ImGuiSelectableFlags_MenuItem | (enabled ? 0 : ImGuiSelectableFlags_Disabled); |     ImGuiSelectableFlags flags = ImGuiSelectableFlags_PressedOnRelease | (enabled ? 0 : ImGuiSelectableFlags_Disabled); | ||||||
|     bool pressed; |     bool pressed; | ||||||
|     if (window->DC.LayoutType == ImGuiLayoutType_Horizontal) |     if (window->DC.LayoutType == ImGuiLayoutType_Horizontal) | ||||||
|     { |     { | ||||||
| @@ -11552,7 +11554,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled) | |||||||
|         window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * 0.5f); |         window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * 0.5f); | ||||||
|         PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing * 2.0f); |         PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing * 2.0f); | ||||||
|         float w = label_size.x; |         float w = label_size.x; | ||||||
|         pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_Menu | ImGuiSelectableFlags_DontClosePopups | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f)); |         pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_PressedOnClick | ImGuiSelectableFlags_DontClosePopups | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f)); | ||||||
|         PopStyleVar(); |         PopStyleVar(); | ||||||
|         window->DC.CursorPos.x += (float)(int)(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 += (float)(int)(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(). | ||||||
|     } |     } | ||||||
| @@ -11562,7 +11564,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled) | |||||||
|         popup_pos = ImVec2(pos.x, pos.y - style.WindowPadding.y); |         popup_pos = ImVec2(pos.x, pos.y - style.WindowPadding.y); | ||||||
|         float w = window->MenuColumns.DeclColumns(label_size.x, 0.0f, (float)(int)(g.FontSize * 1.20f)); // Feedback to next frame |         float w = window->MenuColumns.DeclColumns(label_size.x, 0.0f, (float)(int)(g.FontSize * 1.20f)); // Feedback to next frame | ||||||
|         float extra_w = ImMax(0.0f, GetContentRegionAvail().x - w); |         float extra_w = ImMax(0.0f, GetContentRegionAvail().x - w); | ||||||
|         pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_Menu | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_DrawFillAvailWidth | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f)); |         pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_PressedOnClick | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_DrawFillAvailWidth | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f)); | ||||||
|         if (!enabled) PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]); |         if (!enabled) PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]); | ||||||
|         RenderArrow(pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * 0.30f, 0.0f), ImGuiDir_Right); |         RenderArrow(pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * 0.30f, 0.0f), ImGuiDir_Right); | ||||||
|         if (!enabled) PopStyleColor(); |         if (!enabled) PopStyleColor(); | ||||||
|   | |||||||
| @@ -228,10 +228,11 @@ enum ImGuiColumnsFlags_ | |||||||
| enum ImGuiSelectableFlagsPrivate_ | enum ImGuiSelectableFlagsPrivate_ | ||||||
| { | { | ||||||
|     // NB: need to be in sync with last value of ImGuiSelectableFlags_ |     // NB: need to be in sync with last value of ImGuiSelectableFlags_ | ||||||
|     ImGuiSelectableFlags_Menu               = 1 << 3,   // -> PressedOnClick |     ImGuiSelectableFlags_NoHoldingActiveID  = 1 << 3, | ||||||
|     ImGuiSelectableFlags_MenuItem           = 1 << 4,   // -> PressedOnRelease |     ImGuiSelectableFlags_PressedOnClick     = 1 << 4, | ||||||
|     ImGuiSelectableFlags_Disabled           = 1 << 5, |     ImGuiSelectableFlags_PressedOnRelease   = 1 << 5, | ||||||
|     ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 6 |     ImGuiSelectableFlags_Disabled           = 1 << 6, | ||||||
|  |     ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 7 | ||||||
| }; | }; | ||||||
|  |  | ||||||
| enum ImGuiSeparatorFlags_ | enum ImGuiSeparatorFlags_ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user