mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-25 17:16:35 +00:00
Add Push/PopTextAlignment function
This commit is contained in:
parent
c6e0284ac5
commit
d07649b7b4
16
imgui.cpp
16
imgui.cpp
@ -3832,6 +3832,7 @@ void ImGui::GcCompactTransientWindowBuffers(ImGuiWindow* window)
|
||||
window->DC.ChildWindows.clear();
|
||||
window->DC.ItemWidthStack.clear();
|
||||
window->DC.TextWrapPosStack.clear();
|
||||
window->DC.TextAlignmentStack.clear();
|
||||
}
|
||||
|
||||
void ImGui::GcAwakeTransientWindowBuffers(ImGuiWindow* window)
|
||||
@ -6784,6 +6785,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->DC.TextWrapPos = -1.0f; // disabled
|
||||
window->DC.ItemWidthStack.resize(0);
|
||||
window->DC.TextWrapPosStack.resize(0);
|
||||
window->DC.TextAlignmentStack.resize(0);
|
||||
|
||||
if (window->AutoFitFramesX > 0)
|
||||
window->AutoFitFramesX--;
|
||||
@ -7234,6 +7236,20 @@ void ImGui::PopTextWrapPos()
|
||||
window->DC.TextWrapPosStack.pop_back();
|
||||
}
|
||||
|
||||
void ImGui::PushTextAlignment(float alignment)
|
||||
{
|
||||
ImGuiWindow *window = GetCurrentWindow();
|
||||
window->DC.TextAlignmentStack.push_back(window->DC.TextAlignment);
|
||||
window->DC.TextAlignment = alignment;
|
||||
}
|
||||
|
||||
void ImGui::PopTextAlignment()
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
window->DC.TextAlignment = window->DC.TextAlignmentStack.back();
|
||||
window->DC.TextAlignmentStack.pop_back();
|
||||
}
|
||||
|
||||
static ImGuiWindow* GetCombinedRootWindow(ImGuiWindow* window, bool popup_hierarchy)
|
||||
{
|
||||
ImGuiWindow* last_window = NULL;
|
||||
|
2
imgui.h
2
imgui.h
@ -424,6 +424,8 @@ namespace ImGui
|
||||
IMGUI_API float CalcItemWidth(); // width of item given pushed settings and current cursor position. NOT necessarily the width of last item unlike most 'Item' functions.
|
||||
IMGUI_API void PushTextWrapPos(float wrap_local_pos_x = 0.0f); // push word-wrapping position for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space
|
||||
IMGUI_API void PopTextWrapPos();
|
||||
IMGUI_API void PushTextAlignment(float alignment = 0.0f); // push text alignment position for TextWrapped*() commands. 0.0f: no alignment; 1.0f: align right; 0.5f: align center
|
||||
IMGUI_API void PopTextAlignment();
|
||||
|
||||
// Style read access
|
||||
// - Use the ShowStyleEditor() function to interactively see/edit the colors.
|
||||
|
@ -2296,8 +2296,11 @@ struct IMGUI_API ImGuiWindowTempData
|
||||
// We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.
|
||||
float ItemWidth; // Current item width (>0.0: width in pixels, <0.0: align xx pixels to the right of window).
|
||||
float TextWrapPos; // Current text wrap pos.
|
||||
float TextAlignment; // Current text alignment.
|
||||
ImVector<float> ItemWidthStack; // Store item widths to restore (attention: .back() is not == ItemWidth)
|
||||
ImVector<float> TextWrapPosStack; // Store text wrap pos to restore (attention: .back() is not == TextWrapPos)
|
||||
ImVector<float> TextAlignmentStack; // Store text alignment to restore (attention: .back() is not == TextAlignment)
|
||||
ImGuiStackSizes StackSizesOnBegin; // Store size of various stacks for asserting
|
||||
};
|
||||
|
||||
// Storage for one window
|
||||
|
Loading…
Reference in New Issue
Block a user