Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added configurable spacing after and before headers #27

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
19 changes: 17 additions & 2 deletions imgui_markdown.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ namespace ImGui
{
ImFont* font; // ImGui font
bool separator; // if true, an underlined separator is drawn after the header
float spaceBefore = -1.0f; // Space created before rendering the header
float spaceAfter = -1.0f; // Space created after rendering the header
};

// Configuration struct for Markdown
Expand Down Expand Up @@ -985,19 +987,32 @@ namespace ImGui
{
ImGui::PushFont( fmt.font );
}
ImGui::NewLine();

if (fmt.spaceBefore == -1.0f)
{
ImGui::NewLine();
}
else
{
ImGui::Spacing( fmt.spaceBefore );
}
}
else
{
if( fmt.separator )
{
ImGui::Separator();
}

if (fmt.spaceAfter == -1.0f)
{
ImGui::NewLine();
}
else
{
ImGui::NewLine();
ImGui::Spacing( fmt.spaceAfter );
}

if( fmt.font )
{
ImGui::PopFont();
Expand Down