mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-16 19:11:13 +00:00
How to allow window resize to set an aspect ratio, for a video preview window? #5627
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#5627
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Version: 1.88
Branch: docking
openFrameworks / Windows
My Issue/Question:
I want to draw a window that can be resized (with the draggable top right bottom triangle)
I draw an fbo inside.
But when I set the window shape, (after calculating the window height related to the fbo aspect ratio),
the draggable triangle disappears.
Probably it's related to the passed ImGuiCond_Always condition... ?
Any idea/workaround to improve this?
Here's some pseudo / openFrameworks code;
Regards
This is demonstrated in Demo>Examples>Constrained Resized, see the ratio resizing example there and how to use a callback in SetNextWindowSizeConstraints().
Note that window size include title screen and other decoration, so if you need client size to be resized according to a ratio it needs a bit of extra calculation.
with WindowPadding=0: WindowSize = ClientSize + TitleBarSize which is GetFrameHeight()
GetTextLineWithPadding().EDITthanks, you are so kind.
I am going to amend the existing examples to clarify this calculation of client size and use non-square ratio.
I added a more explicit example for this in
2569c64.It is missing handling of window decoration (title bar). The correct and generic way to do it is a little tricky and I think the library should eventually provide more information and option to the user. In most situation, you can use:
And then perform the aspect ratio calculation by doing:
ComputeRatioedSize(CurrentSize - ExtraSizeNeeded) + ExtraSizeNeeded.
I will aim to improve examples but they need better support for the library.
Also depending on your style and need to display all pixels of a texture precisely, if your window has zero WindowPadding, it is probable you need to account for border size:
The reason being that by design we made border size not affect layout (it simplifies a few things).
I sense we need to improve a few things in the library.
We have a known table issue #3692 which is fairly severe/noticeable and will need us to refactor how window handle their decoration size. This will also lead us to #3518.