mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Added ImGuiWindowFlags_UnsavedDocument window flag to append '*' to title without altering the ID, as a convenience to avoid using the ### operator. (merged from Docking branch)
This commit is contained in:
parent
15447f5b7b
commit
cc1283fb78
@ -39,6 +39,8 @@ Breaking Changes:
|
|||||||
The addition of new configuration options in the Docking branch is pushing for a little reorganization of those names.
|
The addition of new configuration options in the Docking branch is pushing for a little reorganization of those names.
|
||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
|
- Added ImGuiWindowFlags_UnsavedDocument window flag to append '*' to title without altering
|
||||||
|
the ID, as a convenience to avoid using the ### operator.
|
||||||
- Resizing windows from edge is now enabled by default (io.ConfigWindowsResizeFromEdges=true). Note that
|
- Resizing windows from edge is now enabled by default (io.ConfigWindowsResizeFromEdges=true). Note that
|
||||||
it only works _if_ the back-end sets ImGuiBackendFlags_HasMouseCursors, which the standard back-end do.
|
it only works _if_ the back-end sets ImGuiBackendFlags_HasMouseCursors, which the standard back-end do.
|
||||||
- Added io.ConfigWindowsMoveFromTitleBarOnly option. Still is ignored by window with no title bars (often popups).
|
- Added io.ConfigWindowsMoveFromTitleBarOnly option. Still is ignored by window with no title bars (often popups).
|
||||||
|
13
imgui.cpp
13
imgui.cpp
@ -5093,8 +5093,11 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
|
window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
|
||||||
window->DC.ItemFlags = item_flags_backup;
|
window->DC.ItemFlags = item_flags_backup;
|
||||||
|
|
||||||
// Title text (FIXME: refactor text alignment facilities along with RenderText helpers, this is too much code for what it does.)
|
// Title bar text (with: horizontal alignment, avoiding collapse/close button, optional "unsaved document" marker)
|
||||||
ImVec2 text_size = CalcTextSize(name, NULL, true);
|
// FIXME: Refactor text alignment facilities along with RenderText helpers, this is too much code..
|
||||||
|
const char* UNSAVED_DOCUMENT_MARKER = "*";
|
||||||
|
float marker_size_x = (flags & ImGuiWindowFlags_UnsavedDocument) ? CalcTextSize(UNSAVED_DOCUMENT_MARKER, NULL, false).x : 0.0f;
|
||||||
|
ImVec2 text_size = CalcTextSize(name, NULL, true) + ImVec2(marker_size_x, 0.0f);
|
||||||
ImRect text_r = title_bar_rect;
|
ImRect text_r = title_bar_rect;
|
||||||
float pad_left = (flags & ImGuiWindowFlags_NoCollapse) ? style.FramePadding.x : (style.FramePadding.x + g.FontSize + style.ItemInnerSpacing.x);
|
float pad_left = (flags & ImGuiWindowFlags_NoCollapse) ? style.FramePadding.x : (style.FramePadding.x + g.FontSize + style.ItemInnerSpacing.x);
|
||||||
float pad_right = (p_open == NULL) ? style.FramePadding.x : (style.FramePadding.x + g.FontSize + style.ItemInnerSpacing.x);
|
float pad_right = (p_open == NULL) ? style.FramePadding.x : (style.FramePadding.x + g.FontSize + style.ItemInnerSpacing.x);
|
||||||
@ -5105,6 +5108,12 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
ImRect clip_rect = text_r;
|
ImRect clip_rect = text_r;
|
||||||
clip_rect.Max.x = window->Pos.x + window->Size.x - (p_open ? title_bar_rect.GetHeight() - 3 : style.FramePadding.x); // Match the size of CloseButton()
|
clip_rect.Max.x = window->Pos.x + window->Size.x - (p_open ? title_bar_rect.GetHeight() - 3 : style.FramePadding.x); // Match the size of CloseButton()
|
||||||
RenderTextClipped(text_r.Min, text_r.Max, name, NULL, &text_size, style.WindowTitleAlign, &clip_rect);
|
RenderTextClipped(text_r.Min, text_r.Max, name, NULL, &text_size, style.WindowTitleAlign, &clip_rect);
|
||||||
|
if (flags & ImGuiWindowFlags_UnsavedDocument)
|
||||||
|
{
|
||||||
|
ImVec2 marker_pos = ImVec2(ImMax(text_r.Min.x, text_r.Min.x + (text_r.GetWidth() - text_size.x) * style.WindowTitleAlign.x) + text_size.x, text_r.Min.y) + ImVec2(2 - marker_size_x, 0.0f);
|
||||||
|
ImVec2 off = ImVec2(0.0f, (float)(int)(-g.FontSize * 0.25f));
|
||||||
|
RenderTextClipped(marker_pos + off, text_r.Max + off, UNSAVED_DOCUMENT_MARKER, NULL, NULL, ImVec2(0, style.WindowTitleAlign.y), &clip_rect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save clipped aabb so we can access it in constant-time in FindHoveredWindow()
|
// Save clipped aabb so we can access it in constant-time in FindHoveredWindow()
|
||||||
|
1
imgui.h
1
imgui.h
@ -665,6 +665,7 @@ enum ImGuiWindowFlags_
|
|||||||
ImGuiWindowFlags_AlwaysUseWindowPadding = 1 << 16, // Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient)
|
ImGuiWindowFlags_AlwaysUseWindowPadding = 1 << 16, // Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient)
|
||||||
ImGuiWindowFlags_NoNavInputs = 1 << 18, // No gamepad/keyboard navigation within the window
|
ImGuiWindowFlags_NoNavInputs = 1 << 18, // No gamepad/keyboard navigation within the window
|
||||||
ImGuiWindowFlags_NoNavFocus = 1 << 19, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB)
|
ImGuiWindowFlags_NoNavFocus = 1 << 19, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB)
|
||||||
|
ImGuiWindowFlags_UnsavedDocument = 1 << 20, // Append '*' to title without affecting the ID, as a convenience to avoid using the ### operator. When used in a tab/docking context, tab is selected on closure and closure is deferred by one frame to allow code to cancel the closure (with a confirmation popup, etc.) without flicker.
|
||||||
ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
|
ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
|
||||||
ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse,
|
ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse,
|
||||||
ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
|
ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
|
||||||
|
Loading…
Reference in New Issue
Block a user