Skip to content

Commit

Permalink
Demo: Partly fix resizing constraint demo. (#6210, #5627)
Browse files Browse the repository at this point in the history
Broken by 2569c64
  • Loading branch information
ocornut committed Nov 13, 2023
1 parent fe65446 commit 75c46a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ Other changes:
- Demo: Added "Drag and Drop -> Tooltip at target location" demo.
- Demo: Added "Layout -> Child Windows -> Manual-resize" demo. (#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
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().
Expand Down
18 changes: 15 additions & 3 deletions imgui_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7674,9 +7674,21 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
{
// Helper functions to demonstrate programmatic constraints
// 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); }
static void Square(ImGuiSizeCallbackData* data) { data->DesiredSize.x = data->DesiredSize.y = IM_MAX(data->CurrentSize.x, data->CurrentSize.y); }
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); }
// FIXME: None of the three demos works consistently when resizing from borders.
static void AspectRatio(ImGuiSizeCallbackData* data)
{
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[] =
Expand Down

0 comments on commit 75c46a3

Please sign in to comment.