mirror of https://github.com/ocornut/imgui
Added GetItemsLineHeightWithSpacing() helper.
This commit is contained in:
parent
aaefe462bb
commit
f0781d3a24
|
@ -4516,6 +4516,12 @@ float ImGui::GetTextLineHeightWithSpacing()
|
|||
return g.FontSize + g.Style.ItemSpacing.y;
|
||||
}
|
||||
|
||||
float ImGui::GetItemsLineHeightWithSpacing()
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
return g.FontSize + g.Style.FramePadding.y * 2.0f + g.Style.ItemSpacing.y;
|
||||
}
|
||||
|
||||
ImDrawList* ImGui::GetWindowDrawList()
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
|
@ -11722,7 +11728,7 @@ struct ExampleAppConsole
|
|||
// Display every line as a separate entry so we can change their color or add custom widgets. If you only want raw text you can use ImGui::TextUnformatted(log.begin(), log.end());
|
||||
// NB- if you have thousands of entries this approach may be too inefficient. You can seek and display only the lines that are visible - CalcListClipping() is a helper to compute this information.
|
||||
// If your items are of variable size you may want to implement code similar to what CalcListClipping() does. Or split your data into fixed height items to allow random-seeking into your list.
|
||||
ImGui::BeginChild("ScrollingRegion", ImVec2(0,-ImGui::GetTextLineHeightWithSpacing()*2));
|
||||
ImGui::BeginChild("ScrollingRegion", ImVec2(0,-ImGui::GetItemsLineHeightWithSpacing()));
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
{
|
||||
if (ImGui::Selectable("Clear")) ClearLog();
|
||||
|
|
1
imgui.h
1
imgui.h
|
@ -202,6 +202,7 @@ namespace ImGui
|
|||
IMGUI_API void AlignFirstTextHeightToWidgets(); // call once if the first item on the line is a Text() item and you want to vertically lower it to match subsequent (bigger) widgets
|
||||
IMGUI_API float GetTextLineHeight(); // height of font == GetWindowFontSize()
|
||||
IMGUI_API float GetTextLineHeightWithSpacing(); // spacing (in pixels) between 2 consecutive lines of text == GetWindowFontSize() + GetStyle().ItemSpacing.y
|
||||
IMGUI_API float GetItemsLineHeightWithSpacing();
|
||||
|
||||
// ID scopes
|
||||
// If you are creating widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them
|
||||
|
|
Loading…
Reference in New Issue