enkisoftware / imgui_markdown

Markdown for Dear ImGui
zlib License
1.03k stars 69 forks source link

Added configurable spacing after and before headers #27

Open MayitaMayoso opened 1 month ago

MayitaMayoso commented 1 month ago

I felt the spacing after headers was too big so I added the ability to configure how big are the spaces after and before the headers.

MayitaMayoso commented 1 month ago

IDE keep messing with the format, please ignore my previous commits to my fork 😅.

dougbinks commented 1 month ago

Thanks for this PR.

Your implementation as it stands will break current users layout, so it needs to be changed so that the default is to use ImGui::NewLine(). I think the easiest way to do this is to use a negative spaceBefore or spaceAfter to mean use Newline() and to default to -1.0f in the struct MarkdownConfig:

    MarkdownHeadingFormat   headingFormats[ NUMHEADINGS ] = { { NULL, true, -1.0f, -1.0f }, { NULL, true, -1.0f, -1.0f  }, { NULL, true, -1.0f, -1.0f  } };

Note you also need to remove the defaults from struct MarkdownHeadingFormat as these should be set as above (this makes it easier for people to see how to initialize these).

MayitaMayoso commented 1 month ago

Added the mentioned suggestions! I did set as -1.0f the default values so it does not affect the format of other people.

dougbinks commented 1 month ago

Thanks - I'll pull this to review once I get some time.

dougbinks commented 1 month ago

This does not compile for me as the function ImGui::Spacing() does not have a parameter:

https://github.com/ocornut/imgui/blob/master/imgui.h#L482

I think you could possibly use a Dummy of a given height and zero width?

dougbinks commented 1 month ago

Just a reminder that this PR is waiting on a fix as it does not compile against the latest Dear ImGui library code.