Closed soufianekhiat closed 3 years ago
Thanks for the PR and apologies for the delay.
@dougbinks and I'd prefer the imageCallback
to handle sizing. Indeed, although I could add a boolean to the MarkdownImageData
struct to select whether to resize if not enough space, this could become unwieldy.
I think this would be more suitably added to the documentation as an example of how to auto-resize in the ImageCallback()
definition in https://github.com/juliettef/imgui_markdown/blob/master/README.md#example-use-on-windows-with-links-opening-in-a-browser
Do you want to update your PR to modify the readme example or do you prefer me to do it?
I see, for now imageCallback do not allow use allow us to handle the resize of the image. Currently the image callback is agnotic of the current ImWindow. Two solutions:
What do you think? Personaly I prefer the first one, which fit in the essence of "The callback manage the resize".
The imageCallback
function is called immediately before ImGui::Image
is called, and so the ImGui
context state is in the correct state to call ImGui::GetContentRegionAvail()
as needed:
https://github.com/juliettef/imgui_markdown/blob/master/imgui_markdown.h#L584-L590
So the exact same code should work from within the imageCallback
function, returning the size via the MarkdownImageData
struct. Thus there are no changes needed to the callback.
I understand, it's just counter intuitive for me to have the user aware of the implementation, particularly with a callback. Feel free to close this PR otherwise I can provide an update.
Best
Yes, I agree it's not intuitive so we need to improve the documentation & examples. Thanks for highlighting this issue!
Resize when ImGui::GetContentRegionAvailWidth() < imageData.size.x with respect of image ratio. Tested to support image position on the line (not convicing).
TBD: support for: