mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 21:21:06 +01:00 
			
		
		
		
	WIP Menus: Sub-menus appears over the parent-menu scrollbar if there is one (unsure about that) (#126)
This commit is contained in:
		
							
								
								
									
										13
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -1396,8 +1396,9 @@ public: | ||||
|     float       TitleBarHeight() const                  { return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f; } | ||||
|     ImRect      TitleBarRect() const                    { return ImRect(Pos, Pos + ImVec2(SizeFull.x, TitleBarHeight())); } | ||||
|     float       MenuBarHeight() const                   { return (Flags & ImGuiWindowFlags_MenuBar) ? CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f : 0.0f; } | ||||
|     ImRect      MenuBarRect() const                     { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }  | ||||
|     ImRect      MenuBarRect() const                     { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); } | ||||
|     ImVec2      WindowPadding() const                   { return ((Flags & ImGuiWindowFlags_ChildWindow) && !(Flags & (ImGuiWindowFlags_ShowBorders | ImGuiWindowFlags_ComboBox | ImGuiWindowFlags_Popup))) ? ImVec2(0,0) : GImGui->Style.WindowPadding; } | ||||
|     float       ScrollbarWidth() const                  { return ScrollbarY ? GImGui->Style.ScrollbarWidth : 0.0f; } | ||||
|     ImU32       Color(ImGuiCol idx, float a=1.f) const  { ImVec4 c = GImGui->Style.Colors[idx]; c.w *= GImGui->Style.Alpha * a; return ImGui::ColorConvertFloat4ToU32(c); } | ||||
|     ImU32       Color(const ImVec4& col) const          { ImVec4 c = col; c.w *= GImGui->Style.Alpha; return ImGui::ColorConvertFloat4ToU32(c); } | ||||
| }; | ||||
| @@ -3554,7 +3555,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_ | ||||
|             if (parent_window->DC.MenuBarAppending) | ||||
|                 rect_to_avoid = ImRect(-FLT_MAX, parent_window->Pos.y + parent_window->TitleBarHeight(), FLT_MAX, parent_window->Pos.y + parent_window->TitleBarHeight() + parent_window->MenuBarHeight()); | ||||
|             else | ||||
|                 rect_to_avoid = ImRect(parent_window->Pos.x + 4.0f, -FLT_MAX, parent_window->Pos.x + parent_window->Size.x - 4.0f, FLT_MAX); // We want some overlap to convey the relative depth of each popup (here hard-coded to 4) | ||||
|                 rect_to_avoid = ImRect(parent_window->Pos.x + 4.0f, -FLT_MAX, parent_window->Pos.x + parent_window->Size.x - 4.0f - parent_window->ScrollbarWidth(), FLT_MAX); // We want some overlap to convey the relative depth of each popup (here hard-coded to 4) | ||||
|             window->PosFloat = FindBestWindowPos(window->PosFloat, window->Size, flags, &window->AutoPosLastDirection, rect_to_avoid); | ||||
|         } | ||||
|         else if ((flags & ImGuiWindowFlags_Popup) != 0 && window_appearing_after_being_hidden && !window_pos_set_by_api) | ||||
| @@ -3683,7 +3684,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_ | ||||
|                 else if ((flags & ImGuiWindowFlags_Popup) != 0) | ||||
|                     window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_WindowBg, bg_alpha), window_rounding); | ||||
|                 else if ((flags & ImGuiWindowFlags_ChildWindow) != 0) | ||||
|                     window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size-ImVec2(window->ScrollbarY?style.ScrollbarWidth:0.0f,0.0f), window->Color(ImGuiCol_ChildWindowBg, bg_alpha), window_rounding, window->ScrollbarY ? (1|8) : (0xF)); | ||||
|                     window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size-ImVec2(window->ScrollbarWidth(),0.0f), window->Color(ImGuiCol_ChildWindowBg, bg_alpha), window_rounding, window->ScrollbarY ? (1|8) : (0xF)); | ||||
|                 else | ||||
|                     window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_WindowBg, bg_alpha), window_rounding); | ||||
|             } | ||||
| @@ -4379,8 +4380,7 @@ ImVec2 ImGui::GetContentRegionMax() | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         if (window->ScrollbarY) | ||||
|             mx.x -= GImGui->Style.ScrollbarWidth; | ||||
|         mx.x -= window->ScrollbarWidth(); | ||||
|     } | ||||
|     return mx; | ||||
| } | ||||
| @@ -4395,8 +4395,7 @@ ImVec2 ImGui::GetWindowContentRegionMax() | ||||
| { | ||||
|     ImGuiWindow* window = GetCurrentWindow(); | ||||
|     ImVec2 m = window->Size - window->WindowPadding(); | ||||
|     if (window->ScrollbarY) | ||||
|         m.x -= GImGui->Style.ScrollbarWidth; | ||||
|     m.x -= window->ScrollbarWidth(); | ||||
|     return m; | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user