Demo: Partly fix resizing constraint demo. (#6210, #5627)

Broken by 2569c6474
This commit is contained in:
ocornut 2023-11-13 14:53:14 +01:00
parent fe6544622b
commit 75c46a3930
2 changed files with 16 additions and 3 deletions

View File

@ -215,6 +215,7 @@ Other changes:
- Demo: Added "Drag and Drop -> Tooltip at target location" demo. - Demo: Added "Drag and Drop -> Tooltip at target location" demo.
- Demo: Added "Layout -> Child Windows -> Manual-resize" demo. (#1710) - Demo: Added "Layout -> Child Windows -> Manual-resize" demo. (#1710)
- Demo: Added "Layout -> Child Windows -> Auto-resize with constraints" demo. (#1666, #1395, #1496, #1710) - Demo: Added "Layout -> Child Windows -> Auto-resize with constraints" demo. (#1666, #1395, #1496, #1710)
- Demo: Partly fixed "Examples -> Constrained-resizing window" custom constrains demo. (#6210) [@cfillion]
- Backends: Vulkan: Removed parameter from ImGui_ImplVulkan_CreateFontsTexture(): backend now creates its own - Backends: Vulkan: Removed parameter from ImGui_ImplVulkan_CreateFontsTexture(): backend now creates its own
command-buffer to upload fonts. Removed ImGui_ImplVulkan_DestroyFontUploadObjects() which is now unecessary. command-buffer to upload fonts. Removed ImGui_ImplVulkan_DestroyFontUploadObjects() which is now unecessary.
No need to call ImGui_ImplVulkan_CreateFontsTexture() as it is done automatically in NewFrame(). No need to call ImGui_ImplVulkan_CreateFontsTexture() as it is done automatically in NewFrame().

View File

@ -7674,9 +7674,21 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
{ {
// Helper functions to demonstrate programmatic constraints // Helper functions to demonstrate programmatic constraints
// FIXME: This doesn't take account of decoration size (e.g. title bar), library should make this easier. // FIXME: This doesn't take account of decoration size (e.g. title bar), library should make this easier.
static void AspectRatio(ImGuiSizeCallbackData* data) { float aspect_ratio = *(float*)data->UserData; data->DesiredSize.x = IM_MAX(data->CurrentSize.x, data->CurrentSize.y); data->DesiredSize.y = (float)(int)(data->DesiredSize.x / aspect_ratio); } // FIXME: None of the three demos works consistently when resizing from borders.
static void Square(ImGuiSizeCallbackData* data) { data->DesiredSize.x = data->DesiredSize.y = IM_MAX(data->CurrentSize.x, data->CurrentSize.y); } static void AspectRatio(ImGuiSizeCallbackData* data)
static void Step(ImGuiSizeCallbackData* data) { float step = *(float*)data->UserData; data->DesiredSize = ImVec2((int)(data->CurrentSize.x / step + 0.5f) * step, (int)(data->CurrentSize.y / step + 0.5f) * step); } {
float aspect_ratio = *(float*)data->UserData;
data->DesiredSize.y = (float)(int)(data->DesiredSize.x / aspect_ratio);
}
static void Square(ImGuiSizeCallbackData* data)
{
data->DesiredSize.x = data->DesiredSize.y = IM_MAX(data->DesiredSize.x, data->DesiredSize.y);
}
static void Step(ImGuiSizeCallbackData* data)
{
float step = *(float*)data->UserData;
data->DesiredSize = ImVec2((int)(data->DesiredSize.x / step + 0.5f) * step, (int)(data->DesiredSize.y / step + 0.5f) * step);
}
}; };
const char* test_desc[] = const char* test_desc[] =