mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 05:01:05 +01:00 
			
		
		
		
	ListBoxHeader: In version taking height in number of items, made vertical padding consistent regardless of if (items_count <= height_in_items) or not.
Demo: Tweaks.
This commit is contained in:
		| @@ -56,6 +56,8 @@ Other Changes: | |||||||
| - InputText: Multiline: Fixed padding/cliprect not precisely matching single-line version. (#3781) | - InputText: Multiline: Fixed padding/cliprect not precisely matching single-line version. (#3781) | ||||||
| - InputText: Multiline: Fixed FramePadding.y worth of vertical offset when aiming with mouse. | - InputText: Multiline: Fixed FramePadding.y worth of vertical offset when aiming with mouse. | ||||||
| - ListBox: Tweaked default height calculation. | - ListBox: Tweaked default height calculation. | ||||||
|  | - ListBoxHeader: In version taking height in number of items, made vertical padding consistent regardless  | ||||||
|  |   of if (items_count <= height_in_items) or not. | ||||||
| - Fonts: imgui_freetype: Facilitated using FreeType integration: [@Xipiryon, @ocornut] | - Fonts: imgui_freetype: Facilitated using FreeType integration: [@Xipiryon, @ocornut] | ||||||
|   - Use '#define IMGUI_ENABLE_FREETYPE' in imconfig.h should make it work with no other modifications |   - Use '#define IMGUI_ENABLE_FREETYPE' in imconfig.h should make it work with no other modifications | ||||||
|     other than compiling misc/freetype/imgui_freetype.cpp and linking with FreeType. |     other than compiling misc/freetype/imgui_freetype.cpp and linking with FreeType. | ||||||
|   | |||||||
| @@ -7475,19 +7475,20 @@ void ShowExampleAppDocuments(bool* p_open) | |||||||
|         { |         { | ||||||
|             if (!ImGui::IsPopupOpen("Save?")) |             if (!ImGui::IsPopupOpen("Save?")) | ||||||
|                 ImGui::OpenPopup("Save?"); |                 ImGui::OpenPopup("Save?"); | ||||||
|             if (ImGui::BeginPopupModal("Save?")) |             if (ImGui::BeginPopupModal("Save?", NULL, ImGuiWindowFlags_AlwaysAutoResize)) | ||||||
|             { |             { | ||||||
|                 ImGui::Text("Save change to the following items?"); |                 ImGui::Text("Save change to the following items?"); | ||||||
|                 ImGui::SetNextItemWidth(-FLT_MIN); |                 float item_height = ImGui::GetTextLineHeightWithSpacing(); | ||||||
|                 if (ImGui::ListBoxHeader("##", close_queue_unsaved_documents, 6)) |                 if (ImGui::BeginChildFrame(ImGui::GetID("frame"), ImVec2(-FLT_MIN, 6.25f * item_height))) | ||||||
|                 { |                 { | ||||||
|                     for (int n = 0; n < close_queue.Size; n++) |                     for (int n = 0; n < close_queue.Size; n++) | ||||||
|                         if (close_queue[n]->Dirty) |                         if (close_queue[n]->Dirty) | ||||||
|                             ImGui::Text("%s", close_queue[n]->Name); |                             ImGui::Text("%s", close_queue[n]->Name); | ||||||
|                     ImGui::ListBoxFooter(); |                     ImGui::EndChildFrame(); | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 if (ImGui::Button("Yes", ImVec2(80, 0))) |                 ImVec2 button_size(ImGui::GetFontSize() * 7.0f, 0.0f); | ||||||
|  |                 if (ImGui::Button("Yes", button_size)) | ||||||
|                 { |                 { | ||||||
|                     for (int n = 0; n < close_queue.Size; n++) |                     for (int n = 0; n < close_queue.Size; n++) | ||||||
|                     { |                     { | ||||||
| @@ -7499,7 +7500,7 @@ void ShowExampleAppDocuments(bool* p_open) | |||||||
|                     ImGui::CloseCurrentPopup(); |                     ImGui::CloseCurrentPopup(); | ||||||
|                 } |                 } | ||||||
|                 ImGui::SameLine(); |                 ImGui::SameLine(); | ||||||
|                 if (ImGui::Button("No", ImVec2(80, 0))) |                 if (ImGui::Button("No", button_size)) | ||||||
|                 { |                 { | ||||||
|                     for (int n = 0; n < close_queue.Size; n++) |                     for (int n = 0; n < close_queue.Size; n++) | ||||||
|                         close_queue[n]->DoForceClose(); |                         close_queue[n]->DoForceClose(); | ||||||
| @@ -7507,7 +7508,7 @@ void ShowExampleAppDocuments(bool* p_open) | |||||||
|                     ImGui::CloseCurrentPopup(); |                     ImGui::CloseCurrentPopup(); | ||||||
|                 } |                 } | ||||||
|                 ImGui::SameLine(); |                 ImGui::SameLine(); | ||||||
|                 if (ImGui::Button("Cancel", ImVec2(80, 0))) |                 if (ImGui::Button("Cancel", button_size)) | ||||||
|                 { |                 { | ||||||
|                     close_queue.clear(); |                     close_queue.clear(); | ||||||
|                     ImGui::CloseCurrentPopup(); |                     ImGui::CloseCurrentPopup(); | ||||||
|   | |||||||
| @@ -6177,15 +6177,9 @@ bool ImGui::ListBoxHeader(const char* label, const ImVec2& size_arg) | |||||||
| // FIXME: In principle this function should be called BeginListBox(). We should rename it after re-evaluating if we want to keep the same signature. | // FIXME: In principle this function should be called BeginListBox(). We should rename it after re-evaluating if we want to keep the same signature. | ||||||
| bool ImGui::ListBoxHeader(const char* label, int items_count, int height_in_items) | bool ImGui::ListBoxHeader(const char* label, int items_count, int height_in_items) | ||||||
| { | { | ||||||
|     // Size default to hold ~7.25 items. |     // If height_in_items == -1, default height is maximum 7. | ||||||
|     // We add +25% worth of item height to allow the user to see at a glance if there are more items up/down, without looking at the scrollbar. |  | ||||||
|     // We don't add this extra bit if items_count <= height_in_items. It is slightly dodgy, because it means a dynamic list of items will make the widget resize occasionally when it crosses that size. |  | ||||||
|     // I am expecting that someone will come and complain about this behavior in a remote future, then we can advise on a better solution. |  | ||||||
|     ImGuiContext& g = *GImGui; |     ImGuiContext& g = *GImGui; | ||||||
|     if (height_in_items < 0) |     float height_in_items_f = (height_in_items < 0 ? ImMin(items_count, 7) : height_in_items) + 0.25f; | ||||||
|         height_in_items = ImMin(items_count, 7); |  | ||||||
|     float height_in_items_f = (height_in_items < items_count) ? (height_in_items + 0.25f) : (height_in_items + 0.00f); |  | ||||||
|  |  | ||||||
|     ImVec2 size; |     ImVec2 size; | ||||||
|     size.x = 0.0f; |     size.x = 0.0f; | ||||||
|     size.y = GetTextLineHeightWithSpacing() * height_in_items_f + g.Style.FramePadding.y * 2.0f; |     size.y = GetTextLineHeightWithSpacing() * height_in_items_f + g.Style.FramePadding.y * 2.0f; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user