mirror of
https://github.com/xemu-project/imgui.git
synced 2024-11-23 10:19:46 +00:00
Columns: ImDrawList::Channels* functions now work inside columns.
Use a private splitter in columns, paving way for removal of obsolete ImDrawList::Channels* functions.
This commit is contained in:
parent
05a49f0413
commit
9cff4d6e5e
@ -79,6 +79,8 @@ Other Changes:
|
||||
In the current branch they are essentially the same as AddCircle(), AddCircleFilled() but as
|
||||
we will rework the circle rendering functions to use textures and automatic segment count
|
||||
selection, those new api can fill a gap. [@ShironekoBen]
|
||||
- Columns: ImDrawList::Channels* functions now work inside columns. Added extra comments to
|
||||
suggest using user-owned ImDrawListSplitter instead of ImDrawList functions. [@rokups]
|
||||
- Misc: Added ImGuiMouseCursor_NotAllowed enum so it can be used by more shared widgets. [@rokups]
|
||||
- Misc: Disable format checks when using stb_printf, to allow using extra formats.
|
||||
Made IMGUI_USE_STB_SPRINTF a properly documented imconfig.h flag. (#2954) [@loicmolinari]
|
||||
|
7
imgui.h
7
imgui.h
@ -1987,8 +1987,11 @@ struct ImDrawList
|
||||
IMGUI_API ImDrawList* CloneOutput() const; // Create a clone of the CmdBuffer/IdxBuffer/VtxBuffer.
|
||||
|
||||
// Advanced: Channels
|
||||
// - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit foreground primitives before background primitives)
|
||||
// - Use to minimize draw calls (e.g. if going back-and-forth between multiple non-overlapping clipping rectangles, prefer to append into separate channels then merge at the end)
|
||||
// - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit FG primitives before BG primitives)
|
||||
// - Use to minimize draw calls (e.g. if going back-and-forth between multiple clipping rectangles, prefer to append into separate channels then merge at the end)
|
||||
// - FIXME-OBSOLETE: This API shouldn't have been in ImDrawList in the first place!
|
||||
// Prefer using your own persistent copy of ImDrawListSplitter as you can stack them.
|
||||
// Using the ImDrawList::ChannelsXXXX you cannot stack a split over another.
|
||||
inline void ChannelsSplit(int count) { _Splitter.Split(this, count); }
|
||||
inline void ChannelsMerge() { _Splitter.Merge(this); }
|
||||
inline void ChannelsSetCurrent(int n) { _Splitter.SetCurrentChannel(this, n); }
|
||||
|
@ -1307,7 +1307,7 @@ void ImDrawListSplitter::ClearFreeMemory()
|
||||
|
||||
void ImDrawListSplitter::Split(ImDrawList* draw_list, int channels_count)
|
||||
{
|
||||
IM_ASSERT(_Current == 0 && _Count <= 1);
|
||||
IM_ASSERT(_Current == 0 && _Count <= 1 && "Nested channel splitting is not supported. Please use separate instances of ImDrawListSplitter.");
|
||||
int old_channels_count = _Channels.Size;
|
||||
if (old_channels_count < channels_count)
|
||||
_Channels.resize(channels_count);
|
||||
|
@ -843,6 +843,7 @@ struct ImGuiColumns
|
||||
ImRect HostClipRect; // Backup of ClipRect at the time of BeginColumns()
|
||||
ImRect HostWorkRect; // Backup of WorkRect at the time of BeginColumns()
|
||||
ImVector<ImGuiColumnData> Columns;
|
||||
ImDrawListSplitter Splitter;
|
||||
|
||||
ImGuiColumns() { Clear(); }
|
||||
void Clear()
|
||||
|
@ -7400,7 +7400,7 @@ void ImGui::PushColumnsBackground()
|
||||
ImGuiColumns* columns = window->DC.CurrentColumns;
|
||||
if (columns->Count == 1)
|
||||
return;
|
||||
window->DrawList->ChannelsSetCurrent(0);
|
||||
columns->Splitter.SetCurrentChannel(window->DrawList, 0);
|
||||
int cmd_size = window->DrawList->CmdBuffer.Size;
|
||||
PushClipRect(columns->HostClipRect.Min, columns->HostClipRect.Max, false);
|
||||
IM_UNUSED(cmd_size);
|
||||
@ -7413,7 +7413,7 @@ void ImGui::PopColumnsBackground()
|
||||
ImGuiColumns* columns = window->DC.CurrentColumns;
|
||||
if (columns->Count == 1)
|
||||
return;
|
||||
window->DrawList->ChannelsSetCurrent(columns->Current + 1);
|
||||
columns->Splitter.SetCurrentChannel(window->DrawList, columns->Current + 1);
|
||||
PopClipRect();
|
||||
}
|
||||
|
||||
@ -7504,8 +7504,8 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
|
||||
|
||||
if (columns->Count > 1)
|
||||
{
|
||||
window->DrawList->ChannelsSplit(1 + columns->Count);
|
||||
window->DrawList->ChannelsSetCurrent(1);
|
||||
columns->Splitter.Split(window->DrawList, 1 + columns->Count);
|
||||
columns->Splitter.SetCurrentChannel(window->DrawList, 1);
|
||||
PushColumnClipRect(0);
|
||||
}
|
||||
|
||||
@ -7544,14 +7544,14 @@ void ImGui::NextColumn()
|
||||
// Columns 1+ ignore IndentX (by canceling it out)
|
||||
// FIXME-COLUMNS: Unnecessary, could be locked?
|
||||
window->DC.ColumnsOffset.x = GetColumnOffset(columns->Current) - window->DC.Indent.x + column_padding;
|
||||
window->DrawList->ChannelsSetCurrent(columns->Current + 1);
|
||||
columns->Splitter.SetCurrentChannel(window->DrawList, columns->Current + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// New row/line
|
||||
// Column 0 honor IndentX
|
||||
window->DC.ColumnsOffset.x = ImMax(column_padding - window->WindowPadding.x, 0.0f);
|
||||
window->DrawList->ChannelsSetCurrent(1);
|
||||
columns->Splitter.SetCurrentChannel(window->DrawList, 1);
|
||||
columns->Current = 0;
|
||||
columns->LineMinY = columns->LineMaxY;
|
||||
}
|
||||
@ -7581,7 +7581,7 @@ void ImGui::EndColumns()
|
||||
if (columns->Count > 1)
|
||||
{
|
||||
PopClipRect();
|
||||
window->DrawList->ChannelsMerge();
|
||||
columns->Splitter.Merge(window->DrawList);
|
||||
}
|
||||
|
||||
const ImGuiColumnsFlags flags = columns->Flags;
|
||||
|
Loading…
Reference in New Issue
Block a user