diff --git a/imgui.cpp b/imgui.cpp index 5efb3a6e2..2954bd6eb 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -15711,11 +15711,17 @@ void ImGui::ClearIniSettings() void ImGui::CleanupIniSettings(ImGuiSettingsCleanupArgs* args) { ImGuiContext& g = *GImGui; - if (g.PlatformIO.Platform_SessionDate == 0) - return; - ImGuiPackedDate discard_older_than_date_p = g.PlatformIO.Platform_SessionDate; - discard_older_than_date_p.SubtractMonths(args->DiscardOlderThanMonths); - args->_DiscardOlderThanDate = discard_older_than_date_p.Unpack(); + if (args->DiscardAll) + for (ImGuiSettingsHandler& handler : g.SettingsHandlers) + if (args->TypeHashFilter == 0 || handler.TypeHash == args->TypeHashFilter) + if (handler.ClearAllFn != NULL) + handler.ClearAllFn(&g, &handler); + if (g.PlatformIO.Platform_SessionDate != 0 && args->DiscardOlderThanMonths != 0) + { + ImGuiPackedDate discard_older_than_date_p = g.PlatformIO.Platform_SessionDate; + discard_older_than_date_p.SubtractMonths(args->DiscardOlderThanMonths); + args->_DiscardOlderThanDate = discard_older_than_date_p.Unpack(); + } for (ImGuiSettingsHandler& handler : g.SettingsHandlers) if (args->TypeHashFilter == 0 || handler.TypeHash == args->TypeHashFilter) if (handler.CleanupFn != NULL) diff --git a/imgui_demo.cpp b/imgui_demo.cpp index b1a5d7498..b1a326570 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -5092,7 +5092,8 @@ static void DemoWindowLayout() // If you want to create your own time line for a real application you may be better off manipulating // the cursor position yourself, aka using SetCursorPos/SetCursorScreenPos to position the widgets // yourself. You may also want to use the lower-level ImDrawList API. - int num_buttons = 10 + ((line & 1) ? line * 9 : line * 3); + const int num_buttons = 10 + ((line & 1) ? line * 9 : line * 3); + const float base_w = ImGui::GetFontSize() * 3; for (int n = 0; n < num_buttons; n++) { if (n > 0) ImGui::SameLine(); @@ -5104,7 +5105,7 @@ static void DemoWindowLayout() ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(hue, 0.6f, 0.6f)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(hue, 0.7f, 0.7f)); ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(hue, 0.8f, 0.8f)); - ImGui::Button(label, ImVec2(40.0f + sinf((float)(line + n)) * 20.0f, 0.0f)); + ImGui::Button(label, ImVec2(base_w + sinf((float)(line + n)) * base_w * 0.5f, 0.0f)); ImGui::PopStyleColor(3); ImGui::PopID(); } diff --git a/imgui_internal.h b/imgui_internal.h index a4be1621a..23b8ec0fd 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -2051,6 +2051,7 @@ struct ImGuiSettingsCleanupArgs ImGuiID TypeHashFilter = 0; // Set to restrict cleanup to a given .ini type, e.g. == ImHashStr("Window"), ImHashStr("Table"). Otherwise every types supporting Cleanup will be affected. int DiscardOlderThanMonths = 0; // Enable to discard entries older than XX months. bool DiscardWhenMissingDate = false; // Enable to discard entries missing a date. + bool DiscardAll = false; // Enable to discard all entries = same as calling ClearIniSettings() except it may be filtered. bool SetCurrentSessionDateToAll = false; // Enable to write current SessionDate to all supporting entries. // Let us know in #9460 if you use this. bool SetCurrentSessionDateWhenMissingDate = false; // Enable to write current SessionDate to all supporting entries missing a date. // Let us know in #9460 if you use this. int _DiscardOlderThanDate = 0; // [Internal]